const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-BjK-bzFQ.js","assets/usePostcardZones-cvURH7hE.js","assets/DirectMail-CRFnXrhs.js","assets/LeadSiteEditor-B310g2jz.js","assets/VideoUrlField-BGuQ4gq0.js","assets/LeadSiteEditor-BzY4kI8E.css","assets/AdminLeadSiteThemes-moo4KMiC.js","assets/EmailCampaignComposer-GUZHbY6v.js","assets/EditorModeSelector-Dc5_QUoN.js","assets/SharedCampaignTemplates-D5KAXfKA.js","assets/TemplateEditorDialog-DUwu6JYV.js","assets/AgentTemplates-BtHfDVyV.js","assets/TheLocalMoveHome-DM4Qj5CX.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-BqFZhb2Q.js"])))=>i.map(i=>d[i]); var ept=Object.defineProperty;var ITe=t=>{throw TypeError(t)};var tpt=(t,s,r)=>s in t?ept(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Pn=(t,s,r)=>tpt(t,typeof s!="symbol"?s+"":s,r),Rfe=(t,s,r)=>s.has(t)||ITe("Cannot "+r);var ls=(t,s,r)=>(Rfe(t,s,"read from private field"),r?r.call(t):s.get(t)),ri=(t,s,r)=>s.has(t)?ITe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Xn=(t,s,r,n)=>(Rfe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),to=(t,s,r)=>(Rfe(t,s,"access private method"),r);var D7=(t,s,r,n)=>({set _(a){Xn(t,s,a,r)},get _(){return ls(t,s,n)}});function spt(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 rpt="modulepreload",npt=function(t){return"/"+t},LTe={},Lo=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=npt(c),c in LTe)return;LTe[c]=!0;const u=c.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":rpt,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((g,y)=>{f.addEventListener("load",g),f.addEventListener("error",()=>y(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 Jv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Do(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Z9e(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 Y9e={exports:{}},yde={},Q9e={exports:{}},wo={};/** * @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 TO=Symbol.for("react.element"),apt=Symbol.for("react.portal"),ipt=Symbol.for("react.fragment"),opt=Symbol.for("react.strict_mode"),lpt=Symbol.for("react.profiler"),cpt=Symbol.for("react.provider"),dpt=Symbol.for("react.context"),upt=Symbol.for("react.forward_ref"),hpt=Symbol.for("react.suspense"),mpt=Symbol.for("react.memo"),ppt=Symbol.for("react.lazy"),DTe=Symbol.iterator;function fpt(t){return t===null||typeof t!="object"?null:(t=DTe&&t[DTe]||t["@@iterator"],typeof t=="function"?t:null)}var X9e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},J9e=Object.assign,eBe={};function QA(t,s,r){this.props=t,this.context=s,this.refs=eBe,this.updater=r||X9e}QA.prototype.isReactComponent={};QA.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")};QA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function tBe(){}tBe.prototype=QA.prototype;function Awe(t,s,r){this.props=t,this.context=s,this.refs=eBe,this.updater=r||X9e}var Ewe=Awe.prototype=new tBe;Ewe.constructor=Awe;J9e(Ewe,QA.prototype);Ewe.isPureReactComponent=!0;var OTe=Array.isArray,sBe=Object.prototype.hasOwnProperty,Pwe={current:null},rBe={key:!0,ref:!0,__self:!0,__source:!0};function nBe(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)sBe.call(s,n)&&!rBe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,ge=oe[ue];if(0>>1;ue<_e;){var Be=2*(ue+1)-1,Se=oe[Be],Ee=Be+1,Ae=oe[Ee];if(0>a(Se,xe))Eea(Ae,Se)?(oe[ue]=Ae,oe[Ee]=xe,ue=Ee):(oe[ue]=Se,oe[Be]=xe,ue=Be);else if(Eea(Ae,xe))oe[ue]=Ae,oe[Ee]=xe,ue=Ee;else break e}}return he}function a(oe,he){var xe=oe.sortIndex-he.sortIndex;return xe!==0?xe:oe.id-he.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var c=[],u=[],m=1,f=null,g=3,y=!1,_=!1,w=!1,j=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(oe){for(var he=r(u);he!==null;){if(he.callback===null)n(u);else if(he.startTime<=oe)n(u),he.sortIndex=he.expirationTime,s(c,he);else break;he=r(u)}}function I(oe){if(w=!1,M(oe),!_)if(r(c)!==null)_=!0,ne(P);else{var he=r(u);he!==null&&re(I,he.startTime-oe)}}function P(oe,he){_=!1,w&&(w=!1,N($),$=-1),y=!0;var xe=g;try{for(M(he),f=r(c);f!==null&&(!(f.expirationTime>he)||oe&&!X());){var ue=f.callback;if(typeof ue=="function"){f.callback=null,g=f.priorityLevel;var ge=ue(f.expirationTime<=he);he=t.unstable_now(),typeof ge=="function"?f.callback=ge:f===r(c)&&n(c),M(he)}else n(c);f=r(c)}if(f!==null)var _e=!0;else{var Be=r(u);Be!==null&&re(I,Be.startTime-he),_e=!1}return _e}finally{f=null,g=xe,y=!1}}var O=!1,q=null,$=-1,z=5,V=-1;function X(){return!(t.unstable_now()-Voe||125ue?(oe.sortIndex=xe,s(u,oe),r(c)===null&&oe===r(u)&&(w?(N($),$=-1):w=!0,re(I,xe-ue))):(oe.sortIndex=ge,s(c,oe),_||y||(_=!0,ne(P))),oe},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(oe){var he=g;return function(){var xe=g;g=he;try{return oe.apply(this,arguments)}finally{g=xe}}}})(cBe);lBe.exports=cBe;var Spt=lBe.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 Cpt=k,Tf=Spt;function en(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"),Jye=Object.prototype.hasOwnProperty,Mpt=/^[: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]*$/,FTe={},zTe={};function Tpt(t){return Jye.call(zTe,t)?!0:Jye.call(FTe,t)?!1:Mpt.test(t)?zTe[t]=!0:(FTe[t]=!0,!1)}function Apt(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 Ept(t,s,r,n){if(s===null||typeof s>"u"||Apt(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 Wm(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 Oh={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Oh[t]=new Wm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Oh[s]=new Wm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Oh[t]=new Wm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Oh[t]=new Wm(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){Oh[t]=new Wm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Oh[t]=new Wm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Oh[t]=new Wm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Oh[t]=new Wm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Oh[t]=new Wm(t,5,!1,t.toLowerCase(),null,!1,!1)});var Dwe=/[\-:]([a-z])/g;function Owe(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(Dwe,Owe);Oh[s]=new Wm(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(Dwe,Owe);Oh[s]=new Wm(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(Dwe,Owe);Oh[s]=new Wm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Oh[t]=new Wm(t,1,!1,t.toLowerCase(),null,!1,!1)});Oh.xlinkHref=new Wm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Oh[t]=new Wm(t,1,!1,t.toLowerCase(),null,!0,!0)});function Rwe(t,s,r,n){var a=Oh.hasOwnProperty(s)?Oh[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{Bfe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?LI(t):""}function Ppt(t){switch(t.tag){case 5:return LI(t.type);case 16:return LI("Lazy");case 13:return LI("Suspense");case 19:return LI("SuspenseList");case 0:case 2:case 15:return t=$fe(t.type,!1),t;case 11:return t=$fe(t.type.render,!1),t;case 1:return t=$fe(t.type,!0),t;default:return""}}function r0e(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 cM:return"Fragment";case lM:return"Portal";case e0e:return"Profiler";case Fwe:return"StrictMode";case t0e:return"Suspense";case s0e:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case hBe:return(t.displayName||"Context")+".Consumer";case uBe:return(t._context.displayName||"Context")+".Provider";case zwe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Bwe:return s=t.displayName||null,s!==null?s:r0e(t.type)||"Memo";case Jb:s=t._payload,t=t._init;try{return r0e(t(s))}catch{}}return null}function Ipt(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 r0e(s);case 8:return s===Fwe?"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 mw(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function pBe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Lpt(t){var s=pBe(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 F7(t){t._valueTracker||(t._valueTracker=Lpt(t))}function fBe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=pBe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Zie(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 n0e(t,s){var r=s.checked;return id({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function $Te(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=mw(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 xBe(t,s){s=s.checked,s!=null&&Rwe(t,"checked",s,!1)}function a0e(t,s){xBe(t,s);var r=mw(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")?i0e(t,s.type,r):s.hasOwnProperty("defaultValue")&&i0e(t,s.type,mw(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function qTe(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 i0e(t,s,r){(s!=="number"||Zie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var DI=Array.isArray;function IM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=z7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function q8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var eL={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},Dpt=["Webkit","ms","Moz","O"];Object.keys(eL).forEach(function(t){Dpt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),eL[s]=eL[t]})});function bBe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||eL.hasOwnProperty(t)&&eL[t]?(""+s).trim():s+"px"}function _Be(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=bBe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var Opt=id({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 c0e(t,s){if(s){if(Opt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(en(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(en(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(en(61))}if(s.style!=null&&typeof s.style!="object")throw Error(en(62))}}function d0e(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 u0e=null;function $we(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var h0e=null,LM=null,DM=null;function HTe(t){if(t=PO(t)){if(typeof h0e!="function")throw Error(en(280));var s=t.stateNode;s&&(s=jde(s),h0e(t.stateNode,t.type,s))}}function wBe(t){LM?DM?DM.push(t):DM=[t]:LM=t}function jBe(){if(LM){var t=LM,s=DM;if(DM=LM=null,HTe(t),s)for(t=0;t>>=0,t===0?32:31-(Wpt(t)/Kpt|0)|0}var B7=64,$7=4194304;function OI(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 Jie(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=OI(i):(o&=l,o!==0&&(n=OI(o)))}else l=r&~a,l!==0?n=OI(l):o!==0&&(n=OI(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 AO(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Xg(s),t[s]=r}function Xpt(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=sL),eAe=" ",tAe=!1;function UBe(t,s){switch(t){case"keyup":return Sft.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function VBe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var dM=!1;function Mft(t,s){switch(t){case"compositionend":return VBe(s);case"keypress":return s.which!==32?null:(tAe=!0,eAe);case"textInput":return t=s.data,t===eAe&&tAe?null:t;default:return null}}function Tft(t,s){if(dM)return t==="compositionend"||!Zwe&&UBe(t,s)?(t=$Be(),T9=Gwe=T_=null,dM=!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=aAe(r)}}function KBe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?KBe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function ZBe(){for(var t=window,s=Zie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Zie(t.document)}return s}function Ywe(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 Fft(t){var s=ZBe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&KBe(r.ownerDocument.documentElement,r)){if(n!==null&&Ywe(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=iAe(r,o);var l=iAe(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,uM=null,y0e=null,nL=null,v0e=!1;function oAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;v0e||uM==null||uM!==Zie(n)||(n=uM,"selectionStart"in n&&Ywe(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}),nL&&K8(nL,n)||(nL=n,n=soe(y0e,"onSelect"),0pM||(t.current=k0e[pM],k0e[pM]=null,pM--)}function tc(t,s){pM++,k0e[pM]=t.current,t.current=s}var pw={},em=Tw(pw),jp=Tw(!1),VS=pw;function $T(t,s){var r=t.type.contextTypes;if(!r)return pw;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 Np(t){return t=t.childContextTypes,t!=null}function noe(){Mc(jp),Mc(em)}function pAe(t,s,r){if(em.current!==pw)throw Error(en(168));tc(em,s),tc(jp,r)}function n$e(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(en(108,Ipt(t)||"Unknown",a));return id({},r,n)}function aoe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||pw,VS=em.current,tc(em,t),tc(jp,jp.current),!0}function fAe(t,s,r){var n=t.stateNode;if(!n)throw Error(en(169));r?(t=n$e(t,s,VS),n.__reactInternalMemoizedMergedChildContext=t,Mc(jp),Mc(em),tc(em,t)):Mc(jp),tc(jp,r)}var qv=null,Nde=!1,txe=!1;function a$e(t){qv===null?qv=[t]:qv.push(t)}function Yft(t){Nde=!0,a$e(t)}function Aw(){if(!txe&&qv!==null){txe=!0;var t=0,s=wl;try{var r=qv;for(wl=1;t>=l,a-=l,e1=1<<32-Xg(s)+a|r<$?(z=q,q=null):z=q.sibling;var V=g(N,q,M[$],I);if(V===null){q===null&&(q=z);break}t&&q&&V.alternate===null&&s(N,q),S=o(V,S,$),O===null?P=V:O.sibling=V,O=V,q=z}if($===M.length)return r(N,q),$c&&Y2(N,$),P;if(q===null){for(;$$?(z=q,q=null):z=q.sibling;var X=g(N,q,V.value,I);if(X===null){q===null&&(q=z);break}t&&q&&X.alternate===null&&s(N,q),S=o(X,S,$),O===null?P=X:O.sibling=X,O=X,q=z}if(V.done)return r(N,q),$c&&Y2(N,$),P;if(q===null){for(;!V.done;$++,V=M.next())V=f(N,V.value,I),V!==null&&(S=o(V,S,$),O===null?P=V:O.sibling=V,O=V);return $c&&Y2(N,$),P}for(q=n(N,q);!V.done;$++,V=M.next())V=y(q,N,$,V.value,I),V!==null&&(t&&V.alternate!==null&&q.delete(V.key===null?$:V.key),S=o(V,S,$),O===null?P=V:O.sibling=V,O=V);return t&&q.forEach(function(Y){return s(N,Y)}),$c&&Y2(N,$),P}function j(N,S,M,I){if(typeof M=="object"&&M!==null&&M.type===cM&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case R7:e:{for(var P=M.key,O=S;O!==null;){if(O.key===P){if(P=M.type,P===cM){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===P||typeof P=="object"&&P!==null&&P.$$typeof===Jb&&yAe(P)===O.type){r(N,O.sibling),S=a(O,M.props),S.ref=JP(N,O,M),S.return=N,N=S;break e}r(N,O);break}else s(N,O);O=O.sibling}M.type===cM?(S=Y4(M.props.children,N.mode,I,M.key),S.return=N,N=S):(I=R9(M.type,M.key,M.props,null,N.mode,I),I.ref=JP(N,S,M),I.return=N,N=I)}return l(N);case lM: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=cxe(M,N.mode,I),S.return=N,N=S}return l(N);case Jb:return O=M._init,j(N,S,O(M._payload),I)}if(DI(M))return _(N,S,M,I);if(KP(M))return w(N,S,M,I);K7(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=lxe(M,N.mode,I),S.return=N,N=S),l(N)):r(N,S)}return j}var UT=c$e(!0),d$e=c$e(!1),loe=Tw(null),coe=null,gM=null,e2e=null;function t2e(){e2e=gM=coe=null}function s2e(t){var s=loe.current;Mc(loe),t._currentValue=s}function M0e(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 RM(t,s){coe=t,e2e=gM=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(yp=!0),t.firstContext=null)}function Fx(t){var s=t._currentValue;if(e2e!==t)if(t={context:t,memoizedValue:s,next:null},gM===null){if(coe===null)throw Error(en(308));gM=t,coe.dependencies={lanes:0,firstContext:t}}else gM=gM.next=t;return s}var b4=null;function r2e(t){b4===null?b4=[t]:b4.push(t)}function u$e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,r2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,E1(t,n)}function E1(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 e_=!1;function n2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function h$e(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 o1(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function q_(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,qo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,E1(t,r)}return a=n.interleaved,a===null?(s.next=s,r2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,E1(t,r)}function E9(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,Uwe(t,r)}}function vAe(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 doe(t,s,r,n){var a=t.updateQueue;e_=!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 m=t.alternate;m!==null&&(m=m.updateQueue,i=m.lastBaseUpdate,i!==l&&(i===null?m.firstBaseUpdate=u:i.next=u,m.lastBaseUpdate=c))}if(o!==null){var f=a.baseState;l=0,m=u=c=null,i=o;do{var g=i.lane,y=i.eventTime;if((n&g)===g){m!==null&&(m=m.next={eventTime:y,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var _=t,w=i;switch(g=s,y=r,w.tag){case 1:if(_=w.payload,typeof _=="function"){f=_.call(y,f,g);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=w.payload,g=typeof _=="function"?_.call(y,f,g):_,g==null)break e;f=id({},f,g);break e;case 2:e_=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,g=a.effects,g===null?a.effects=[i]:g.push(i))}else y={eventTime:y,lane:g,tag:i.tag,payload:i.payload,callback:i.callback,next:null},m===null?(u=m=y,c=f):m=m.next=y,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(m===null&&(c=f),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=m,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);WS|=l,t.lanes=l,t.memoizedState=f}}function bAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=rxe.transition;rxe.transition={};try{t(!1),s()}finally{wl=r,rxe.transition=n}}function T$e(){return zx().memoizedState}function ext(t,s,r){var n=V_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},A$e(t))E$e(s,r);else if(r=u$e(t,s,r,n),r!==null){var a=Rm();Jg(r,t,n,a),P$e(r,s,n)}}function txt(t,s,r){var n=V_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(A$e(t))E$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,oy(i,l)){var c=s.interleaved;c===null?(a.next=a,r2e(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=u$e(t,s,a,n),r!==null&&(a=Rm(),Jg(r,t,n,a),P$e(r,s,n))}}function A$e(t){var s=t.alternate;return t===rd||s!==null&&s===rd}function E$e(t,s){aL=hoe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function P$e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Uwe(t,r)}}var moe={readContext:Fx,useCallback:$h,useContext:$h,useEffect:$h,useImperativeHandle:$h,useInsertionEffect:$h,useLayoutEffect:$h,useMemo:$h,useReducer:$h,useRef:$h,useState:$h,useDebugValue:$h,useDeferredValue:$h,useTransition:$h,useMutableSource:$h,useSyncExternalStore:$h,useId:$h,unstable_isNewReconciler:!1},sxt={readContext:Fx,useCallback:function(t,s){return Ky().memoizedState=[t,s===void 0?null:s],t},useContext:Fx,useEffect:wAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,I9(4194308,4,N$e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return I9(4194308,4,t,s)},useInsertionEffect:function(t,s){return I9(4,2,t,s)},useMemo:function(t,s){var r=Ky();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Ky();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=ext.bind(null,rd,t),[n.memoizedState,t]},useRef:function(t){var s=Ky();return t={current:t},s.memoizedState=t},useState:_Ae,useDebugValue:h2e,useDeferredValue:function(t){return Ky().memoizedState=t},useTransition:function(){var t=_Ae(!1),s=t[0];return t=Jft.bind(null,t[1]),Ky().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=rd,a=Ky();if($c){if(r===void 0)throw Error(en(407));r=r()}else{if(r=s(),th===null)throw Error(en(349));GS&30||x$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,wAe(y$e.bind(null,n,o,t),[t]),n.flags|=2048,sD(9,g$e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Ky(),s=th.identifierPrefix;if($c){var r=t1,n=e1;r=(n&~(1<<32-Xg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=eD++,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[a0]=s,t[Q8]=n,q$e(t,s,!1,!1),s.stateNode=t;e:{switch(l=d0e(r,n),r){case"dialog":vc("cancel",t),vc("close",t),a=n;break;case"iframe":case"object":case"embed":vc("load",t),a=n;break;case"video":case"audio":for(a=0;aGT&&(s.flags|=128,n=!0,eI(o,!1),s.lanes=4194304)}else{if(!n)if(t=uoe(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),eI(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!$c)return qh(s),null}else 2*Dd()-o.renderingStartTime>GT&&r!==1073741824&&(s.flags|=128,n=!0,eI(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=Dd(),s.sibling=null,r=Jc.current,tc(Jc,n?r&1|2:r&1),s):(qh(s),null);case 22:case 23:return y2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?rf&1073741824&&(qh(s),s.subtreeFlags&6&&(s.flags|=8192)):qh(s),null;case 24:return null;case 25:return null}throw Error(en(156,s.tag))}function dxt(t,s){switch(Xwe(s),s.tag){case 1:return Np(s.type)&&noe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return VT(),Mc(jp),Mc(em),o2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return i2e(s),null;case 13:if(Mc(Jc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(en(340));qT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Mc(Jc),null;case 4:return VT(),null;case 10:return s2e(s.type._context),null;case 22:case 23:return y2e(),null;case 24:return null;default:return null}}var Y7=!1,Wh=!1,uxt=typeof WeakSet=="function"?WeakSet:Set,oa=null;function yM(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){fd(t,s,n)}else r.current=null}function R0e(t,s,r){try{r()}catch(n){fd(t,s,n)}}var IAe=!1;function hxt(t,s){if(b0e=eoe,t=ZBe(),Ywe(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,m=0,f=t,g=null;t:for(;;){for(var y;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),(y=f.firstChild)!==null;)g=f,f=y;for(;;){if(f===t)break t;if(g===r&&++u===a&&(i=l),g===o&&++m===n&&(c=l),(y=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=y}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(_0e={focusedElem:t,selectionRange:r},eoe=!1,oa=s;oa!==null;)if(s=oa,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,oa=t;else for(;oa!==null;){s=oa;try{var _=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var w=_.memoizedProps,j=_.memoizedState,N=s.stateNode,S=N.getSnapshotBeforeUpdate(s.elementType===s.type?w:Dg(s.type,w),j);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(en(163))}}catch(I){fd(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,oa=t;break}oa=s.return}return _=IAe,IAe=!1,_}function iL(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&&R0e(s,r,o)}a=a.next}while(a!==n)}}function Cde(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 F0e(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 H$e(t){var s=t.alternate;s!==null&&(t.alternate=null,H$e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[a0],delete s[Q8],delete s[N0e],delete s[Kft],delete s[Zft])),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 G$e(t){return t.tag===5||t.tag===3||t.tag===4}function LAe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||G$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 z0e(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=roe));else if(n!==4&&(t=t.child,t!==null))for(z0e(t,s,r),t=t.sibling;t!==null;)z0e(t,s,r),t=t.sibling}function B0e(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(B0e(t,s,r),t=t.sibling;t!==null;)B0e(t,s,r),t=t.sibling}var bh=null,zg=!1;function Rb(t,s,r){for(r=r.child;r!==null;)W$e(t,s,r),r=r.sibling}function W$e(t,s,r){if(p0&&typeof p0.onCommitFiberUnmount=="function")try{p0.onCommitFiberUnmount(vde,r)}catch{}switch(r.tag){case 5:Wh||yM(r,s);case 6:var n=bh,a=zg;bh=null,Rb(t,s,r),bh=n,zg=a,bh!==null&&(zg?(t=bh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):bh.removeChild(r.stateNode));break;case 18:bh!==null&&(zg?(t=bh,r=r.stateNode,t.nodeType===8?exe(t.parentNode,r):t.nodeType===1&&exe(t,r),G8(t)):exe(bh,r.stateNode));break;case 4:n=bh,a=zg,bh=r.stateNode.containerInfo,zg=!0,Rb(t,s,r),bh=n,zg=a;break;case 0:case 11:case 14:case 15:if(!Wh&&(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)&&R0e(r,s,l),a=a.next}while(a!==n)}Rb(t,s,r);break;case 1:if(!Wh&&(yM(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){fd(r,s,i)}Rb(t,s,r);break;case 21:Rb(t,s,r);break;case 22:r.mode&1?(Wh=(n=Wh)||r.memoizedState!==null,Rb(t,s,r),Wh=n):Rb(t,s,r);break;default:Rb(t,s,r)}}function DAe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new uxt),s.forEach(function(n){var a=_xt.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function Sg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Dd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*pxt(n/1960))-n,10t?16:t,A_===null)var n=!1;else{if(t=A_,A_=null,xoe=0,qo&6)throw Error(en(331));var a=qo;for(qo|=4,oa=t.current;oa!==null;){var o=oa,l=o.child;if(oa.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cDd()-x2e?Z4(t,0):f2e|=r),kp(t,s)}function tqe(t,s){s===0&&(t.mode&1?(s=$7,$7<<=1,!($7&130023424)&&($7=4194304)):s=1);var r=Rm();t=E1(t,s),t!==null&&(AO(t,s,r),kp(t,r))}function bxt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),tqe(t,r)}function _xt(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(en(314))}n!==null&&n.delete(s),tqe(t,r)}var sqe;sqe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||jp.current)yp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return yp=!1,lxt(t,s,r);yp=!!(t.flags&131072)}else yp=!1,$c&&s.flags&1048576&&i$e(s,ooe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;L9(t,s),t=s.pendingProps;var a=$T(s,em.current);RM(s,r),a=c2e(null,s,n,t,a,r);var o=d2e();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,Np(n)?(o=!0,aoe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,n2e(s),a.updater=Sde,s.stateNode=a,a._reactInternals=s,A0e(s,n,t,r),s=I0e(null,s,n,!0,o,r)):(s.tag=0,$c&&o&&Qwe(s),km(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(L9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=jxt(n),t=Dg(n,t),a){case 0:s=P0e(null,s,n,t,r);break e;case 1:s=AAe(null,s,n,t,r);break e;case 11:s=MAe(null,s,n,t,r);break e;case 14:s=TAe(null,s,n,Dg(n.type,t),r);break e}throw Error(en(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Dg(n,a),P0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Dg(n,a),AAe(t,s,n,a,r);case 3:e:{if(z$e(s),t===null)throw Error(en(387));n=s.pendingProps,o=s.memoizedState,a=o.element,h$e(t,s),doe(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=HT(Error(en(423)),s),s=EAe(t,s,n,r,a);break e}else if(n!==a){a=HT(Error(en(424)),s),s=EAe(t,s,n,r,a);break e}else for(pf=$_(s.stateNode.containerInfo.firstChild),xf=s,$c=!0,Vg=null,r=d$e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(qT(),n===a){s=P1(t,s,r);break e}km(t,s,n,r)}s=s.child}return s;case 5:return m$e(s),t===null&&C0e(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,w0e(n,a)?l=null:o!==null&&w0e(n,o)&&(s.flags|=32),F$e(t,s),km(t,s,l,r),s.child;case 6:return t===null&&C0e(s),null;case 13:return B$e(t,s,r);case 4:return a2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=UT(s,null,n,r):km(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Dg(n,a),MAe(t,s,n,a,r);case 7:return km(t,s,s.pendingProps,r),s.child;case 8:return km(t,s,s.pendingProps.children,r),s.child;case 12:return km(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,tc(loe,n._currentValue),n._currentValue=l,o!==null)if(oy(o.value,l)){if(o.children===a.children&&!jp.current){s=P1(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=o1(-1,r&-r),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var m=u.pending;m===null?c.next=c:(c.next=m.next,m.next=c),u.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),M0e(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(en(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),M0e(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}km(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,RM(s,r),a=Fx(a),n=n(a),s.flags|=1,km(t,s,n,r),s.child;case 14:return n=s.type,a=Dg(n,s.pendingProps),a=Dg(n.type,a),TAe(t,s,n,a,r);case 15:return O$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Dg(n,a),L9(t,s),s.tag=1,Np(n)?(t=!0,aoe(s)):t=!1,RM(s,r),I$e(s,n,a),A0e(s,n,a,r),I0e(null,s,n,!0,t,r);case 19:return $$e(t,s,r);case 22:return R$e(t,s,r)}throw Error(en(156,s.tag))};function rqe(t,s){return ABe(t,s)}function wxt(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 kx(t,s,r,n){return new wxt(t,s,r,n)}function b2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function jxt(t){if(typeof t=="function")return b2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===zwe)return 11;if(t===Bwe)return 14}return 2}function H_(t,s){var r=t.alternate;return r===null?(r=kx(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 R9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")b2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case cM:return Y4(r.children,a,o,s);case Fwe:l=8,a|=8;break;case e0e:return t=kx(12,r,s,a|2),t.elementType=e0e,t.lanes=o,t;case t0e:return t=kx(13,r,s,a),t.elementType=t0e,t.lanes=o,t;case s0e:return t=kx(19,r,s,a),t.elementType=s0e,t.lanes=o,t;case mBe:return Tde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case uBe:l=10;break e;case hBe:l=9;break e;case zwe:l=11;break e;case Bwe:l=14;break e;case Jb:l=16,n=null;break e}throw Error(en(130,t==null?t:typeof t,""))}return s=kx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function Y4(t,s,r,n){return t=kx(7,t,n,s),t.lanes=r,t}function Tde(t,s,r,n){return t=kx(22,t,n,s),t.elementType=mBe,t.lanes=r,t.stateNode={isHidden:!1},t}function lxe(t,s,r){return t=kx(6,t,null,s),t.lanes=r,t}function cxe(t,s,r){return s=kx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Nxt(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=Ufe(0),this.expirationTimes=Ufe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ufe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function _2e(t,s,r,n,a,o,l,i,c){return t=new Nxt(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=kx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},n2e(o),t}function kxt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(oqe)}catch(t){console.error(t)}}oqe(),oBe.exports=Df;var vp=oBe.exports;const k2e=Do(vp);var lqe,UAe=vp;lqe=UAe.createRoot,UAe.hydrateRoot;const Axt=1,Ext=1e6;let dxe=0;function Pxt(){return dxe=(dxe+1)%Number.MAX_SAFE_INTEGER,dxe.toString()}const uxe=new Map,VAe=t=>{if(uxe.has(t))return;const s=setTimeout(()=>{uxe.delete(t),cL({type:"REMOVE_TOAST",toastId:t})},Ext);uxe.set(t,s)},Ixt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Axt)};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?VAe(r):t.toasts.forEach(n=>{VAe(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)}}},F9=[];let z9={toasts:[]};function cL(t){z9=Ixt(z9,t),F9.forEach(s=>{s(z9)})}function kn({...t}){const s=Pxt(),r=a=>cL({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>cL({type:"DISMISS_TOAST",toastId:s});return cL({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ra(){const[t,s]=k.useState(z9);return k.useEffect(()=>(F9.push(s),()=>{const r=F9.indexOf(s);r>-1&&F9.splice(r,1)}),[t]),{...t,toast:kn,dismiss:r=>cL({type:"DISMISS_TOAST",toastId:r})}}function Or(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 HAe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function I1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=HAe(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 od(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:y,..._}=f,w=((N=g==null?void 0:g[t])==null?void 0:N[c])||i,j=k.useMemo(()=>_,Object.values(_));return e.jsx(w.Provider,{value:j,children:y})};u.displayName=o+"Provider";function m(f,g){var w;const y=((w=g==null?void 0:g[t])==null?void 0:w[c])||i,_=k.useContext(y);if(_)return _;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,m]}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,Dxt(a,...s)]}function Dxt(...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 fw(t){const s=Oxt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),c=i.find(Rxt);if(c){const u=c.props.children,m=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,m):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var S2e=fw("Slot");function Oxt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=zxt(a),i=Fxt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?I1(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 cqe=Symbol("radix.slottable");function dqe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=cqe,s}function Rxt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cqe}function Fxt(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 zxt(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 LO(t){const s=t+"CollectionProvider",[r,n]=od(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:j,children:N}=w,S=mt.useRef(null),M=mt.useRef(new Map).current;return e.jsx(a,{scope:j,itemMap:M,collectionRef:S,children:N})};l.displayName=s;const i=t+"CollectionSlot",c=fw(i),u=mt.forwardRef((w,j)=>{const{scope:N,children:S}=w,M=o(i,N),I=Ka(j,M.collectionRef);return e.jsx(c,{ref:I,children:S})});u.displayName=i;const m=t+"CollectionItemSlot",f="data-radix-collection-item",g=fw(m),y=mt.forwardRef((w,j)=>{const{scope:N,children:S,...M}=w,I=mt.useRef(null),P=Ka(j,I),O=o(m,N);return mt.useEffect(()=>(O.itemMap.set(I,{ref:I,...M}),()=>void O.itemMap.delete(I))),e.jsx(g,{[f]:"",ref:P,children:S})});y.displayName=m;function _(w){const j=o(t+"CollectionConsumer",w);return mt.useCallback(()=>{const S=j.collectionRef.current;if(!S)return[];const M=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(j.itemMap.values()).sort((O,q)=>M.indexOf(O.ref.current)-M.indexOf(q.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:l,Slot:u,ItemSlot:y},_,n]}var Bxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cn=Bxt.reduce((t,s)=>{const r=fw(`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 C2e(t,s){t&&vp.flushSync(()=>t.dispatchEvent(s))}function _d(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 $xt(t,s=globalThis==null?void 0:globalThis.document){const r=_d(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 qxt="DismissableLayer",H0e="dismissableLayer.update",Uxt="dismissableLayer.pointerDownOutside",Vxt="dismissableLayer.focusOutside",GAe,uqe=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ew=k.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=k.useContext(uqe),[m,f]=k.useState(null),g=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=k.useState({}),_=Ka(s,q=>f(q)),w=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=w.indexOf(j),S=m?w.indexOf(m):-1,M=u.layersWithOutsidePointerEventsDisabled.size>0,I=S>=N,P=Gxt(q=>{const $=q.target,z=[...u.branches].some(V=>V.contains($));!I||z||(a==null||a(q),l==null||l(q),q.defaultPrevented||i==null||i())},g),O=Wxt(q=>{const $=q.target;[...u.branches].some(V=>V.contains($))||(o==null||o(q),l==null||l(q),q.defaultPrevented||i==null||i())},g);return $xt(q=>{S===u.layers.size-1&&(n==null||n(q),!q.defaultPrevented&&i&&(q.preventDefault(),i()))},g),k.useEffect(()=>{if(m)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(GAe=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(m)),u.layers.add(m),WAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=GAe)}},[m,g,r,u]),k.useEffect(()=>()=>{m&&(u.layers.delete(m),u.layersWithOutsidePointerEventsDisabled.delete(m),WAe())},[m,u]),k.useEffect(()=>{const q=()=>y({});return document.addEventListener(H0e,q),()=>document.removeEventListener(H0e,q)},[]),e.jsx(cn.div,{...c,ref:_,style:{pointerEvents:M?I?"auto":"none":void 0,...t.style},onFocusCapture:Or(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Or(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Or(t.onPointerDownCapture,P.onPointerDownCapture)})});Ew.displayName=qxt;var Hxt="DismissableLayerBranch",hqe=k.forwardRef((t,s)=>{const r=k.useContext(uqe),n=k.useRef(null),a=Ka(s,n);return k.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(cn.div,{...t,ref:a})});hqe.displayName=Hxt;function Gxt(t,s=globalThis==null?void 0:globalThis.document){const r=_d(t),n=k.useRef(!1),a=k.useRef(()=>{});return k.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){mqe(Uxt,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 Wxt(t,s=globalThis==null?void 0:globalThis.document){const r=_d(t),n=k.useRef(!1);return k.useEffect(()=>{const a=o=>{o.target&&!n.current&&mqe(Vxt,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 WAe(){const t=new CustomEvent(H0e);document.dispatchEvent(t)}function mqe(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?C2e(a,o):a.dispatchEvent(o)}var Kxt=Ew,Zxt=hqe,kd=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},Yxt="Portal",eE=k.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=k.useState(!1);kd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?k2e.createPortal(e.jsx(cn.div,{...n,ref:s}),l):null});eE.displayName=Yxt;function Qxt(t,s){return k.useReducer((r,n)=>s[r][n]??r,t)}var qd=t=>{const{present:s,children:r}=t,n=Xxt(s),a=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),o=Ka(n.ref,Jxt(a));return typeof r=="function"||n.isPresent?k.cloneElement(a,{ref:o}):null};qd.displayName="Presence";function Xxt(t){const[s,r]=k.useState(),n=k.useRef(null),a=k.useRef(t),o=k.useRef("none"),l=t?"mounted":"unmounted",[i,c]=Qxt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=J7(n.current);o.current=i==="mounted"?u:"none"},[i]),kd(()=>{const u=n.current,m=a.current;if(m!==t){const g=o.current,y=J7(u);t?c("MOUNT"):y==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(m&&g!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),kd(()=>{if(s){let u;const m=s.ownerDocument.defaultView??window,f=y=>{const w=J7(n.current).includes(y.animationName);if(y.target===s&&w&&(c("ANIMATION_END"),!a.current)){const j=s.style.animationFillMode;s.style.animationFillMode="forwards",u=m.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=j)})}},g=y=>{y.target===s&&(o.current=J7(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{m.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 J7(t){return(t==null?void 0:t.animationName)||"none"}function Jxt(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 egt=Lwe[" useInsertionEffect ".trim().toString()]||kd;function lh({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=tgt({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const m=k.useRef(t!==void 0);k.useEffect(()=>{const f=m.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.`),m.current=i},[i,n])}const u=k.useCallback(m=>{var f;if(i){const g=sgt(m)?m(t):m;g!==t&&((f=l.current)==null||f.call(l,g))}else o(m)},[i,t,o,l]);return[c,u]}function tgt({defaultProp:t,onChange:s}){const[r,n]=k.useState(t),a=k.useRef(r),o=k.useRef(s);return egt(()=>{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 sgt(t){return typeof t=="function"}var pqe=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"}),rgt="VisuallyHidden",Lde=k.forwardRef((t,s)=>e.jsx(cn.span,{...t,ref:s,style:{...pqe,...t.style}}));Lde.displayName=rgt;var ngt=Lde,M2e="ToastProvider",[T2e,agt,igt]=LO("Toast"),[fqe]=od("Toast",[igt]),[ogt,Dde]=fqe(M2e),xqe=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,m]=k.useState(0),f=k.useRef(!1),g=k.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${M2e}\`. Expected non-empty \`string\`.`),e.jsx(T2e.Provider,{scope:s,children:e.jsx(ogt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:k.useCallback(()=>m(y=>y+1),[]),onToastRemove:k.useCallback(()=>m(y=>y-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:g,children:l})})};xqe.displayName=M2e;var gqe="ToastViewport",lgt=["F8"],G0e="toast.viewportPause",W0e="toast.viewportResume",yqe=k.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=lgt,label:a="Notifications ({hotkey})",...o}=t,l=Dde(gqe,r),i=agt(r),c=k.useRef(null),u=k.useRef(null),m=k.useRef(null),f=k.useRef(null),g=Ka(s,f,l.onViewportChange),y=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=l.toastCount>0;k.useEffect(()=>{const j=N=>{var M;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((M=f.current)==null||M.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]),k.useEffect(()=>{const j=c.current,N=f.current;if(_&&j&&N){const S=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(G0e);N.dispatchEvent(O),l.isClosePausedRef.current=!0}},M=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(W0e);N.dispatchEvent(O),l.isClosePausedRef.current=!1}},I=O=>{!j.contains(O.relatedTarget)&&M()},P=()=>{j.contains(document.activeElement)||M()};return j.addEventListener("focusin",S),j.addEventListener("focusout",I),j.addEventListener("pointermove",S),j.addEventListener("pointerleave",P),window.addEventListener("blur",S),window.addEventListener("focus",M),()=>{j.removeEventListener("focusin",S),j.removeEventListener("focusout",I),j.removeEventListener("pointermove",S),j.removeEventListener("pointerleave",P),window.removeEventListener("blur",S),window.removeEventListener("focus",M)}}},[_,l.isClosePausedRef]);const w=k.useCallback(({tabbingDirection:j})=>{const S=i().map(M=>{const I=M.ref.current,P=[I,..._gt(I)];return j==="forwards"?P:P.reverse()});return(j==="forwards"?S.reverse():S).flat()},[i]);return k.useEffect(()=>{const j=f.current;if(j){const N=S=>{var P,O,q;const M=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!M){const $=document.activeElement,z=S.shiftKey;if(S.target===j&&z){(P=u.current)==null||P.focus();return}const Y=w({tabbingDirection:z?"backwards":"forwards"}),J=Y.findIndex(Q=>Q===$);hxe(Y.slice(J+1))?S.preventDefault():z?(O=u.current)==null||O.focus():(q=m.current)==null||q.focus()}};return j.addEventListener("keydown",N),()=>j.removeEventListener("keydown",N)}},[i,w]),e.jsxs(Zxt,{ref:c,role:"region","aria-label":a.replace("{hotkey}",y),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&e.jsx(K0e,{ref:u,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"forwards"});hxe(j)}}),e.jsx(T2e.Slot,{scope:r,children:e.jsx(cn.ol,{tabIndex:-1,...o,ref:g})}),_&&e.jsx(K0e,{ref:m,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"backwards"});hxe(j)}})]})});yqe.displayName=gqe;var vqe="ToastFocusProxy",K0e=k.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Dde(vqe,r);return e.jsx(Lde,{"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()}})});K0e.displayName=vqe;var DO="Toast",cgt="toast.swipeStart",dgt="toast.swipeMove",ugt="toast.swipeCancel",hgt="toast.swipeEnd",bqe=k.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=lh({prop:n,defaultProp:a??!0,onChange:o,caller:DO});return e.jsx(qd,{present:r||i,children:e.jsx(fgt,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:_d(t.onPause),onResume:_d(t.onResume),onSwipeStart:Or(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Or(t.onSwipeMove,u=>{const{x:m,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${m}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Or(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:Or(t.onSwipeEnd,u=>{const{x:m,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",`${m}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});bqe.displayName=DO;var[mgt,pgt]=fqe(DO,{onClose(){}}),fgt=k.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:c,onResume:u,onSwipeStart:m,onSwipeMove:f,onSwipeCancel:g,onSwipeEnd:y,..._}=t,w=Dde(DO,r),[j,N]=k.useState(null),S=Ka(s,Q=>N(Q)),M=k.useRef(null),I=k.useRef(null),P=a||w.duration,O=k.useRef(0),q=k.useRef(P),$=k.useRef(0),{onToastAdd:z,onToastRemove:V}=w,X=_d(()=>{var ce;(j==null?void 0:j.contains(document.activeElement))&&((ce=w.viewport)==null||ce.focus()),l()}),Y=k.useCallback(Q=>{!Q||Q===1/0||(window.clearTimeout($.current),O.current=new Date().getTime(),$.current=window.setTimeout(X,Q))},[X]);k.useEffect(()=>{const Q=w.viewport;if(Q){const ce=()=>{Y(q.current),u==null||u()},ne=()=>{const re=new Date().getTime()-O.current;q.current=q.current-re,window.clearTimeout($.current),c==null||c()};return Q.addEventListener(G0e,ne),Q.addEventListener(W0e,ce),()=>{Q.removeEventListener(G0e,ne),Q.removeEventListener(W0e,ce)}}},[w.viewport,P,c,u,Y]),k.useEffect(()=>{o&&!w.isClosePausedRef.current&&Y(P)},[o,P,w.isClosePausedRef,Y]),k.useEffect(()=>(z(),()=>V()),[z,V]);const J=k.useMemo(()=>j?Cqe(j):null,[j]);return w.viewport?e.jsxs(e.Fragment,{children:[J&&e.jsx(xgt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:J}),e.jsx(mgt,{scope:r,onClose:X,children:vp.createPortal(e.jsx(T2e.ItemSlot,{scope:r,children:e.jsx(Kxt,{asChild:!0,onEscapeKeyDown:Or(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||X(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(cn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,..._,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Or(t.onKeyDown,Q=>{Q.key==="Escape"&&(i==null||i(Q.nativeEvent),Q.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,X()))}),onPointerDown:Or(t.onPointerDown,Q=>{Q.button===0&&(M.current={x:Q.clientX,y:Q.clientY})}),onPointerMove:Or(t.onPointerMove,Q=>{if(!M.current)return;const ce=Q.clientX-M.current.x,ne=Q.clientY-M.current.y,re=!!I.current,oe=["left","right"].includes(w.swipeDirection),he=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,xe=oe?he(0,ce):0,ue=oe?0:he(0,ne),ge=Q.pointerType==="touch"?10:2,_e={x:xe,y:ue},Be={originalEvent:Q,delta:_e};re?(I.current=_e,ez(dgt,f,Be,{discrete:!1})):KAe(_e,w.swipeDirection,ge)?(I.current=_e,ez(cgt,m,Be,{discrete:!1}),Q.target.setPointerCapture(Q.pointerId)):(Math.abs(ce)>ge||Math.abs(ne)>ge)&&(M.current=null)}),onPointerUp:Or(t.onPointerUp,Q=>{const ce=I.current,ne=Q.target;if(ne.hasPointerCapture(Q.pointerId)&&ne.releasePointerCapture(Q.pointerId),I.current=null,M.current=null,ce){const re=Q.currentTarget,oe={originalEvent:Q,delta:ce};KAe(ce,w.swipeDirection,w.swipeThreshold)?ez(hgt,y,oe,{discrete:!0}):ez(ugt,g,oe,{discrete:!0}),re.addEventListener("click",he=>he.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),xgt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Dde(DO,s),[o,l]=k.useState(!1),[i,c]=k.useState(!1);return vgt(()=>l(!0)),k.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(eE,{asChild:!0,children:e.jsx(Lde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},ggt="ToastTitle",_qe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(cn.div,{...n,ref:s})});_qe.displayName=ggt;var ygt="ToastDescription",wqe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(cn.div,{...n,ref:s})});wqe.displayName=ygt;var jqe="ToastAction",Nqe=k.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(Sqe,{altText:r,asChild:!0,children:e.jsx(A2e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${jqe}\`. Expected non-empty \`string\`.`),null)});Nqe.displayName=jqe;var kqe="ToastClose",A2e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=pgt(kqe,r);return e.jsx(Sqe,{asChild:!0,children:e.jsx(cn.button,{type:"button",...n,ref:s,onClick:Or(t.onClick,a.onClose)})})});A2e.displayName=kqe;var Sqe=k.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(cn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function Cqe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),bgt(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(...Cqe(n))}}),s}function ez(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?C2e(a,o):a.dispatchEvent(o)}var KAe=(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 vgt(t=()=>{}){const s=_d(t);kd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function bgt(t){return t.nodeType===t.ELEMENT_NODE}function _gt(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 hxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var wgt=xqe,Mqe=yqe,Tqe=bqe,Aqe=_qe,Eqe=wqe,Pqe=Nqe,Iqe=A2e;function Lqe(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,YAe=Hi,S3=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return YAe(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 m=r==null?void 0:r[u],f=o==null?void 0:o[u];if(m===null)return null;const g=ZAe(m)||ZAe(f);return a[u][g]}),i=r&&Object.entries(r).reduce((u,m)=>{let[f,g]=m;return g===void 0||(u[f]=g),u},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,m)=>{let{class:f,className:g,...y}=m;return Object.entries(y).every(_=>{let[w,j]=_;return Array.isArray(j)?j.includes({...o,...i}[w]):{...o,...i}[w]===j})?[...u,f,g]:u},[]);return YAe(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 jgt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Dqe=(...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 Ngt={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 Oqe=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,...Ngt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:Dqe("lucide",a),...i},[...l.map(([u,m])=>k.createElement(u,m)),...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(Oqe,{ref:o,iconNode:s,className:Dqe(`lucide-${jgt(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 B9=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 $9=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 q9=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 U9=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 Mh=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 V9=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 H9=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 X2=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 J2=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 G9=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 ej=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 W9=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 K9=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 Z9=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 Y9=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 Q9=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 Q4=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 X9=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 J9=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 eB=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 tB=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 sB=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 rB=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 nB=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 aB=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 iB=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 oB=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 lB=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 X4=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 J4=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 cB=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 dB=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 uB=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 hB=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 mB=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 pB=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 fB=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 xB=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 gB=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 yB=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 vB=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 bB=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 _B=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 wB=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 jB=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 NB=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 kB=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 SB=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 CB=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 MB=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 TB=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 dL=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 AB=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 uL=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 EB=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 zM=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 PB=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 IB=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 LB=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 DB=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 OB=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 RB=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 FB=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 zB=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 BB=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 $B=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 qB=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 tj=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 UB=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 VB=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 HB=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 hL=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 GB=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 WB=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 KB=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 sj=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 rj=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 Yh=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 ZB=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 YB=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 QB=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 Ga=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 XB=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 l1=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 JB=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 ba=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 e$=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 t$=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 nj=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 wd=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 s$=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 r$=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 n$=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 aj=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 mL=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 a$=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 i$=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 ij=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 Tu=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 o$=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 l$=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 c$=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 d$=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 u$=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 h$=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=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 oj=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 p$=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 f$=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 x$=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 g$=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 lj=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 y$=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 v$=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 b$=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 _$=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 w$=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 j$=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 N$=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 k$=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 S$=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 C$=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 M$=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 T$=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 A$=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 E$=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 P$=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 pL=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 I$=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 L$=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 D$=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 O$=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 R$=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 au=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 F$=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 z$=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 B$=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 $$=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 q$=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 U$=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 V$=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 H$=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 G$=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 eS=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 W$=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 Th=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 K$=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 Z$=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 Y$=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 Q$=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 X$=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 J$=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 c1=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 eq=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 tq=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 Fm=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 cj=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 dj=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 sq=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 rq=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 nq=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 aq=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 iq=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 oq=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 lq=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 cq=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 dq=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 uq=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 hq=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 mq=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 pq=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 fq=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 xq=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 gq=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 tS=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 yq=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 vq=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 bq=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 _q=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 wq=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 jq=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 Nq=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 uj=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 kq=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 Sq=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 Cq=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 Mq=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 Tq=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 Aq=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 Eq=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 Pq=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 Iq=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 Lq=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 Ah=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 Dq=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 Oq=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 Rq=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 Fq=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 zq=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 Bq=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 $q=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 qq=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 Uq=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 Vq=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 fL=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 Hq=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 Ax=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 Gq=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 Wq=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 Kq=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 BM=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 Zq=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 Yq=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 hj=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 Qq=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 Xq=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 Jq=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 xL=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 eU=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 tU=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 sU=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 rU=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 sh=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 nU=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 aU=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 iU=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 oU=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 lU=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ta=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sS=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 cU=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 dU=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 uU=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 hU=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 mU=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 Eh=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 rS=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 pU=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 fU=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 xU=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 gU=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 gL=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 $M=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 yU=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 Fd=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 vU=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 bU=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 _U=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 wU=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 yL=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 jU=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 G_=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 NU=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 kU=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 SU=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 CU=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 MU=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 fn=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 TU=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 gf=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 AU=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 EU=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 PU=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 IU=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 LU=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 mj=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 DU=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 OU=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 qM=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 RU=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 FU=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 zU=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 BU=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 $U=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 qU=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 UU=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 VU=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 HU=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 GU=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 pj=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 fj=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 WU=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 KU=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 ZU=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 xj=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 gj=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 yj=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 YU=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 vj=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 QU=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 co=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 XU=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 bj=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 JU=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 eV=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 _j=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 wj=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 tV=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 jj=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 Nj=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 kj=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 sV=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 vL=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 ua=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 rV=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 nV=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 Ji=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 aV=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 iV=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 tl=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 Sp=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 oV=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 lV=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 cV=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 dV=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 uV=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 hV=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 mV=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 Ex=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 pV=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 fV=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 xV=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 gV=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 yV=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 ul=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 Sj=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 Cj=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 Mj=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 Tj=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 Aj=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 Ej=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 Pj=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 Ij=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 wi=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 Lj=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 Dj=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 Oj=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 Rj=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 vV=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 Fj=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 bV=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 _V=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 wV=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 jV=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 NV=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 kV=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 SV=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 zj=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 Uv=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 Bj=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 CV=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 $j=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 qj=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 Uj=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 Vj=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 fp=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 Hj=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 Gj=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 Wj=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 MV=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 Kj=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 Zj=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 Yj=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 Nc=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 jd=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 TV=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 AV=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 EV=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 UM=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 PV=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 W_=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 IV=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 LV=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 Qj=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 Xj=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 DV=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 OV=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 RV=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 FV=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 zV=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 BV=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 $V=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 qV=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 UV=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 VV=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 HV=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 GV=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 WV=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 KV=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 ZV=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 YV=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 QV=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 XV=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 JV=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 mn=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 eH=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 tH=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 Jj=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 sH=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 rH=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 nH=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 aH=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 iH=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 oH=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 lH=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 cH=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 dH=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 uH=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 hH=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 mH=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 eN=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 pH=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 fH=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 s1=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 xH=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 tN=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 nS=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 gH=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 yH=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 aS=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 vH=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 bL=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 sN=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 rN=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 bH=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 _H=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 wH=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 d1=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 jH=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 NH=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 kH=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 SH=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 nN=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 iS=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 MH=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 TH=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 AH=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 EH=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 IH=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 LH=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 DH=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 OH=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 yi=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 RH=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 FH=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 zH=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 BH=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 $H=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 qH=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 UH=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 VH=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 HH=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 GH=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 WH=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 KH=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 Px=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 ZH=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 YH=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 QH=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 XH=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 zm=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 JH=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 eG=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 tG=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 sG=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 rG=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 nG=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 aG=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 _L=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 iG=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 oG=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 lG=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 cG=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 aN=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 dG=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 uG=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 hG=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 mG=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 pG=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 fG=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 xG=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 gG=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 yG=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 vG=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 bG=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 _G=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 wG=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 jG=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 NG=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 kG=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 SG=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 CG=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 MG=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 ml=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 TG=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 AG=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 u1=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 EG=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 vi=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 PG=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 IG=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 LG=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 DG=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 OG=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 ey=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 RG=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 FG=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 zG=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 BG=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 $G=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 qG=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 iN=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 UG=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 VG=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 HG=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 VM=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 vx=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 bx=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 GG=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 WG=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 KG=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 ZG=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 YG=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 QG=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 wL=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rn=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=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 Cp=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 Tn=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 Au=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 JG=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 eW=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 tW=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 sW=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 rW=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 nW=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 aW=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 iW=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 oW=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 lW=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 oN=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 cW=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 dW=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 uW=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 lN=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 cN=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 dN=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 uN=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 hW=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 mW=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 pW=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 fW=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 xW=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 hN=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 gW=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 yW=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 oS=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 vW=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 K_=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 bW=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 _W=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 wW=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 jW=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 NW=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 kW=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 SW=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 CW=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 MW=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 TW=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 AW=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 mN=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 pN=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 EW=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 PW=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 IW=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 LW=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 DW=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 OW=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 RW=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 h1=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 jL=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 FW=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 zW=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 wn=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 BW=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 $W=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 qW=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 UW=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 VW=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 HW=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 GW=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 WW=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 KW=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 ZW=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 YW=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 HM=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 QW=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 _u=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 XW=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 ty=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 JW=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 eK=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 tK=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 sK=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 rK=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 nK=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 aK=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 iK=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 m1=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 oK=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 rh=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 lK=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 cK=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 dK=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 Z_=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 uK=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 hK=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 NL=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 mK=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 pK=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 Zg=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 fK=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 xK=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 gK=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 yK=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 vK=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 bK=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 _K=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 wK=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 jK=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 fN=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 NK=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 kK=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 SK=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 CK=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 MK=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 TK=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 AK=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 EK=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 PK=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 IK=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 LK=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 Bm=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 DK=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 xN=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 OK=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 RK=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 FK=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 zK=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 BK=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 $K=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 qK=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 UK=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 VK=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 HK=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 GK=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 WK=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 KK=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 ZK=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 YK=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 QK=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 XK=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 JK=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 eZ=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 tZ=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 sZ=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 rZ=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 nZ=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 aZ=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 iZ=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 oZ=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 lZ=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 cZ=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 dZ=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 lS=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 bo=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 uZ=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 hZ=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 gN=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 mZ=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 pZ=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 fZ=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 xZ=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 gZ=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 yZ=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 vZ=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 bZ=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 _Z=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 wZ=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 jZ=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 NZ=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 kZ=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 SZ=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 CZ=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 MZ=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 TZ=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 Nd=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 AZ=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 EZ=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 Qh=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 PZ=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 IZ=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 yN=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 LZ=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 vN=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 dx=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 DZ=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 Eu=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 OZ=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 RZ=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 FZ=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 zZ=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 BZ=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 $Z=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 qZ=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 bN=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 UZ=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 VZ=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 kL=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 SL=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 HZ=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 GZ=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 CL=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 WZ=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 Y_=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 KZ=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 ZZ=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 GM=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 WM=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 ML=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 YZ=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 QZ=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 XZ=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 JZ=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 eY=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 tY=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 sY=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 rY=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 nY=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 aY=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 iY=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 Ja=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 oY=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 lY=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 cY=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 KM=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 dY=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 uY=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 hY=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 mY=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 pY=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 fY=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 xY=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 xn=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 _N=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 wN=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 gY=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 yY=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 vY=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 bY=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 _Y=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 p1=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 wY=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 jY=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 bl=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 NY=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 kY=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 SY=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 jN=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 NN=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 CY=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 MY=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 cS=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 TY=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 Pu=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 dS=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 AY=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 EY=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 PY=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 IY=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 x0=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 uS=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 LY=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 Mp=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 DY=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 OY=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 RY=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 FY=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 zY=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 BY=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 $Y=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 qY=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 UY=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 VY=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 HY=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 GY=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 WY=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 kN=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 KY=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 ZY=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 YY=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 QY=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 XY=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 JY=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 ZM=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 hS=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 Tp=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 eQ=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 tQ=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 sQ=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 mS=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 rQ=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 nQ=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 aQ=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 iQ=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 oQ=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 YM=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 QM=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 lQ=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 cQ=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 dQ=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 pl=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 Uo=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 Ap=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 uQ=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 hQ=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 mQ=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 pQ=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 fQ=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 xQ=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 gQ=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 g0=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 yQ=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 vQ=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 bQ=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 _Q=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 wQ=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 jQ=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 NQ=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 nh=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 ys=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 kQ=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 SQ=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 CQ=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 MQ=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 XM=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 SN=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 TQ=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 CN=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 zd=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 pS=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 fS=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 AQ=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 EQ=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 PQ=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 IQ=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 LQ=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 DQ=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 OQ=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 TL=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 RQ=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 FQ=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 zQ=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 AL=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 rr=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 BQ=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 $Q=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 qQ=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 UQ=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 VQ=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 HQ=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 GQ=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 WQ=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 KQ=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 ZQ=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 YQ=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 QQ=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 aa=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 XQ=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 y0=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 JQ=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 eX=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 xS=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 f1=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 tX=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 Ph=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 sX=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 rX=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 gS=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 nX=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 aX=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 iX=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 JM=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 oX=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 lX=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 cX=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 EL=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 dX=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 uX=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 hX=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 Uc=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 mX=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 pX=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 fX=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 xX=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 gX=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 yX=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 PL=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 vX=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 eT=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 IL=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 bX=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 _X=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 wX=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 jX=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 NX=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 Ki=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 kX=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 SX=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 MN=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 LL=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 CX=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 MX=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 TX=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 AX=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 EX=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 PX=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 IX=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 LX=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 v0=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 DX=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 OX=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 RX=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 FX=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 zX=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 BX=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 $X=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 qX=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 UX=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 VX=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 yS=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 HX=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 vS=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 GX=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 WX=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 KX=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 DL=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 ZX=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 YX=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 QX=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 $m=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 kh=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 XX=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 TN=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 JX=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 eJ=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 tJ=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 sJ=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 rJ=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 nJ=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 aJ=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 iJ=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 oJ=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 lJ=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 cJ=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 dJ=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 uJ=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 hJ=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 mJ=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 pJ=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 fJ=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 xJ=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 gJ=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 yJ=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 OL=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 vJ=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 x1=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 bJ=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 _J=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 wJ=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 jJ=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 NJ=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 kJ=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 SJ=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 CJ=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 MJ=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 Vv=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 TJ=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 AN=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 EN=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 AJ=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 EJ=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 PJ=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 IJ=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 LJ=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 DJ=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 OJ=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 RJ=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 FJ=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 zJ=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 BJ=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 $J=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 Al=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 qJ=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 UJ=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 PN=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 VJ=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 $l=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 HJ=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 IN=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 GJ=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 WJ=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 LN=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 DN=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 ON=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 RN=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 KJ=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 FN=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 ZJ=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 YJ=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 QJ=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 zN=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 XJ=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 JJ=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 eee=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 tee=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 Hv=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 bS=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 see=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 ree=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 iu=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 Ih=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 nee=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 aee=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 Gv=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 iee=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 X_=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 r0=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 oee=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 lee=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 cee=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 Pa=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 dee=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 _S=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 uee=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 hee=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 mee=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 pee=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 fee=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 xee=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 gee=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 yee=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 Nn=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 vee=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 bee=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 _ee=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 wee=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 jee=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 Nee=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 kee=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 See=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 Cee=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 Mee=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 Tee=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 RL=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 J_=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 Aee=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 Eee=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 Pee=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 Iee=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 Lee=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 sl=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 Dee=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 BN=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 FL=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 qs=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 Oee=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 Ree=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 Fee=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 zee=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 Bee=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 $ee=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 qee=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 Uee=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 Vee=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 zL=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 sy=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 Hee=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 BL=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 Gee=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 Wee=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 Kee=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 Zee=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b0=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g1=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 Yee=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 Qee=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 Xee=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 Jee=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 ete=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 tte=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 y1=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 ste=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 rte=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 nte=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 ate=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 ite=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 ote=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 lte=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 cte=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 dte=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 ute=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 hte=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 mte=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 pte=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 fte=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 $N=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 xte=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 gte=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 yte=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 vte=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 bte=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 wS=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 _te=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 tT=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 wte=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 zo=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 jte=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 Nte=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 kte=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 Ste=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 Cte=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 $L=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 Mte=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 Tte=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 Ate=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 qL=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 Ete=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 Pte=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 _0=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 Ite=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 Lte=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 qN=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 Dte=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 w0=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 Ote=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 UL=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 Rte=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 Fte=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 zte=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 UN=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 VN=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 Bte=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 $te=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 Ix=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 qte=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 Ute=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 Vte=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 Hte=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 Gte=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 Wte=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 Kte=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 Zte=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 Vc=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 HN=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 VL=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 Yte=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 Qte=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 Xte=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 Jte=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 ese=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 tse=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 sse=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 rse=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 nse=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 ase=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 ise=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 ose=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 lse=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 cse=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 dse=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 use=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 hse=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 mse=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 pse=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 HL=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 sn=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 fse=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 GN=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 xse=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 Fn=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 gse=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 yse=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 vse=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 bse=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 _se=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 wse=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 GL=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 el=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 jse=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 nd=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 WL=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 Nse=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 kse=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 Sse=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 Cse=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 jS=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 Mse=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 Tse=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 Ase=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 NS=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 Ese=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 Pse=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 WN=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 ou=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 Ise=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 Lse=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 Dse=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 j0=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 Ose=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 bp=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 Rse=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 Fse=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 zse=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 Bse=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 kS=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 $se=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 qse=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 Use=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 Vse=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 Hse=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 Gse=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 Wse=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 Kse=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 Zse=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 Yse=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 Qse=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 Xse=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 Jse=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 ere=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 tre=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 sre=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 v1=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 KN=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 rre=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 nre=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 N0=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 are=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 ire=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 ore=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 l0=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 lre=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 cre=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 dre=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 ure=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 hre=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 nn=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 mre=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 pre=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 fre=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 xre=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 gre=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 yre=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 vre=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 SS=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 ZN=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 YN=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 QN=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 XN=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 JN=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 ek=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 tk=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 sk=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 rk=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 nk=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 ak=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 ik=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 ok=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 lk=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 ck=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 Wy=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 Wv=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 dk=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 uk=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 hk=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 mk=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 pk=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 fk=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 bre=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 _re=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 xk=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 gk=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 yk=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 vk=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 bk=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 _k=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 wk=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 jk=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 Nk=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 kk=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 Sk=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 Ck=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 Mk=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 Tk=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 Ak=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 md=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 Ek=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 Pk=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 Ik=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 Lk=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 Dk=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 Ok=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 wre=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 Rk=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 Fk=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 zk=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 Bk=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 $k=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 jre=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 Nre=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 qk=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 Uk=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 Vk=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 Hk=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 k0=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 kre=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 Sre=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 Cre=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 Mre=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 Tre=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 ea=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 Are=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 Ere=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 Pre=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 Ire=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 Lre=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 sT=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 Dre=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 Ore=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 KL=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 Rre=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 Fre=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 zre=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 Bre=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 $re=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 b1=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 qre=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 Ure=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 Vre=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 Hre=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 Gre=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 Wre=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 Kre=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 Zre=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 Yre=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 rT=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 Qre=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 Xre=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 Jre=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 ene=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 tne=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 sne=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 nT=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 rne=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 nne=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 ane=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 Lh=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 ine=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 one=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 lne=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 cne=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 dne=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 une=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 hne=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 Xh=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 mne=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 pne=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 fne=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 xne=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 Gk=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 gne=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 yne=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 vne=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 bne=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 _ne=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 wne=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 Wk=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 jne=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 Nne=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 kne=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 Sne=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 ZL=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 YL=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 ah=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 Cne=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 Mne=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 Tne=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 Ane=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 Ene=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 Pne=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 QL=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 Ine=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 Lne=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 Dne=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 One=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 Rne=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 Fne=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 zne=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 Bne=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 $ne=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 qne=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 Une=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 Vne=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 Hne=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 Gne=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 Wne=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 Kne=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 Zne=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 Yne=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 Qne=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 Kk=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 kr=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 Xne=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 Jne=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 Zk=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 S0=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 eae=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 tae=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 CS=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 sae=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 Bo=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 vd=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 rae=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 nae=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 _o=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 aT=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 aae=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 iae=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 Yk=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 oae=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 lae=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 cae=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 dae=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 uae=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 hae=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 mae=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 XL=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 pae=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 fae=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 MS=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 xae=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 gae=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 yae=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 Qk=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 vae=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 TS=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 bae=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 ci=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 _ae=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 ew=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 JL=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 e8=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 wae=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 El=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 Xk=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 Jk=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 e4=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 jae=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 t4=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 Nae=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 s4=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 r4=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 kae=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 Sae=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 Zi=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 n4=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 ur=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 a4=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 i4=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 Cae=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 iT=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 Mae=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 Tae=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 Aae=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 Eae=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 Pae=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 Iae=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 Lae=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 Dae=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 Oae=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 Rae=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 Fae=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 zae=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 Bae=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 $ae=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 qae=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 Uae=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 Vae=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 o4=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 t8=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 Hae=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 Kv=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 Gae=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 Wae=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 Kae=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 Zae=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 s8=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 Yae=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 Qae=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 Xae=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 Jae=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 eie=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 tie=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 sie=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 rie=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 nie=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 aie=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 iie=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 oie=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 lie=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 cie=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 die=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 uie=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 hie=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 mie=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 pie=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 fie=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 ry=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 Er=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 xie=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 gie=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 Jh=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 tw=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 oT=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 kgt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:B9,AArrowUp:$9,ALargeSmall:q9,Accessibility:U9,Activity:Mh,AirVent:V9,Airplay:H9,AlarmClock:W9,AlarmClockCheck:X2,AlarmClockMinus:J2,AlarmClockOff:G9,AlarmClockPlus:ej,AlarmSmoke:K9,Album:Z9,AlignCenter:Q4,AlignCenterHorizontal:Y9,AlignCenterVertical:Q9,AlignEndHorizontal:X9,AlignEndVertical:J9,AlignHorizontalDistributeCenter:eB,AlignHorizontalDistributeEnd:tB,AlignHorizontalDistributeStart:sB,AlignHorizontalJustifyCenter:rB,AlignHorizontalJustifyEnd:nB,AlignHorizontalJustifyStart:aB,AlignHorizontalSpaceAround:iB,AlignHorizontalSpaceBetween:oB,AlignJustify:lB,AlignLeft:X4,AlignRight:J4,AlignStartHorizontal:cB,AlignStartVertical:dB,AlignVerticalDistributeCenter:uB,AlignVerticalDistributeEnd:hB,AlignVerticalDistributeStart:mB,AlignVerticalJustifyCenter:pB,AlignVerticalJustifyEnd:fB,AlignVerticalJustifyStart:xB,AlignVerticalSpaceAround:gB,AlignVerticalSpaceBetween:yB,Ambulance:vB,Ampersand:bB,Ampersands:_B,Amphora:wB,Anchor:jB,Angry:NB,Annoyed:kB,Antenna:SB,Anvil:CB,Aperture:MB,AppWindow:dL,AppWindowMac:TB,Apple:AB,Archive:zM,ArchiveRestore:uL,ArchiveX:EB,Armchair:PB,ArrowBigDown:LB,ArrowBigDownDash:IB,ArrowBigLeft:OB,ArrowBigLeftDash:DB,ArrowBigRight:FB,ArrowBigRightDash:RB,ArrowBigUp:BB,ArrowBigUpDash:zB,ArrowDown:Yh,ArrowDown01:$B,ArrowDown10:qB,ArrowDownAZ:tj,ArrowDownFromLine:UB,ArrowDownLeft:VB,ArrowDownNarrowWide:HB,ArrowDownRight:hL,ArrowDownToDot:GB,ArrowDownToLine:WB,ArrowDownUp:KB,ArrowDownWideNarrow:sj,ArrowDownZA:rj,ArrowLeft:Ga,ArrowLeftFromLine:ZB,ArrowLeftRight:YB,ArrowLeftToLine:QB,ArrowRight:ba,ArrowRightFromLine:XB,ArrowRightLeft:l1,ArrowRightToLine:JB,ArrowUp:Tu,ArrowUp01:e$,ArrowUp10:t$,ArrowUpAZ:nj,ArrowUpDown:wd,ArrowUpFromDot:s$,ArrowUpFromLine:r$,ArrowUpLeft:n$,ArrowUpNarrowWide:aj,ArrowUpRight:mL,ArrowUpToLine:a$,ArrowUpWideNarrow:i$,ArrowUpZA:ij,ArrowsUpFromLine:o$,Asterisk:l$,AtSign:c$,Atom:d$,AudioLines:u$,AudioWaveform:h$,Award:rc,Axe:m$,Axis3d:oj,Baby:p$,Backpack:f$,Badge:E$,BadgeAlert:x$,BadgeCent:g$,BadgeCheck:lj,BadgeDollarSign:y$,BadgeEuro:v$,BadgeHelp:b$,BadgeIndianRupee:_$,BadgeInfo:w$,BadgeJapaneseYen:j$,BadgeMinus:N$,BadgePercent:k$,BadgePlus:S$,BadgePoundSterling:C$,BadgeRussianRuble:M$,BadgeSwissFranc:T$,BadgeX:A$,BaggageClaim:P$,Ban:pL,Banana:I$,Bandage:L$,Banknote:D$,Barcode:O$,Baseline:R$,Bath:au,Battery:U$,BatteryCharging:F$,BatteryFull:z$,BatteryLow:B$,BatteryMedium:$$,BatteryWarning:q$,Beaker:V$,Bean:G$,BeanOff:H$,Bed:Th,BedDouble:eS,BedSingle:W$,Beef:K$,Beer:Y$,BeerOff:Z$,Bell:Fm,BellDot:Q$,BellElectric:X$,BellMinus:J$,BellOff:c1,BellPlus:eq,BellRing:tq,BetweenHorizontalEnd:cj,BetweenHorizontalStart:dj,BetweenVerticalEnd:sq,BetweenVerticalStart:rq,BicepsFlexed:nq,Bike:aq,Binary:iq,Binoculars:oq,Biohazard:lq,Bird:cq,Bitcoin:dq,Blend:uq,Blinds:hq,Blocks:mq,Bluetooth:gq,BluetoothConnected:pq,BluetoothOff:fq,BluetoothSearching:xq,Bold:tS,Bolt:yq,Bomb:vq,Bone:bq,Book:qq,BookA:_q,BookAudio:wq,BookCheck:jq,BookCopy:Nq,BookDashed:uj,BookDown:kq,BookHeadphones:Sq,BookHeart:Cq,BookImage:Mq,BookKey:Tq,BookLock:Aq,BookMarked:Eq,BookMinus:Pq,BookOpen:Ah,BookOpenCheck:Iq,BookOpenText:Lq,BookPlus:Dq,BookText:Oq,BookType:Rq,BookUp:zq,BookUp2:Fq,BookUser:Bq,BookX:$q,Bookmark:Ax,BookmarkCheck:Uq,BookmarkMinus:Vq,BookmarkPlus:fL,BookmarkX:Hq,BoomBox:Gq,Bot:BM,BotMessageSquare:Wq,BotOff:Kq,Box:Zq,Boxes:Yq,Braces:hj,Brackets:Qq,Brain:xL,BrainCircuit:Xq,BrainCog:Jq,BrickWall:eU,Briefcase:sh,BriefcaseBusiness:tU,BriefcaseConveyorBelt:sU,BriefcaseMedical:rU,BringToFront:nU,Brush:aU,Bug:lU,BugOff:iU,BugPlay:oU,Building:sS,Building2:Ta,Bus:dU,BusFront:cU,Cable:hU,CableCar:uU,Cake:Eh,CakeSlice:mU,Calculator:rS,Calendar:fn,Calendar1:pU,CalendarArrowDown:fU,CalendarArrowUp:xU,CalendarCheck:gL,CalendarCheck2:gU,CalendarClock:$M,CalendarCog:yU,CalendarDays:Fd,CalendarFold:vU,CalendarHeart:bU,CalendarMinus:wU,CalendarMinus2:_U,CalendarOff:yL,CalendarPlus:G_,CalendarPlus2:jU,CalendarRange:NU,CalendarSearch:kU,CalendarSync:SU,CalendarX:MU,CalendarX2:CU,Camera:gf,CameraOff:TU,Candy:PU,CandyCane:AU,CandyOff:EU,Cannabis:IU,Captions:mj,CaptionsOff:LU,Car:qM,CarFront:DU,CarTaxiFront:OU,Caravan:RU,Carrot:FU,CaseLower:zU,CaseSensitive:BU,CaseUpper:$U,CassetteTape:qU,Cast:UU,Castle:VU,Cat:HU,Cctv:GU,ChartArea:pj,ChartBar:xj,ChartBarBig:fj,ChartBarDecreasing:WU,ChartBarIncreasing:KU,ChartBarStacked:ZU,ChartCandlestick:gj,ChartColumn:co,ChartColumnBig:yj,ChartColumnDecreasing:YU,ChartColumnIncreasing:vj,ChartColumnStacked:QU,ChartGantt:XU,ChartLine:bj,ChartNetwork:JU,ChartNoAxesColumn:wj,ChartNoAxesColumnDecreasing:eV,ChartNoAxesColumnIncreasing:_j,ChartNoAxesCombined:tV,ChartNoAxesGantt:jj,ChartPie:Nj,ChartScatter:kj,ChartSpline:sV,Check:ua,CheckCheck:vL,ChefHat:rV,Cherry:nV,ChevronDown:Ji,ChevronFirst:aV,ChevronLast:iV,ChevronLeft:tl,ChevronRight:da,ChevronUp:Sp,ChevronsDown:lV,ChevronsDownUp:oV,ChevronsLeft:uV,ChevronsLeftRight:dV,ChevronsLeftRightEllipsis:cV,ChevronsRight:mV,ChevronsRightLeft:hV,ChevronsUp:pV,ChevronsUpDown:Ex,Chrome:fV,Church:xV,Cigarette:yV,CigaretteOff:gV,Circle:jd,CircleAlert:ul,CircleArrowDown:Sj,CircleArrowLeft:Cj,CircleArrowOutDownLeft:Mj,CircleArrowOutDownRight:Tj,CircleArrowOutUpLeft:Aj,CircleArrowOutUpRight:Ej,CircleArrowRight:Pj,CircleArrowUp:Ij,CircleCheck:sa,CircleCheckBig:wi,CircleChevronDown:Lj,CircleChevronLeft:Dj,CircleChevronRight:Oj,CircleChevronUp:Rj,CircleDashed:vV,CircleDivide:Fj,CircleDollarSign:bV,CircleDot:wV,CircleDotDashed:_V,CircleEllipsis:jV,CircleEqual:NV,CircleFadingArrowUp:kV,CircleFadingPlus:SV,CircleGauge:zj,CircleHelp:Uv,CircleMinus:Bj,CircleOff:CV,CircleParking:qj,CircleParkingOff:$j,CirclePause:Uj,CirclePercent:Vj,CirclePlay:fp,CirclePlus:Hj,CirclePower:Gj,CircleSlash:MV,CircleSlash2:Wj,CircleStop:Kj,CircleUser:Yj,CircleUserRound:Zj,CircleX:Nc,CircuitBoard:TV,Citrus:AV,Clapperboard:EV,Clipboard:FV,ClipboardCheck:UM,ClipboardCopy:PV,ClipboardList:W_,ClipboardMinus:IV,ClipboardPaste:LV,ClipboardPen:Xj,ClipboardPenLine:Qj,ClipboardPlus:DV,ClipboardType:OV,ClipboardX:RV,Clock:mn,Clock1:zV,Clock10:BV,Clock11:$V,Clock12:qV,Clock2:UV,Clock3:VV,Clock4:HV,Clock5:GV,Clock6:WV,Clock7:KV,Clock8:ZV,Clock9:YV,ClockAlert:QV,ClockArrowDown:XV,ClockArrowUp:JV,Cloud:pH,CloudAlert:eH,CloudCog:tH,CloudDownload:Jj,CloudDrizzle:sH,CloudFog:rH,CloudHail:nH,CloudLightning:aH,CloudMoon:oH,CloudMoonRain:iH,CloudOff:lH,CloudRain:dH,CloudRainWind:cH,CloudSnow:uH,CloudSun:mH,CloudSunRain:hH,CloudUpload:eN,Cloudy:fH,Clover:s1,Club:xH,Code:nS,CodeXml:tN,Codepen:gH,Codesandbox:yH,Coffee:aS,Cog:vH,Coins:bL,Columns2:sN,Columns3:rN,Columns4:bH,Combine:_H,Command:wH,Compass:d1,Component:jH,Computer:NH,ConciergeBell:kH,Cone:SH,Construction:CH,Contact:iS,ContactRound:nN,Container:MH,Contrast:TH,Cookie:AH,CookingPot:EH,Copy:yi,CopyCheck:PH,CopyMinus:IH,CopyPlus:LH,CopySlash:DH,CopyX:OH,Copyleft:RH,Copyright:FH,CornerDownLeft:zH,CornerDownRight:BH,CornerLeftDown:$H,CornerLeftUp:qH,CornerRightDown:UH,CornerRightUp:VH,CornerUpLeft:HH,CornerUpRight:GH,Cpu:WH,CreativeCommons:KH,CreditCard:Px,Croissant:ZH,Crop:YH,Cross:QH,Crosshair:XH,Crown:zm,Cuboid:JH,CupSoda:eG,Currency:tG,Cylinder:sG,Dam:rG,Database:_L,DatabaseBackup:nG,DatabaseZap:aG,Delete:iG,Dessert:oG,Diameter:lG,Diamond:uG,DiamondMinus:cG,DiamondPercent:aN,DiamondPlus:dG,Dice1:hG,Dice2:mG,Dice3:pG,Dice4:fG,Dice5:xG,Dice6:gG,Dices:yG,Diff:vG,Disc:jG,Disc2:bG,Disc3:_G,DiscAlbum:wG,Divide:NG,Dna:SG,DnaOff:kG,Dock:CG,Dog:MG,DollarSign:ml,Donut:TG,DoorClosed:AG,DoorOpen:u1,Dot:EG,Download:vi,DraftingCompass:PG,Drama:IG,Dribbble:LG,Drill:DG,Droplet:OG,Droplets:ey,Drum:RG,Drumstick:FG,Dumbbell:zG,Ear:$G,EarOff:BG,Earth:iN,EarthLock:qG,Eclipse:UG,Egg:VM,EggFried:VG,EggOff:HG,Ellipsis:bx,EllipsisVertical:vx,Equal:KG,EqualApproximately:GG,EqualNot:WG,Eraser:ZG,EthernetPort:YG,Euro:QG,Expand:wL,ExternalLink:rn,Eye:Tn,EyeClosed:XG,EyeOff:Cp,Facebook:Au,Factory:JG,Fan:eW,FastForward:tW,Feather:sW,Fence:rW,FerrisWheel:nW,Figma:aW,File:HM,FileArchive:iW,FileAudio:lW,FileAudio2:oW,FileAxis3d:oN,FileBadge:dW,FileBadge2:cW,FileBox:uW,FileChartColumn:cN,FileChartColumnIncreasing:lN,FileChartLine:dN,FileChartPie:uN,FileCheck:mW,FileCheck2:hW,FileClock:pW,FileCode:xW,FileCode2:fW,FileCog:hN,FileDiff:gW,FileDigit:yW,FileDown:oS,FileHeart:vW,FileImage:K_,FileInput:bW,FileJson:wW,FileJson2:_W,FileKey:NW,FileKey2:jW,FileLock:SW,FileLock2:kW,FileMinus:MW,FileMinus2:CW,FileMusic:TW,FileOutput:AW,FilePen:pN,FilePenLine:mN,FilePlus:PW,FilePlus2:EW,FileQuestion:IW,FileScan:LW,FileSearch:OW,FileSearch2:DW,FileSliders:RW,FileSpreadsheet:h1,FileStack:jL,FileSymlink:FW,FileTerminal:zW,FileText:wn,FileType:$W,FileType2:BW,FileUp:qW,FileUser:UW,FileVideo:HW,FileVideo2:VW,FileVolume:WW,FileVolume2:GW,FileWarning:KW,FileX:YW,FileX2:ZW,Files:QW,Film:_u,Filter:ty,FilterX:XW,Fingerprint:JW,FireExtinguisher:eK,Fish:rK,FishOff:tK,FishSymbol:sK,Flag:m1,FlagOff:nK,FlagTriangleLeft:aK,FlagTriangleRight:iK,Flame:rh,FlameKindling:oK,Flashlight:cK,FlashlightOff:lK,FlaskConical:Z_,FlaskConicalOff:dK,FlaskRound:uK,FlipHorizontal:NL,FlipHorizontal2:hK,FlipVertical:pK,FlipVertical2:mK,Flower:fK,Flower2:Zg,Focus:xK,FoldHorizontal:gK,FoldVertical:yK,Folder:HK,FolderArchive:vK,FolderCheck:bK,FolderClock:_K,FolderClosed:wK,FolderCode:jK,FolderCog:fN,FolderDot:NK,FolderDown:kK,FolderGit:CK,FolderGit2:SK,FolderHeart:MK,FolderInput:TK,FolderKanban:AK,FolderKey:EK,FolderLock:PK,FolderMinus:IK,FolderOpen:Bm,FolderOpenDot:LK,FolderOutput:DK,FolderPen:xN,FolderPlus:OK,FolderRoot:RK,FolderSearch:zK,FolderSearch2:FK,FolderSymlink:BK,FolderSync:$K,FolderTree:qK,FolderUp:UK,FolderX:VK,Folders:GK,Footprints:WK,Forklift:KK,Forward:ZK,Frame:YK,Framer:QK,Frown:XK,Fuel:JK,Fullscreen:eZ,GalleryHorizontal:sZ,GalleryHorizontalEnd:tZ,GalleryThumbnails:rZ,GalleryVertical:aZ,GalleryVerticalEnd:nZ,Gamepad:oZ,Gamepad2:iZ,Gauge:lZ,Gavel:cZ,Gem:dZ,Ghost:lS,Gift:bo,GitBranch:hZ,GitBranchPlus:uZ,GitCommitHorizontal:gN,GitCommitVertical:mZ,GitCompare:fZ,GitCompareArrows:pZ,GitFork:xZ,GitGraph:gZ,GitMerge:yZ,GitPullRequest:NZ,GitPullRequestArrow:vZ,GitPullRequestClosed:bZ,GitPullRequestCreate:wZ,GitPullRequestCreateArrow:_Z,GitPullRequestDraft:jZ,Github:kZ,Gitlab:SZ,GlassWater:CZ,Glasses:MZ,Globe:Nd,GlobeLock:TZ,Goal:AZ,Grab:EZ,GraduationCap:Qh,Grape:PZ,Grid2x2:vN,Grid2x2Check:IZ,Grid2x2Plus:yN,Grid2x2X:LZ,Grid3x3:dx,Grip:OZ,GripHorizontal:DZ,GripVertical:Eu,Group:RZ,Guitar:FZ,Ham:zZ,Hammer:BZ,Hand:kL,HandCoins:$Z,HandHeart:qZ,HandHelping:bN,HandMetal:UZ,HandPlatter:VZ,Handshake:SL,HardDrive:CL,HardDriveDownload:HZ,HardDriveUpload:GZ,HardHat:WZ,Hash:Y_,Haze:KZ,HdmiPort:ZZ,Heading:JZ,Heading1:GM,Heading2:WM,Heading3:ML,Heading4:YZ,Heading5:QZ,Heading6:XZ,HeadphoneOff:eY,Headphones:tY,Headset:sY,Heart:Ja,HeartCrack:rY,HeartHandshake:nY,HeartOff:aY,HeartPulse:iY,Heater:oY,Hexagon:lY,Highlighter:cY,History:KM,Hop:uY,HopOff:dY,Hospital:hY,Hotel:mY,Hourglass:pY,House:xn,HousePlug:fY,HousePlus:xY,IceCreamBowl:_N,IceCreamCone:wN,IdCard:gY,Image:bl,ImageDown:yY,ImageMinus:vY,ImageOff:bY,ImagePlay:_Y,ImagePlus:p1,ImageUp:wY,ImageUpscale:jY,Images:NY,Import:kY,Inbox:SY,IndentDecrease:jN,IndentIncrease:NN,IndianRupee:CY,Infinity:MY,Info:cS,InspectionPanel:TY,Instagram:Pu,Italic:dS,IterationCcw:AY,IterationCw:EY,JapaneseYen:PY,Joystick:IY,Kanban:x0,Key:Mp,KeyRound:uS,KeySquare:LY,Keyboard:RY,KeyboardMusic:DY,KeyboardOff:OY,Lamp:UY,LampCeiling:FY,LampDesk:zY,LampFloor:BY,LampWallDown:$Y,LampWallUp:qY,LandPlot:VY,Landmark:HY,Languages:GY,Laptop:KY,LaptopMinimal:kN,LaptopMinimalCheck:WY,Lasso:YY,LassoSelect:ZY,Laugh:QY,Layers:ZM,Layers2:XY,Layers3:JY,LayoutDashboard:hS,LayoutGrid:Tp,LayoutList:eQ,LayoutPanelLeft:tQ,LayoutPanelTop:sQ,LayoutTemplate:mS,Leaf:rQ,LeafyGreen:nQ,Lectern:aQ,LetterText:iQ,Library:YM,LibraryBig:oQ,LifeBuoy:QM,Ligature:lQ,Lightbulb:Q_,LightbulbOff:cQ,Link:Uo,Link2:pl,Link2Off:dQ,Linkedin:Ap,List:nh,ListCheck:uQ,ListChecks:hQ,ListCollapse:mQ,ListEnd:pQ,ListFilter:fQ,ListMinus:xQ,ListMusic:gQ,ListOrdered:g0,ListPlus:yQ,ListRestart:vQ,ListStart:bQ,ListTodo:_Q,ListTree:wQ,ListVideo:jQ,ListX:NQ,Loader:SQ,LoaderCircle:ys,LoaderPinwheel:kQ,Locate:XM,LocateFixed:CQ,LocateOff:MQ,Lock:zd,LockKeyhole:TQ,LockKeyholeOpen:SN,LockOpen:CN,LogIn:pS,LogOut:fS,Logs:AQ,Lollipop:EQ,Luggage:PQ,Magnet:IQ,Mail:rr,MailCheck:LQ,MailMinus:DQ,MailOpen:OQ,MailPlus:TL,MailQuestion:RQ,MailSearch:FQ,MailWarning:zQ,MailX:AL,Mailbox:BQ,Mails:$Q,Map:y0,MapPin:aa,MapPinCheck:UQ,MapPinCheckInside:qQ,MapPinHouse:VQ,MapPinMinus:GQ,MapPinMinusInside:HQ,MapPinOff:WQ,MapPinPlus:ZQ,MapPinPlusInside:KQ,MapPinX:QQ,MapPinXInside:YQ,MapPinned:XQ,Martini:JQ,Maximize:xS,Maximize2:eX,Medal:f1,Megaphone:Ph,MegaphoneOff:tX,Meh:sX,MemoryStick:rX,Menu:gS,Merge:nX,MessageCircle:Uc,MessageCircleCode:aX,MessageCircleDashed:iX,MessageCircleHeart:JM,MessageCircleMore:oX,MessageCircleOff:lX,MessageCirclePlus:cX,MessageCircleQuestion:EL,MessageCircleReply:dX,MessageCircleWarning:uX,MessageCircleX:hX,MessageSquare:Ki,MessageSquareCode:mX,MessageSquareDashed:pX,MessageSquareDiff:fX,MessageSquareDot:xX,MessageSquareHeart:gX,MessageSquareLock:yX,MessageSquareMore:PL,MessageSquareOff:vX,MessageSquarePlus:eT,MessageSquareQuote:IL,MessageSquareReply:bX,MessageSquareShare:_X,MessageSquareText:wX,MessageSquareWarning:jX,MessageSquareX:NX,MessagesSquare:kX,Mic:LL,MicOff:SX,MicVocal:MN,Microchip:CX,Microscope:MX,Microwave:TX,Milestone:AX,Milk:PX,MilkOff:EX,Minimize:LX,Minimize2:IX,Minus:v0,Monitor:vS,MonitorCheck:DX,MonitorCog:OX,MonitorDot:RX,MonitorDown:FX,MonitorOff:zX,MonitorPause:BX,MonitorPlay:$X,MonitorSmartphone:qX,MonitorSpeaker:UX,MonitorStop:VX,MonitorUp:yS,MonitorX:HX,Moon:WX,MoonStar:GX,Mountain:DL,MountainSnow:KX,Mouse:XX,MouseOff:ZX,MousePointer:kh,MousePointer2:YX,MousePointerBan:QX,MousePointerClick:$m,Move:uJ,Move3d:TN,MoveDiagonal:eJ,MoveDiagonal2:JX,MoveDown:rJ,MoveDownLeft:tJ,MoveDownRight:sJ,MoveHorizontal:nJ,MoveLeft:aJ,MoveRight:iJ,MoveUp:cJ,MoveUpLeft:oJ,MoveUpRight:lJ,MoveVertical:dJ,Music:fJ,Music2:hJ,Music3:mJ,Music4:pJ,Navigation:OL,Navigation2:gJ,Navigation2Off:xJ,NavigationOff:yJ,Network:vJ,Newspaper:x1,Nfc:bJ,Notebook:NJ,NotebookPen:_J,NotebookTabs:wJ,NotebookText:jJ,NotepadText:SJ,NotepadTextDashed:kJ,Nut:MJ,NutOff:CJ,Octagon:AJ,OctagonAlert:Vv,OctagonMinus:TJ,OctagonPause:AN,OctagonX:EN,Omega:EJ,Option:PJ,Orbit:IJ,Origami:LJ,Package:Al,Package2:DJ,PackageCheck:OJ,PackageMinus:RJ,PackageOpen:FJ,PackagePlus:zJ,PackageSearch:BJ,PackageX:$J,PaintBucket:qJ,PaintRoller:UJ,Paintbrush:VJ,PaintbrushVertical:PN,Palette:$l,PanelBottom:WJ,PanelBottomClose:HJ,PanelBottomDashed:IN,PanelBottomOpen:GJ,PanelLeft:RN,PanelLeftClose:LN,PanelLeftDashed:DN,PanelLeftOpen:ON,PanelRight:YJ,PanelRightClose:KJ,PanelRightDashed:FN,PanelRightOpen:ZJ,PanelTop:JJ,PanelTopClose:QJ,PanelTopDashed:zN,PanelTopOpen:XJ,PanelsLeftBottom:eee,PanelsRightBottom:tee,PanelsTopLeft:Hv,Paperclip:bS,Parentheses:see,ParkingMeter:ree,PartyPopper:iu,Pause:Ih,PawPrint:nee,PcCase:aee,Pen:r0,PenLine:Gv,PenOff:iee,PenTool:X_,Pencil:Pa,PencilLine:oee,PencilOff:lee,PencilRuler:cee,Pentagon:dee,Percent:_S,PersonStanding:uee,PhilippinePeso:hee,Phone:Nn,PhoneCall:mee,PhoneForwarded:pee,PhoneIncoming:fee,PhoneMissed:xee,PhoneOff:gee,PhoneOutgoing:yee,Pi:vee,Piano:bee,Pickaxe:_ee,PictureInPicture:jee,PictureInPicture2:wee,PiggyBank:Nee,Pilcrow:Cee,PilcrowLeft:kee,PilcrowRight:See,Pill:Tee,PillBottle:Mee,Pin:J_,PinOff:RL,Pipette:Aee,Pizza:Eee,Plane:Lee,PlaneLanding:Pee,PlaneTakeoff:Iee,Play:sl,Plug:FL,Plug2:Dee,PlugZap:BN,Plus:qs,Pocket:Ree,PocketKnife:Oee,Podcast:Fee,Pointer:Bee,PointerOff:zee,Popcorn:$ee,Popsicle:qee,PoundSterling:Uee,Power:zL,PowerOff:Vee,Presentation:sy,Printer:BL,PrinterCheck:Hee,Projector:Gee,Proportions:Wee,Puzzle:Kee,Pyramid:Zee,QrCode:b0,Quote:g1,Rabbit:Yee,Radar:Qee,Radiation:Xee,Radical:Jee,Radio:y1,RadioReceiver:ete,RadioTower:tte,Radius:ste,RailSymbol:rte,Rainbow:nte,Rat:ate,Ratio:ite,Receipt:fte,ReceiptCent:ote,ReceiptEuro:lte,ReceiptIndianRupee:cte,ReceiptJapaneseYen:dte,ReceiptPoundSterling:ute,ReceiptRussianRuble:hte,ReceiptSwissFranc:mte,ReceiptText:pte,RectangleEllipsis:$N,RectangleHorizontal:xte,RectangleVertical:gte,Recycle:yte,Redo:wS,Redo2:vte,RedoDot:bte,RefreshCcw:tT,RefreshCcwDot:_te,RefreshCw:zo,RefreshCwOff:wte,Refrigerator:jte,Regex:Nte,RemoveFormatting:kte,Repeat:$L,Repeat1:Ste,Repeat2:Cte,Replace:Tte,ReplaceAll:Mte,Reply:qL,ReplyAll:Ate,Rewind:Ete,Ribbon:Pte,Rocket:_0,RockingChair:Ite,RollerCoaster:Lte,Rotate3d:qN,RotateCcw:w0,RotateCcwSquare:Dte,RotateCw:UL,RotateCwSquare:Ote,Route:Fte,RouteOff:Rte,Router:zte,Rows2:UN,Rows3:VN,Rows4:Bte,Rss:$te,Ruler:Ix,RussianRuble:qte,Sailboat:Ute,Salad:Vte,Sandwich:Hte,Satellite:Wte,SatelliteDish:Gte,Save:Vc,SaveAll:Kte,SaveOff:Zte,Scale:VL,Scale3d:HN,Scaling:Yte,Scan:nse,ScanBarcode:Qte,ScanEye:Xte,ScanFace:Jte,ScanLine:ese,ScanQrCode:tse,ScanSearch:sse,ScanText:rse,School:ase,Scissors:ose,ScissorsLineDashed:ise,ScreenShare:cse,ScreenShareOff:lse,Scroll:use,ScrollText:dse,Search:sn,SearchCheck:hse,SearchCode:mse,SearchSlash:pse,SearchX:HL,Section:fse,Send:Fn,SendHorizontal:GN,SendToBack:xse,SeparatorHorizontal:gse,SeparatorVertical:yse,Server:wse,ServerCog:vse,ServerCrash:bse,ServerOff:_se,Settings:el,Settings2:GL,Shapes:jse,Share:WL,Share2:nd,Sheet:Nse,Shell:kse,Shield:ou,ShieldAlert:Sse,ShieldBan:Cse,ShieldCheck:jS,ShieldEllipsis:Mse,ShieldHalf:Tse,ShieldMinus:Ase,ShieldOff:NS,ShieldPlus:Ese,ShieldQuestion:Pse,ShieldX:WN,Ship:Lse,ShipWheel:Ise,Shirt:Dse,ShoppingBag:j0,ShoppingBasket:Ose,ShoppingCart:bp,Shovel:Rse,ShowerHead:Fse,Shrink:zse,Shrub:Bse,Shuffle:kS,Sigma:$se,Signal:Gse,SignalHigh:qse,SignalLow:Use,SignalMedium:Vse,SignalZero:Hse,Signature:Wse,Signpost:Zse,SignpostBig:Kse,Siren:Yse,SkipBack:Qse,SkipForward:Xse,Skull:Jse,Slack:ere,Slash:tre,Slice:sre,SlidersHorizontal:v1,SlidersVertical:KN,Smartphone:N0,SmartphoneCharging:rre,SmartphoneNfc:nre,Smile:ire,SmilePlus:are,Snail:ore,Snowflake:l0,Sofa:lre,Soup:cre,Space:dre,Spade:ure,Sparkle:hre,Sparkles:nn,Speaker:mre,Speech:pre,SpellCheck:xre,SpellCheck2:fre,Spline:gre,Split:yre,SprayCan:vre,Sprout:SS,Square:k0,SquareActivity:ZN,SquareArrowDown:XN,SquareArrowDownLeft:YN,SquareArrowDownRight:QN,SquareArrowLeft:JN,SquareArrowOutDownLeft:ek,SquareArrowOutDownRight:tk,SquareArrowOutUpLeft:sk,SquareArrowOutUpRight:rk,SquareArrowRight:nk,SquareArrowUp:ok,SquareArrowUpLeft:ak,SquareArrowUpRight:ik,SquareAsterisk:lk,SquareBottomDashedScissors:ck,SquareChartGantt:Wy,SquareCheck:dk,SquareCheckBig:Wv,SquareChevronDown:uk,SquareChevronLeft:hk,SquareChevronRight:mk,SquareChevronUp:pk,SquareCode:fk,SquareDashed:yk,SquareDashedBottom:_re,SquareDashedBottomCode:bre,SquareDashedKanban:xk,SquareDashedMousePointer:gk,SquareDivide:vk,SquareDot:bk,SquareEqual:_k,SquareFunction:wk,SquareKanban:jk,SquareLibrary:Nk,SquareM:kk,SquareMenu:Sk,SquareMinus:Ck,SquareMousePointer:Mk,SquareParking:Ak,SquareParkingOff:Tk,SquarePen:md,SquarePercent:Ek,SquarePi:Pk,SquarePilcrow:Ik,SquarePlay:Lk,SquarePlus:Dk,SquarePower:Ok,SquareRadical:wre,SquareScissors:Rk,SquareSigma:Fk,SquareSlash:zk,SquareSplitHorizontal:Bk,SquareSplitVertical:$k,SquareSquare:jre,SquareStack:Nre,SquareTerminal:qk,SquareUser:Vk,SquareUserRound:Uk,SquareX:Hk,Squircle:kre,Squirrel:Sre,Stamp:Cre,Star:ea,StarHalf:Mre,StarOff:Tre,StepBack:Are,StepForward:Ere,Stethoscope:Pre,Sticker:Ire,StickyNote:Lre,Store:sT,StretchHorizontal:Dre,StretchVertical:Ore,Strikethrough:KL,Subscript:Rre,Sun:b1,SunDim:Fre,SunMedium:zre,SunMoon:Bre,SunSnow:$re,Sunrise:qre,Sunset:Ure,Superscript:Vre,SwatchBook:Hre,SwissFranc:Gre,SwitchCamera:Wre,Sword:Kre,Swords:Zre,Syringe:Yre,Table:nT,Table2:rT,TableCellsMerge:Qre,TableCellsSplit:Xre,TableColumnsSplit:Jre,TableOfContents:ene,TableProperties:tne,TableRowsSplit:sne,Tablet:nne,TabletSmartphone:rne,Tablets:ane,Tag:Lh,Tags:ine,Tally1:one,Tally2:lne,Tally3:cne,Tally4:dne,Tally5:une,Tangent:hne,Target:Xh,Telescope:mne,Tent:fne,TentTree:pne,Terminal:xne,TestTube:gne,TestTubeDiagonal:Gk,TestTubes:yne,Text:jne,TextCursor:bne,TextCursorInput:vne,TextQuote:_ne,TextSearch:wne,TextSelect:Wk,Theater:Nne,Thermometer:ZL,ThermometerSnowflake:kne,ThermometerSun:Sne,ThumbsDown:YL,ThumbsUp:ah,Ticket:QL,TicketCheck:Cne,TicketMinus:Mne,TicketPercent:Tne,TicketPlus:Ane,TicketSlash:Ene,TicketX:Pne,Tickets:Lne,TicketsPlane:Ine,Timer:Rne,TimerOff:Dne,TimerReset:One,ToggleLeft:Fne,ToggleRight:zne,Toilet:Bne,Tornado:$ne,Torus:qne,Touchpad:Vne,TouchpadOff:Une,TowerControl:Hne,ToyBrick:Gne,Tractor:Wne,TrafficCone:Kne,TrainFront:Yne,TrainFrontTunnel:Zne,TrainTrack:Qne,TramFront:Kk,Trash:Xne,Trash2:kr,TreeDeciduous:Jne,TreePalm:Zk,TreePine:S0,Trees:eae,Trello:tae,TrendingDown:CS,TrendingUp:Bo,TrendingUpDown:sae,Triangle:nae,TriangleAlert:vd,TriangleRight:rae,Trophy:_o,Truck:aT,Turtle:aae,Tv:oae,TvMinimal:Yk,TvMinimalPlay:iae,Twitch:lae,Twitter:cae,Type:uae,TypeOutline:dae,Umbrella:mae,UmbrellaOff:hae,Underline:XL,Undo:MS,Undo2:pae,UndoDot:fae,UnfoldHorizontal:xae,UnfoldVertical:gae,Ungroup:yae,University:Qk,Unlink:TS,Unlink2:vae,Unplug:bae,Upload:ci,Usb:_ae,User:Zi,UserCheck:ew,UserCog:JL,UserMinus:e8,UserPen:wae,UserPlus:El,UserRound:r4,UserRoundCheck:Xk,UserRoundCog:Jk,UserRoundMinus:e4,UserRoundPen:jae,UserRoundPlus:t4,UserRoundSearch:Nae,UserRoundX:s4,UserSearch:kae,UserX:Sae,Users:ur,UsersRound:n4,Utensils:i4,UtensilsCrossed:a4,UtilityPole:Cae,Variable:iT,Vault:Mae,Vegan:Tae,VenetianMask:Aae,Vibrate:Pae,VibrateOff:Eae,Video:An,VideoOff:Iae,Videotape:Lae,View:Dae,Voicemail:Oae,Volleyball:Rae,Volume:qae,Volume1:Fae,Volume2:zae,VolumeOff:Bae,VolumeX:$ae,Vote:Uae,Wallet:t8,WalletCards:Vae,WalletMinimal:o4,Wallpaper:Hae,Wand:Gae,WandSparkles:Kv,Warehouse:Wae,WashingMachine:Kae,Watch:Zae,Waves:s8,Waypoints:Yae,Webcam:Qae,Webhook:Jae,WebhookOff:Xae,Weight:eie,Wheat:sie,WheatOff:tie,WholeWord:rie,Wifi:lie,WifiHigh:nie,WifiLow:aie,WifiOff:iie,WifiZero:oie,Wind:die,WindArrowDown:cie,Wine:hie,WineOff:uie,Workflow:mie,Worm:pie,WrapText:fie,Wrench:ry,X:Er,Youtube:xie,Zap:Jh,ZapOff:gie,ZoomIn:tw,ZoomOut:oT},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 E2e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:B9,AArrowDownIcon:B9,AArrowUp:$9,AArrowUpIcon:$9,ALargeSmall:q9,ALargeSmallIcon:q9,Accessibility:U9,AccessibilityIcon:U9,Activity:Mh,ActivityIcon:Mh,ActivitySquare:ZN,ActivitySquareIcon:ZN,AirVent:V9,AirVentIcon:V9,Airplay:H9,AirplayIcon:H9,AlarmCheck:X2,AlarmCheckIcon:X2,AlarmClock:W9,AlarmClockCheck:X2,AlarmClockCheckIcon:X2,AlarmClockIcon:W9,AlarmClockMinus:J2,AlarmClockMinusIcon:J2,AlarmClockOff:G9,AlarmClockOffIcon:G9,AlarmClockPlus:ej,AlarmClockPlusIcon:ej,AlarmMinus:J2,AlarmMinusIcon:J2,AlarmPlus:ej,AlarmPlusIcon:ej,AlarmSmoke:K9,AlarmSmokeIcon:K9,Album:Z9,AlbumIcon:Z9,AlertCircle:ul,AlertCircleIcon:ul,AlertOctagon:Vv,AlertOctagonIcon:Vv,AlertTriangle:vd,AlertTriangleIcon:vd,AlignCenter:Q4,AlignCenterHorizontal:Y9,AlignCenterHorizontalIcon:Y9,AlignCenterIcon:Q4,AlignCenterVertical:Q9,AlignCenterVerticalIcon:Q9,AlignEndHorizontal:X9,AlignEndHorizontalIcon:X9,AlignEndVertical:J9,AlignEndVerticalIcon:J9,AlignHorizontalDistributeCenter:eB,AlignHorizontalDistributeCenterIcon:eB,AlignHorizontalDistributeEnd:tB,AlignHorizontalDistributeEndIcon:tB,AlignHorizontalDistributeStart:sB,AlignHorizontalDistributeStartIcon:sB,AlignHorizontalJustifyCenter:rB,AlignHorizontalJustifyCenterIcon:rB,AlignHorizontalJustifyEnd:nB,AlignHorizontalJustifyEndIcon:nB,AlignHorizontalJustifyStart:aB,AlignHorizontalJustifyStartIcon:aB,AlignHorizontalSpaceAround:iB,AlignHorizontalSpaceAroundIcon:iB,AlignHorizontalSpaceBetween:oB,AlignHorizontalSpaceBetweenIcon:oB,AlignJustify:lB,AlignJustifyIcon:lB,AlignLeft:X4,AlignLeftIcon:X4,AlignRight:J4,AlignRightIcon:J4,AlignStartHorizontal:cB,AlignStartHorizontalIcon:cB,AlignStartVertical:dB,AlignStartVerticalIcon:dB,AlignVerticalDistributeCenter:uB,AlignVerticalDistributeCenterIcon:uB,AlignVerticalDistributeEnd:hB,AlignVerticalDistributeEndIcon:hB,AlignVerticalDistributeStart:mB,AlignVerticalDistributeStartIcon:mB,AlignVerticalJustifyCenter:pB,AlignVerticalJustifyCenterIcon:pB,AlignVerticalJustifyEnd:fB,AlignVerticalJustifyEndIcon:fB,AlignVerticalJustifyStart:xB,AlignVerticalJustifyStartIcon:xB,AlignVerticalSpaceAround:gB,AlignVerticalSpaceAroundIcon:gB,AlignVerticalSpaceBetween:yB,AlignVerticalSpaceBetweenIcon:yB,Ambulance:vB,AmbulanceIcon:vB,Ampersand:bB,AmpersandIcon:bB,Ampersands:_B,AmpersandsIcon:_B,Amphora:wB,AmphoraIcon:wB,Anchor:jB,AnchorIcon:jB,Angry:NB,AngryIcon:NB,Annoyed:kB,AnnoyedIcon:kB,Antenna:SB,AntennaIcon:SB,Anvil:CB,AnvilIcon:CB,Aperture:MB,ApertureIcon:MB,AppWindow:dL,AppWindowIcon:dL,AppWindowMac:TB,AppWindowMacIcon:TB,Apple:AB,AppleIcon:AB,Archive:zM,ArchiveIcon:zM,ArchiveRestore:uL,ArchiveRestoreIcon:uL,ArchiveX:EB,ArchiveXIcon:EB,AreaChart:pj,AreaChartIcon:pj,Armchair:PB,ArmchairIcon:PB,ArrowBigDown:LB,ArrowBigDownDash:IB,ArrowBigDownDashIcon:IB,ArrowBigDownIcon:LB,ArrowBigLeft:OB,ArrowBigLeftDash:DB,ArrowBigLeftDashIcon:DB,ArrowBigLeftIcon:OB,ArrowBigRight:FB,ArrowBigRightDash:RB,ArrowBigRightDashIcon:RB,ArrowBigRightIcon:FB,ArrowBigUp:BB,ArrowBigUpDash:zB,ArrowBigUpDashIcon:zB,ArrowBigUpIcon:BB,ArrowDown:Yh,ArrowDown01:$B,ArrowDown01Icon:$B,ArrowDown10:qB,ArrowDown10Icon:qB,ArrowDownAZ:tj,ArrowDownAZIcon:tj,ArrowDownAz:tj,ArrowDownAzIcon:tj,ArrowDownCircle:Sj,ArrowDownCircleIcon:Sj,ArrowDownFromLine:UB,ArrowDownFromLineIcon:UB,ArrowDownIcon:Yh,ArrowDownLeft:VB,ArrowDownLeftFromCircle:Mj,ArrowDownLeftFromCircleIcon:Mj,ArrowDownLeftFromSquare:ek,ArrowDownLeftFromSquareIcon:ek,ArrowDownLeftIcon:VB,ArrowDownLeftSquare:YN,ArrowDownLeftSquareIcon:YN,ArrowDownNarrowWide:HB,ArrowDownNarrowWideIcon:HB,ArrowDownRight:hL,ArrowDownRightFromCircle:Tj,ArrowDownRightFromCircleIcon:Tj,ArrowDownRightFromSquare:tk,ArrowDownRightFromSquareIcon:tk,ArrowDownRightIcon:hL,ArrowDownRightSquare:QN,ArrowDownRightSquareIcon:QN,ArrowDownSquare:XN,ArrowDownSquareIcon:XN,ArrowDownToDot:GB,ArrowDownToDotIcon:GB,ArrowDownToLine:WB,ArrowDownToLineIcon:WB,ArrowDownUp:KB,ArrowDownUpIcon:KB,ArrowDownWideNarrow:sj,ArrowDownWideNarrowIcon:sj,ArrowDownZA:rj,ArrowDownZAIcon:rj,ArrowDownZa:rj,ArrowDownZaIcon:rj,ArrowLeft:Ga,ArrowLeftCircle:Cj,ArrowLeftCircleIcon:Cj,ArrowLeftFromLine:ZB,ArrowLeftFromLineIcon:ZB,ArrowLeftIcon:Ga,ArrowLeftRight:YB,ArrowLeftRightIcon:YB,ArrowLeftSquare:JN,ArrowLeftSquareIcon:JN,ArrowLeftToLine:QB,ArrowLeftToLineIcon:QB,ArrowRight:ba,ArrowRightCircle:Pj,ArrowRightCircleIcon:Pj,ArrowRightFromLine:XB,ArrowRightFromLineIcon:XB,ArrowRightIcon:ba,ArrowRightLeft:l1,ArrowRightLeftIcon:l1,ArrowRightSquare:nk,ArrowRightSquareIcon:nk,ArrowRightToLine:JB,ArrowRightToLineIcon:JB,ArrowUp:Tu,ArrowUp01:e$,ArrowUp01Icon:e$,ArrowUp10:t$,ArrowUp10Icon:t$,ArrowUpAZ:nj,ArrowUpAZIcon:nj,ArrowUpAz:nj,ArrowUpAzIcon:nj,ArrowUpCircle:Ij,ArrowUpCircleIcon:Ij,ArrowUpDown:wd,ArrowUpDownIcon:wd,ArrowUpFromDot:s$,ArrowUpFromDotIcon:s$,ArrowUpFromLine:r$,ArrowUpFromLineIcon:r$,ArrowUpIcon:Tu,ArrowUpLeft:n$,ArrowUpLeftFromCircle:Aj,ArrowUpLeftFromCircleIcon:Aj,ArrowUpLeftFromSquare:sk,ArrowUpLeftFromSquareIcon:sk,ArrowUpLeftIcon:n$,ArrowUpLeftSquare:ak,ArrowUpLeftSquareIcon:ak,ArrowUpNarrowWide:aj,ArrowUpNarrowWideIcon:aj,ArrowUpRight:mL,ArrowUpRightFromCircle:Ej,ArrowUpRightFromCircleIcon:Ej,ArrowUpRightFromSquare:rk,ArrowUpRightFromSquareIcon:rk,ArrowUpRightIcon:mL,ArrowUpRightSquare:ik,ArrowUpRightSquareIcon:ik,ArrowUpSquare:ok,ArrowUpSquareIcon:ok,ArrowUpToLine:a$,ArrowUpToLineIcon:a$,ArrowUpWideNarrow:i$,ArrowUpWideNarrowIcon:i$,ArrowUpZA:ij,ArrowUpZAIcon:ij,ArrowUpZa:ij,ArrowUpZaIcon:ij,ArrowsUpFromLine:o$,ArrowsUpFromLineIcon:o$,Asterisk:l$,AsteriskIcon:l$,AsteriskSquare:lk,AsteriskSquareIcon:lk,AtSign:c$,AtSignIcon:c$,Atom:d$,AtomIcon:d$,AudioLines:u$,AudioLinesIcon:u$,AudioWaveform:h$,AudioWaveformIcon:h$,Award:rc,AwardIcon:rc,Axe:m$,AxeIcon:m$,Axis3D:oj,Axis3DIcon:oj,Axis3d:oj,Axis3dIcon:oj,Baby:p$,BabyIcon:p$,Backpack:f$,BackpackIcon:f$,Badge:E$,BadgeAlert:x$,BadgeAlertIcon:x$,BadgeCent:g$,BadgeCentIcon:g$,BadgeCheck:lj,BadgeCheckIcon:lj,BadgeDollarSign:y$,BadgeDollarSignIcon:y$,BadgeEuro:v$,BadgeEuroIcon:v$,BadgeHelp:b$,BadgeHelpIcon:b$,BadgeIcon:E$,BadgeIndianRupee:_$,BadgeIndianRupeeIcon:_$,BadgeInfo:w$,BadgeInfoIcon:w$,BadgeJapaneseYen:j$,BadgeJapaneseYenIcon:j$,BadgeMinus:N$,BadgeMinusIcon:N$,BadgePercent:k$,BadgePercentIcon:k$,BadgePlus:S$,BadgePlusIcon:S$,BadgePoundSterling:C$,BadgePoundSterlingIcon:C$,BadgeRussianRuble:M$,BadgeRussianRubleIcon:M$,BadgeSwissFranc:T$,BadgeSwissFrancIcon:T$,BadgeX:A$,BadgeXIcon:A$,BaggageClaim:P$,BaggageClaimIcon:P$,Ban:pL,BanIcon:pL,Banana:I$,BananaIcon:I$,Bandage:L$,BandageIcon:L$,Banknote:D$,BanknoteIcon:D$,BarChart:_j,BarChart2:wj,BarChart2Icon:wj,BarChart3:co,BarChart3Icon:co,BarChart4:vj,BarChart4Icon:vj,BarChartBig:yj,BarChartBigIcon:yj,BarChartHorizontal:xj,BarChartHorizontalBig:fj,BarChartHorizontalBigIcon:fj,BarChartHorizontalIcon:xj,BarChartIcon:_j,Barcode:O$,BarcodeIcon:O$,Baseline:R$,BaselineIcon:R$,Bath:au,BathIcon:au,Battery:U$,BatteryCharging:F$,BatteryChargingIcon:F$,BatteryFull:z$,BatteryFullIcon:z$,BatteryIcon:U$,BatteryLow:B$,BatteryLowIcon:B$,BatteryMedium:$$,BatteryMediumIcon:$$,BatteryWarning:q$,BatteryWarningIcon:q$,Beaker:V$,BeakerIcon:V$,Bean:G$,BeanIcon:G$,BeanOff:H$,BeanOffIcon:H$,Bed:Th,BedDouble:eS,BedDoubleIcon:eS,BedIcon:Th,BedSingle:W$,BedSingleIcon:W$,Beef:K$,BeefIcon:K$,Beer:Y$,BeerIcon:Y$,BeerOff:Z$,BeerOffIcon:Z$,Bell:Fm,BellDot:Q$,BellDotIcon:Q$,BellElectric:X$,BellElectricIcon:X$,BellIcon:Fm,BellMinus:J$,BellMinusIcon:J$,BellOff:c1,BellOffIcon:c1,BellPlus:eq,BellPlusIcon:eq,BellRing:tq,BellRingIcon:tq,BetweenHorizonalEnd:cj,BetweenHorizonalEndIcon:cj,BetweenHorizonalStart:dj,BetweenHorizonalStartIcon:dj,BetweenHorizontalEnd:cj,BetweenHorizontalEndIcon:cj,BetweenHorizontalStart:dj,BetweenHorizontalStartIcon:dj,BetweenVerticalEnd:sq,BetweenVerticalEndIcon:sq,BetweenVerticalStart:rq,BetweenVerticalStartIcon:rq,BicepsFlexed:nq,BicepsFlexedIcon:nq,Bike:aq,BikeIcon:aq,Binary:iq,BinaryIcon:iq,Binoculars:oq,BinocularsIcon:oq,Biohazard:lq,BiohazardIcon:lq,Bird:cq,BirdIcon:cq,Bitcoin:dq,BitcoinIcon:dq,Blend:uq,BlendIcon:uq,Blinds:hq,BlindsIcon:hq,Blocks:mq,BlocksIcon:mq,Bluetooth:gq,BluetoothConnected:pq,BluetoothConnectedIcon:pq,BluetoothIcon:gq,BluetoothOff:fq,BluetoothOffIcon:fq,BluetoothSearching:xq,BluetoothSearchingIcon:xq,Bold:tS,BoldIcon:tS,Bolt:yq,BoltIcon:yq,Bomb:vq,BombIcon:vq,Bone:bq,BoneIcon:bq,Book:qq,BookA:_q,BookAIcon:_q,BookAudio:wq,BookAudioIcon:wq,BookCheck:jq,BookCheckIcon:jq,BookCopy:Nq,BookCopyIcon:Nq,BookDashed:uj,BookDashedIcon:uj,BookDown:kq,BookDownIcon:kq,BookHeadphones:Sq,BookHeadphonesIcon:Sq,BookHeart:Cq,BookHeartIcon:Cq,BookIcon:qq,BookImage:Mq,BookImageIcon:Mq,BookKey:Tq,BookKeyIcon:Tq,BookLock:Aq,BookLockIcon:Aq,BookMarked:Eq,BookMarkedIcon:Eq,BookMinus:Pq,BookMinusIcon:Pq,BookOpen:Ah,BookOpenCheck:Iq,BookOpenCheckIcon:Iq,BookOpenIcon:Ah,BookOpenText:Lq,BookOpenTextIcon:Lq,BookPlus:Dq,BookPlusIcon:Dq,BookTemplate:uj,BookTemplateIcon:uj,BookText:Oq,BookTextIcon:Oq,BookType:Rq,BookTypeIcon:Rq,BookUp:zq,BookUp2:Fq,BookUp2Icon:Fq,BookUpIcon:zq,BookUser:Bq,BookUserIcon:Bq,BookX:$q,BookXIcon:$q,Bookmark:Ax,BookmarkCheck:Uq,BookmarkCheckIcon:Uq,BookmarkIcon:Ax,BookmarkMinus:Vq,BookmarkMinusIcon:Vq,BookmarkPlus:fL,BookmarkPlusIcon:fL,BookmarkX:Hq,BookmarkXIcon:Hq,BoomBox:Gq,BoomBoxIcon:Gq,Bot:BM,BotIcon:BM,BotMessageSquare:Wq,BotMessageSquareIcon:Wq,BotOff:Kq,BotOffIcon:Kq,Box:Zq,BoxIcon:Zq,BoxSelect:yk,BoxSelectIcon:yk,Boxes:Yq,BoxesIcon:Yq,Braces:hj,BracesIcon:hj,Brackets:Qq,BracketsIcon:Qq,Brain:xL,BrainCircuit:Xq,BrainCircuitIcon:Xq,BrainCog:Jq,BrainCogIcon:Jq,BrainIcon:xL,BrickWall:eU,BrickWallIcon:eU,Briefcase:sh,BriefcaseBusiness:tU,BriefcaseBusinessIcon:tU,BriefcaseConveyorBelt:sU,BriefcaseConveyorBeltIcon:sU,BriefcaseIcon:sh,BriefcaseMedical:rU,BriefcaseMedicalIcon:rU,BringToFront:nU,BringToFrontIcon:nU,Brush:aU,BrushIcon:aU,Bug:lU,BugIcon:lU,BugOff:iU,BugOffIcon:iU,BugPlay:oU,BugPlayIcon:oU,Building:sS,Building2:Ta,Building2Icon:Ta,BuildingIcon:sS,Bus:dU,BusFront:cU,BusFrontIcon:cU,BusIcon:dU,Cable:hU,CableCar:uU,CableCarIcon:uU,CableIcon:hU,Cake:Eh,CakeIcon:Eh,CakeSlice:mU,CakeSliceIcon:mU,Calculator:rS,CalculatorIcon:rS,Calendar:fn,Calendar1:pU,Calendar1Icon:pU,CalendarArrowDown:fU,CalendarArrowDownIcon:fU,CalendarArrowUp:xU,CalendarArrowUpIcon:xU,CalendarCheck:gL,CalendarCheck2:gU,CalendarCheck2Icon:gU,CalendarCheckIcon:gL,CalendarClock:$M,CalendarClockIcon:$M,CalendarCog:yU,CalendarCogIcon:yU,CalendarDays:Fd,CalendarDaysIcon:Fd,CalendarFold:vU,CalendarFoldIcon:vU,CalendarHeart:bU,CalendarHeartIcon:bU,CalendarIcon:fn,CalendarMinus:wU,CalendarMinus2:_U,CalendarMinus2Icon:_U,CalendarMinusIcon:wU,CalendarOff:yL,CalendarOffIcon:yL,CalendarPlus:G_,CalendarPlus2:jU,CalendarPlus2Icon:jU,CalendarPlusIcon:G_,CalendarRange:NU,CalendarRangeIcon:NU,CalendarSearch:kU,CalendarSearchIcon:kU,CalendarSync:SU,CalendarSyncIcon:SU,CalendarX:MU,CalendarX2:CU,CalendarX2Icon:CU,CalendarXIcon:MU,Camera:gf,CameraIcon:gf,CameraOff:TU,CameraOffIcon:TU,CandlestickChart:gj,CandlestickChartIcon:gj,Candy:PU,CandyCane:AU,CandyCaneIcon:AU,CandyIcon:PU,CandyOff:EU,CandyOffIcon:EU,Cannabis:IU,CannabisIcon:IU,Captions:mj,CaptionsIcon:mj,CaptionsOff:LU,CaptionsOffIcon:LU,Car:qM,CarFront:DU,CarFrontIcon:DU,CarIcon:qM,CarTaxiFront:OU,CarTaxiFrontIcon:OU,Caravan:RU,CaravanIcon:RU,Carrot:FU,CarrotIcon:FU,CaseLower:zU,CaseLowerIcon:zU,CaseSensitive:BU,CaseSensitiveIcon:BU,CaseUpper:$U,CaseUpperIcon:$U,CassetteTape:qU,CassetteTapeIcon:qU,Cast:UU,CastIcon:UU,Castle:VU,CastleIcon:VU,Cat:HU,CatIcon:HU,Cctv:GU,CctvIcon:GU,ChartArea:pj,ChartAreaIcon:pj,ChartBar:xj,ChartBarBig:fj,ChartBarBigIcon:fj,ChartBarDecreasing:WU,ChartBarDecreasingIcon:WU,ChartBarIcon:xj,ChartBarIncreasing:KU,ChartBarIncreasingIcon:KU,ChartBarStacked:ZU,ChartBarStackedIcon:ZU,ChartCandlestick:gj,ChartCandlestickIcon:gj,ChartColumn:co,ChartColumnBig:yj,ChartColumnBigIcon:yj,ChartColumnDecreasing:YU,ChartColumnDecreasingIcon:YU,ChartColumnIcon:co,ChartColumnIncreasing:vj,ChartColumnIncreasingIcon:vj,ChartColumnStacked:QU,ChartColumnStackedIcon:QU,ChartGantt:XU,ChartGanttIcon:XU,ChartLine:bj,ChartLineIcon:bj,ChartNetwork:JU,ChartNetworkIcon:JU,ChartNoAxesColumn:wj,ChartNoAxesColumnDecreasing:eV,ChartNoAxesColumnDecreasingIcon:eV,ChartNoAxesColumnIcon:wj,ChartNoAxesColumnIncreasing:_j,ChartNoAxesColumnIncreasingIcon:_j,ChartNoAxesCombined:tV,ChartNoAxesCombinedIcon:tV,ChartNoAxesGantt:jj,ChartNoAxesGanttIcon:jj,ChartPie:Nj,ChartPieIcon:Nj,ChartScatter:kj,ChartScatterIcon:kj,ChartSpline:sV,ChartSplineIcon:sV,Check:ua,CheckCheck:vL,CheckCheckIcon:vL,CheckCircle:wi,CheckCircle2:sa,CheckCircle2Icon:sa,CheckCircleIcon:wi,CheckIcon:ua,CheckSquare:Wv,CheckSquare2:dk,CheckSquare2Icon:dk,CheckSquareIcon:Wv,ChefHat:rV,ChefHatIcon:rV,Cherry:nV,CherryIcon:nV,ChevronDown:Ji,ChevronDownCircle:Lj,ChevronDownCircleIcon:Lj,ChevronDownIcon:Ji,ChevronDownSquare:uk,ChevronDownSquareIcon:uk,ChevronFirst:aV,ChevronFirstIcon:aV,ChevronLast:iV,ChevronLastIcon:iV,ChevronLeft:tl,ChevronLeftCircle:Dj,ChevronLeftCircleIcon:Dj,ChevronLeftIcon:tl,ChevronLeftSquare:hk,ChevronLeftSquareIcon:hk,ChevronRight:da,ChevronRightCircle:Oj,ChevronRightCircleIcon:Oj,ChevronRightIcon:da,ChevronRightSquare:mk,ChevronRightSquareIcon:mk,ChevronUp:Sp,ChevronUpCircle:Rj,ChevronUpCircleIcon:Rj,ChevronUpIcon:Sp,ChevronUpSquare:pk,ChevronUpSquareIcon:pk,ChevronsDown:lV,ChevronsDownIcon:lV,ChevronsDownUp:oV,ChevronsDownUpIcon:oV,ChevronsLeft:uV,ChevronsLeftIcon:uV,ChevronsLeftRight:dV,ChevronsLeftRightEllipsis:cV,ChevronsLeftRightEllipsisIcon:cV,ChevronsLeftRightIcon:dV,ChevronsRight:mV,ChevronsRightIcon:mV,ChevronsRightLeft:hV,ChevronsRightLeftIcon:hV,ChevronsUp:pV,ChevronsUpDown:Ex,ChevronsUpDownIcon:Ex,ChevronsUpIcon:pV,Chrome:fV,ChromeIcon:fV,Church:xV,ChurchIcon:xV,Cigarette:yV,CigaretteIcon:yV,CigaretteOff:gV,CigaretteOffIcon:gV,Circle:jd,CircleAlert:ul,CircleAlertIcon:ul,CircleArrowDown:Sj,CircleArrowDownIcon:Sj,CircleArrowLeft:Cj,CircleArrowLeftIcon:Cj,CircleArrowOutDownLeft:Mj,CircleArrowOutDownLeftIcon:Mj,CircleArrowOutDownRight:Tj,CircleArrowOutDownRightIcon:Tj,CircleArrowOutUpLeft:Aj,CircleArrowOutUpLeftIcon:Aj,CircleArrowOutUpRight:Ej,CircleArrowOutUpRightIcon:Ej,CircleArrowRight:Pj,CircleArrowRightIcon:Pj,CircleArrowUp:Ij,CircleArrowUpIcon:Ij,CircleCheck:sa,CircleCheckBig:wi,CircleCheckBigIcon:wi,CircleCheckIcon:sa,CircleChevronDown:Lj,CircleChevronDownIcon:Lj,CircleChevronLeft:Dj,CircleChevronLeftIcon:Dj,CircleChevronRight:Oj,CircleChevronRightIcon:Oj,CircleChevronUp:Rj,CircleChevronUpIcon:Rj,CircleDashed:vV,CircleDashedIcon:vV,CircleDivide:Fj,CircleDivideIcon:Fj,CircleDollarSign:bV,CircleDollarSignIcon:bV,CircleDot:wV,CircleDotDashed:_V,CircleDotDashedIcon:_V,CircleDotIcon:wV,CircleEllipsis:jV,CircleEllipsisIcon:jV,CircleEqual:NV,CircleEqualIcon:NV,CircleFadingArrowUp:kV,CircleFadingArrowUpIcon:kV,CircleFadingPlus:SV,CircleFadingPlusIcon:SV,CircleGauge:zj,CircleGaugeIcon:zj,CircleHelp:Uv,CircleHelpIcon:Uv,CircleIcon:jd,CircleMinus:Bj,CircleMinusIcon:Bj,CircleOff:CV,CircleOffIcon:CV,CircleParking:qj,CircleParkingIcon:qj,CircleParkingOff:$j,CircleParkingOffIcon:$j,CirclePause:Uj,CirclePauseIcon:Uj,CirclePercent:Vj,CirclePercentIcon:Vj,CirclePlay:fp,CirclePlayIcon:fp,CirclePlus:Hj,CirclePlusIcon:Hj,CirclePower:Gj,CirclePowerIcon:Gj,CircleSlash:MV,CircleSlash2:Wj,CircleSlash2Icon:Wj,CircleSlashIcon:MV,CircleSlashed:Wj,CircleSlashedIcon:Wj,CircleStop:Kj,CircleStopIcon:Kj,CircleUser:Yj,CircleUserIcon:Yj,CircleUserRound:Zj,CircleUserRoundIcon:Zj,CircleX:Nc,CircleXIcon:Nc,CircuitBoard:TV,CircuitBoardIcon:TV,Citrus:AV,CitrusIcon:AV,Clapperboard:EV,ClapperboardIcon:EV,Clipboard:FV,ClipboardCheck:UM,ClipboardCheckIcon:UM,ClipboardCopy:PV,ClipboardCopyIcon:PV,ClipboardEdit:Xj,ClipboardEditIcon:Xj,ClipboardIcon:FV,ClipboardList:W_,ClipboardListIcon:W_,ClipboardMinus:IV,ClipboardMinusIcon:IV,ClipboardPaste:LV,ClipboardPasteIcon:LV,ClipboardPen:Xj,ClipboardPenIcon:Xj,ClipboardPenLine:Qj,ClipboardPenLineIcon:Qj,ClipboardPlus:DV,ClipboardPlusIcon:DV,ClipboardSignature:Qj,ClipboardSignatureIcon:Qj,ClipboardType:OV,ClipboardTypeIcon:OV,ClipboardX:RV,ClipboardXIcon:RV,Clock:mn,Clock1:zV,Clock10:BV,Clock10Icon:BV,Clock11:$V,Clock11Icon:$V,Clock12:qV,Clock12Icon:qV,Clock1Icon:zV,Clock2:UV,Clock2Icon:UV,Clock3:VV,Clock3Icon:VV,Clock4:HV,Clock4Icon:HV,Clock5:GV,Clock5Icon:GV,Clock6:WV,Clock6Icon:WV,Clock7:KV,Clock7Icon:KV,Clock8:ZV,Clock8Icon:ZV,Clock9:YV,Clock9Icon:YV,ClockAlert:QV,ClockAlertIcon:QV,ClockArrowDown:XV,ClockArrowDownIcon:XV,ClockArrowUp:JV,ClockArrowUpIcon:JV,ClockIcon:mn,Cloud:pH,CloudAlert:eH,CloudAlertIcon:eH,CloudCog:tH,CloudCogIcon:tH,CloudDownload:Jj,CloudDownloadIcon:Jj,CloudDrizzle:sH,CloudDrizzleIcon:sH,CloudFog:rH,CloudFogIcon:rH,CloudHail:nH,CloudHailIcon:nH,CloudIcon:pH,CloudLightning:aH,CloudLightningIcon:aH,CloudMoon:oH,CloudMoonIcon:oH,CloudMoonRain:iH,CloudMoonRainIcon:iH,CloudOff:lH,CloudOffIcon:lH,CloudRain:dH,CloudRainIcon:dH,CloudRainWind:cH,CloudRainWindIcon:cH,CloudSnow:uH,CloudSnowIcon:uH,CloudSun:mH,CloudSunIcon:mH,CloudSunRain:hH,CloudSunRainIcon:hH,CloudUpload:eN,CloudUploadIcon:eN,Cloudy:fH,CloudyIcon:fH,Clover:s1,CloverIcon:s1,Club:xH,ClubIcon:xH,Code:nS,Code2:tN,Code2Icon:tN,CodeIcon:nS,CodeSquare:fk,CodeSquareIcon:fk,CodeXml:tN,CodeXmlIcon:tN,Codepen:gH,CodepenIcon:gH,Codesandbox:yH,CodesandboxIcon:yH,Coffee:aS,CoffeeIcon:aS,Cog:vH,CogIcon:vH,Coins:bL,CoinsIcon:bL,Columns:sN,Columns2:sN,Columns2Icon:sN,Columns3:rN,Columns3Icon:rN,Columns4:bH,Columns4Icon:bH,ColumnsIcon:sN,Combine:_H,CombineIcon:_H,Command:wH,CommandIcon:wH,Compass:d1,CompassIcon:d1,Component:jH,ComponentIcon:jH,Computer:NH,ComputerIcon:NH,ConciergeBell:kH,ConciergeBellIcon:kH,Cone:SH,ConeIcon:SH,Construction:CH,ConstructionIcon:CH,Contact:iS,Contact2:nN,Contact2Icon:nN,ContactIcon:iS,ContactRound:nN,ContactRoundIcon:nN,Container:MH,ContainerIcon:MH,Contrast:TH,ContrastIcon:TH,Cookie:AH,CookieIcon:AH,CookingPot:EH,CookingPotIcon:EH,Copy:yi,CopyCheck:PH,CopyCheckIcon:PH,CopyIcon:yi,CopyMinus:IH,CopyMinusIcon:IH,CopyPlus:LH,CopyPlusIcon:LH,CopySlash:DH,CopySlashIcon:DH,CopyX:OH,CopyXIcon:OH,Copyleft:RH,CopyleftIcon:RH,Copyright:FH,CopyrightIcon:FH,CornerDownLeft:zH,CornerDownLeftIcon:zH,CornerDownRight:BH,CornerDownRightIcon:BH,CornerLeftDown:$H,CornerLeftDownIcon:$H,CornerLeftUp:qH,CornerLeftUpIcon:qH,CornerRightDown:UH,CornerRightDownIcon:UH,CornerRightUp:VH,CornerRightUpIcon:VH,CornerUpLeft:HH,CornerUpLeftIcon:HH,CornerUpRight:GH,CornerUpRightIcon:GH,Cpu:WH,CpuIcon:WH,CreativeCommons:KH,CreativeCommonsIcon:KH,CreditCard:Px,CreditCardIcon:Px,Croissant:ZH,CroissantIcon:ZH,Crop:YH,CropIcon:YH,Cross:QH,CrossIcon:QH,Crosshair:XH,CrosshairIcon:XH,Crown:zm,CrownIcon:zm,Cuboid:JH,CuboidIcon:JH,CupSoda:eG,CupSodaIcon:eG,CurlyBraces:hj,CurlyBracesIcon:hj,Currency:tG,CurrencyIcon:tG,Cylinder:sG,CylinderIcon:sG,Dam:rG,DamIcon:rG,Database:_L,DatabaseBackup:nG,DatabaseBackupIcon:nG,DatabaseIcon:_L,DatabaseZap:aG,DatabaseZapIcon:aG,Delete:iG,DeleteIcon:iG,Dessert:oG,DessertIcon:oG,Diameter:lG,DiameterIcon:lG,Diamond:uG,DiamondIcon:uG,DiamondMinus:cG,DiamondMinusIcon:cG,DiamondPercent:aN,DiamondPercentIcon:aN,DiamondPlus:dG,DiamondPlusIcon:dG,Dice1:hG,Dice1Icon:hG,Dice2:mG,Dice2Icon:mG,Dice3:pG,Dice3Icon:pG,Dice4:fG,Dice4Icon:fG,Dice5:xG,Dice5Icon:xG,Dice6:gG,Dice6Icon:gG,Dices:yG,DicesIcon:yG,Diff:vG,DiffIcon:vG,Disc:jG,Disc2:bG,Disc2Icon:bG,Disc3:_G,Disc3Icon:_G,DiscAlbum:wG,DiscAlbumIcon:wG,DiscIcon:jG,Divide:NG,DivideCircle:Fj,DivideCircleIcon:Fj,DivideIcon:NG,DivideSquare:vk,DivideSquareIcon:vk,Dna:SG,DnaIcon:SG,DnaOff:kG,DnaOffIcon:kG,Dock:CG,DockIcon:CG,Dog:MG,DogIcon:MG,DollarSign:ml,DollarSignIcon:ml,Donut:TG,DonutIcon:TG,DoorClosed:AG,DoorClosedIcon:AG,DoorOpen:u1,DoorOpenIcon:u1,Dot:EG,DotIcon:EG,DotSquare:bk,DotSquareIcon:bk,Download:vi,DownloadCloud:Jj,DownloadCloudIcon:Jj,DownloadIcon:vi,DraftingCompass:PG,DraftingCompassIcon:PG,Drama:IG,DramaIcon:IG,Dribbble:LG,DribbbleIcon:LG,Drill:DG,DrillIcon:DG,Droplet:OG,DropletIcon:OG,Droplets:ey,DropletsIcon:ey,Drum:RG,DrumIcon:RG,Drumstick:FG,DrumstickIcon:FG,Dumbbell:zG,DumbbellIcon:zG,Ear:$G,EarIcon:$G,EarOff:BG,EarOffIcon:BG,Earth:iN,EarthIcon:iN,EarthLock:qG,EarthLockIcon:qG,Eclipse:UG,EclipseIcon:UG,Edit:md,Edit2:r0,Edit2Icon:r0,Edit3:Gv,Edit3Icon:Gv,EditIcon:md,Egg:VM,EggFried:VG,EggFriedIcon:VG,EggIcon:VM,EggOff:HG,EggOffIcon:HG,Ellipsis:bx,EllipsisIcon:bx,EllipsisVertical:vx,EllipsisVerticalIcon:vx,Equal:KG,EqualApproximately:GG,EqualApproximatelyIcon:GG,EqualIcon:KG,EqualNot:WG,EqualNotIcon:WG,EqualSquare:_k,EqualSquareIcon:_k,Eraser:ZG,EraserIcon:ZG,EthernetPort:YG,EthernetPortIcon:YG,Euro:QG,EuroIcon:QG,Expand:wL,ExpandIcon:wL,ExternalLink:rn,ExternalLinkIcon:rn,Eye:Tn,EyeClosed:XG,EyeClosedIcon:XG,EyeIcon:Tn,EyeOff:Cp,EyeOffIcon:Cp,Facebook:Au,FacebookIcon:Au,Factory:JG,FactoryIcon:JG,Fan:eW,FanIcon:eW,FastForward:tW,FastForwardIcon:tW,Feather:sW,FeatherIcon:sW,Fence:rW,FenceIcon:rW,FerrisWheel:nW,FerrisWheelIcon:nW,Figma:aW,FigmaIcon:aW,File:HM,FileArchive:iW,FileArchiveIcon:iW,FileAudio:lW,FileAudio2:oW,FileAudio2Icon:oW,FileAudioIcon:lW,FileAxis3D:oN,FileAxis3DIcon:oN,FileAxis3d:oN,FileAxis3dIcon:oN,FileBadge:dW,FileBadge2:cW,FileBadge2Icon:cW,FileBadgeIcon:dW,FileBarChart:lN,FileBarChart2:cN,FileBarChart2Icon:cN,FileBarChartIcon:lN,FileBox:uW,FileBoxIcon:uW,FileChartColumn:cN,FileChartColumnIcon:cN,FileChartColumnIncreasing:lN,FileChartColumnIncreasingIcon:lN,FileChartLine:dN,FileChartLineIcon:dN,FileChartPie:uN,FileChartPieIcon:uN,FileCheck:mW,FileCheck2:hW,FileCheck2Icon:hW,FileCheckIcon:mW,FileClock:pW,FileClockIcon:pW,FileCode:xW,FileCode2:fW,FileCode2Icon:fW,FileCodeIcon:xW,FileCog:hN,FileCog2:hN,FileCog2Icon:hN,FileCogIcon:hN,FileDiff:gW,FileDiffIcon:gW,FileDigit:yW,FileDigitIcon:yW,FileDown:oS,FileDownIcon:oS,FileEdit:pN,FileEditIcon:pN,FileHeart:vW,FileHeartIcon:vW,FileIcon:HM,FileImage:K_,FileImageIcon:K_,FileInput:bW,FileInputIcon:bW,FileJson:wW,FileJson2:_W,FileJson2Icon:_W,FileJsonIcon:wW,FileKey:NW,FileKey2:jW,FileKey2Icon:jW,FileKeyIcon:NW,FileLineChart:dN,FileLineChartIcon:dN,FileLock:SW,FileLock2:kW,FileLock2Icon:kW,FileLockIcon:SW,FileMinus:MW,FileMinus2:CW,FileMinus2Icon:CW,FileMinusIcon:MW,FileMusic:TW,FileMusicIcon:TW,FileOutput:AW,FileOutputIcon:AW,FilePen:pN,FilePenIcon:pN,FilePenLine:mN,FilePenLineIcon:mN,FilePieChart:uN,FilePieChartIcon:uN,FilePlus:PW,FilePlus2:EW,FilePlus2Icon:EW,FilePlusIcon:PW,FileQuestion:IW,FileQuestionIcon:IW,FileScan:LW,FileScanIcon:LW,FileSearch:OW,FileSearch2:DW,FileSearch2Icon:DW,FileSearchIcon:OW,FileSignature:mN,FileSignatureIcon:mN,FileSliders:RW,FileSlidersIcon:RW,FileSpreadsheet:h1,FileSpreadsheetIcon:h1,FileStack:jL,FileStackIcon:jL,FileSymlink:FW,FileSymlinkIcon:FW,FileTerminal:zW,FileTerminalIcon:zW,FileText:wn,FileTextIcon:wn,FileType:$W,FileType2:BW,FileType2Icon:BW,FileTypeIcon:$W,FileUp:qW,FileUpIcon:qW,FileUser:UW,FileUserIcon:UW,FileVideo:HW,FileVideo2:VW,FileVideo2Icon:VW,FileVideoIcon:HW,FileVolume:WW,FileVolume2:GW,FileVolume2Icon:GW,FileVolumeIcon:WW,FileWarning:KW,FileWarningIcon:KW,FileX:YW,FileX2:ZW,FileX2Icon:ZW,FileXIcon:YW,Files:QW,FilesIcon:QW,Film:_u,FilmIcon:_u,Filter:ty,FilterIcon:ty,FilterX:XW,FilterXIcon:XW,Fingerprint:JW,FingerprintIcon:JW,FireExtinguisher:eK,FireExtinguisherIcon:eK,Fish:rK,FishIcon:rK,FishOff:tK,FishOffIcon:tK,FishSymbol:sK,FishSymbolIcon:sK,Flag:m1,FlagIcon:m1,FlagOff:nK,FlagOffIcon:nK,FlagTriangleLeft:aK,FlagTriangleLeftIcon:aK,FlagTriangleRight:iK,FlagTriangleRightIcon:iK,Flame:rh,FlameIcon:rh,FlameKindling:oK,FlameKindlingIcon:oK,Flashlight:cK,FlashlightIcon:cK,FlashlightOff:lK,FlashlightOffIcon:lK,FlaskConical:Z_,FlaskConicalIcon:Z_,FlaskConicalOff:dK,FlaskConicalOffIcon:dK,FlaskRound:uK,FlaskRoundIcon:uK,FlipHorizontal:NL,FlipHorizontal2:hK,FlipHorizontal2Icon:hK,FlipHorizontalIcon:NL,FlipVertical:pK,FlipVertical2:mK,FlipVertical2Icon:mK,FlipVerticalIcon:pK,Flower:fK,Flower2:Zg,Flower2Icon:Zg,FlowerIcon:fK,Focus:xK,FocusIcon:xK,FoldHorizontal:gK,FoldHorizontalIcon:gK,FoldVertical:yK,FoldVerticalIcon:yK,Folder:HK,FolderArchive:vK,FolderArchiveIcon:vK,FolderCheck:bK,FolderCheckIcon:bK,FolderClock:_K,FolderClockIcon:_K,FolderClosed:wK,FolderClosedIcon:wK,FolderCode:jK,FolderCodeIcon:jK,FolderCog:fN,FolderCog2:fN,FolderCog2Icon:fN,FolderCogIcon:fN,FolderDot:NK,FolderDotIcon:NK,FolderDown:kK,FolderDownIcon:kK,FolderEdit:xN,FolderEditIcon:xN,FolderGit:CK,FolderGit2:SK,FolderGit2Icon:SK,FolderGitIcon:CK,FolderHeart:MK,FolderHeartIcon:MK,FolderIcon:HK,FolderInput:TK,FolderInputIcon:TK,FolderKanban:AK,FolderKanbanIcon:AK,FolderKey:EK,FolderKeyIcon:EK,FolderLock:PK,FolderLockIcon:PK,FolderMinus:IK,FolderMinusIcon:IK,FolderOpen:Bm,FolderOpenDot:LK,FolderOpenDotIcon:LK,FolderOpenIcon:Bm,FolderOutput:DK,FolderOutputIcon:DK,FolderPen:xN,FolderPenIcon:xN,FolderPlus:OK,FolderPlusIcon:OK,FolderRoot:RK,FolderRootIcon:RK,FolderSearch:zK,FolderSearch2:FK,FolderSearch2Icon:FK,FolderSearchIcon:zK,FolderSymlink:BK,FolderSymlinkIcon:BK,FolderSync:$K,FolderSyncIcon:$K,FolderTree:qK,FolderTreeIcon:qK,FolderUp:UK,FolderUpIcon:UK,FolderX:VK,FolderXIcon:VK,Folders:GK,FoldersIcon:GK,Footprints:WK,FootprintsIcon:WK,ForkKnife:i4,ForkKnifeCrossed:a4,ForkKnifeCrossedIcon:a4,ForkKnifeIcon:i4,Forklift:KK,ForkliftIcon:KK,FormInput:$N,FormInputIcon:$N,Forward:ZK,ForwardIcon:ZK,Frame:YK,FrameIcon:YK,Framer:QK,FramerIcon:QK,Frown:XK,FrownIcon:XK,Fuel:JK,FuelIcon:JK,Fullscreen:eZ,FullscreenIcon:eZ,FunctionSquare:wk,FunctionSquareIcon:wk,GalleryHorizontal:sZ,GalleryHorizontalEnd:tZ,GalleryHorizontalEndIcon:tZ,GalleryHorizontalIcon:sZ,GalleryThumbnails:rZ,GalleryThumbnailsIcon:rZ,GalleryVertical:aZ,GalleryVerticalEnd:nZ,GalleryVerticalEndIcon:nZ,GalleryVerticalIcon:aZ,Gamepad:oZ,Gamepad2:iZ,Gamepad2Icon:iZ,GamepadIcon:oZ,GanttChart:jj,GanttChartIcon:jj,GanttChartSquare:Wy,GanttChartSquareIcon:Wy,Gauge:lZ,GaugeCircle:zj,GaugeCircleIcon:zj,GaugeIcon:lZ,Gavel:cZ,GavelIcon:cZ,Gem:dZ,GemIcon:dZ,Ghost:lS,GhostIcon:lS,Gift:bo,GiftIcon:bo,GitBranch:hZ,GitBranchIcon:hZ,GitBranchPlus:uZ,GitBranchPlusIcon:uZ,GitCommit:gN,GitCommitHorizontal:gN,GitCommitHorizontalIcon:gN,GitCommitIcon:gN,GitCommitVertical:mZ,GitCommitVerticalIcon:mZ,GitCompare:fZ,GitCompareArrows:pZ,GitCompareArrowsIcon:pZ,GitCompareIcon:fZ,GitFork:xZ,GitForkIcon:xZ,GitGraph:gZ,GitGraphIcon:gZ,GitMerge:yZ,GitMergeIcon:yZ,GitPullRequest:NZ,GitPullRequestArrow:vZ,GitPullRequestArrowIcon:vZ,GitPullRequestClosed:bZ,GitPullRequestClosedIcon:bZ,GitPullRequestCreate:wZ,GitPullRequestCreateArrow:_Z,GitPullRequestCreateArrowIcon:_Z,GitPullRequestCreateIcon:wZ,GitPullRequestDraft:jZ,GitPullRequestDraftIcon:jZ,GitPullRequestIcon:NZ,Github:kZ,GithubIcon:kZ,Gitlab:SZ,GitlabIcon:SZ,GlassWater:CZ,GlassWaterIcon:CZ,Glasses:MZ,GlassesIcon:MZ,Globe:Nd,Globe2:iN,Globe2Icon:iN,GlobeIcon:Nd,GlobeLock:TZ,GlobeLockIcon:TZ,Goal:AZ,GoalIcon:AZ,Grab:EZ,GrabIcon:EZ,GraduationCap:Qh,GraduationCapIcon:Qh,Grape:PZ,GrapeIcon:PZ,Grid:dx,Grid2X2:vN,Grid2X2Icon:vN,Grid2X2Plus:yN,Grid2X2PlusIcon:yN,Grid2x2:vN,Grid2x2Check:IZ,Grid2x2CheckIcon:IZ,Grid2x2Icon:vN,Grid2x2Plus:yN,Grid2x2PlusIcon:yN,Grid2x2X:LZ,Grid2x2XIcon:LZ,Grid3X3:dx,Grid3X3Icon:dx,Grid3x3:dx,Grid3x3Icon:dx,GridIcon:dx,Grip:OZ,GripHorizontal:DZ,GripHorizontalIcon:DZ,GripIcon:OZ,GripVertical:Eu,GripVerticalIcon:Eu,Group:RZ,GroupIcon:RZ,Guitar:FZ,GuitarIcon:FZ,Ham:zZ,HamIcon:zZ,Hammer:BZ,HammerIcon:BZ,Hand:kL,HandCoins:$Z,HandCoinsIcon:$Z,HandHeart:qZ,HandHeartIcon:qZ,HandHelping:bN,HandHelpingIcon:bN,HandIcon:kL,HandMetal:UZ,HandMetalIcon:UZ,HandPlatter:VZ,HandPlatterIcon:VZ,Handshake:SL,HandshakeIcon:SL,HardDrive:CL,HardDriveDownload:HZ,HardDriveDownloadIcon:HZ,HardDriveIcon:CL,HardDriveUpload:GZ,HardDriveUploadIcon:GZ,HardHat:WZ,HardHatIcon:WZ,Hash:Y_,HashIcon:Y_,Haze:KZ,HazeIcon:KZ,HdmiPort:ZZ,HdmiPortIcon:ZZ,Heading:JZ,Heading1:GM,Heading1Icon:GM,Heading2:WM,Heading2Icon:WM,Heading3:ML,Heading3Icon:ML,Heading4:YZ,Heading4Icon:YZ,Heading5:QZ,Heading5Icon:QZ,Heading6:XZ,Heading6Icon:XZ,HeadingIcon:JZ,HeadphoneOff:eY,HeadphoneOffIcon:eY,Headphones:tY,HeadphonesIcon:tY,Headset:sY,HeadsetIcon:sY,Heart:Ja,HeartCrack:rY,HeartCrackIcon:rY,HeartHandshake:nY,HeartHandshakeIcon:nY,HeartIcon:Ja,HeartOff:aY,HeartOffIcon:aY,HeartPulse:iY,HeartPulseIcon:iY,Heater:oY,HeaterIcon:oY,HelpCircle:Uv,HelpCircleIcon:Uv,HelpingHand:bN,HelpingHandIcon:bN,Hexagon:lY,HexagonIcon:lY,Highlighter:cY,HighlighterIcon:cY,History:KM,HistoryIcon:KM,Home:xn,HomeIcon:xn,Hop:uY,HopIcon:uY,HopOff:dY,HopOffIcon:dY,Hospital:hY,HospitalIcon:hY,Hotel:mY,HotelIcon:mY,Hourglass:pY,HourglassIcon:pY,House:xn,HouseIcon:xn,HousePlug:fY,HousePlugIcon:fY,HousePlus:xY,HousePlusIcon:xY,IceCream:wN,IceCream2:_N,IceCream2Icon:_N,IceCreamBowl:_N,IceCreamBowlIcon:_N,IceCreamCone:wN,IceCreamConeIcon:wN,IceCreamIcon:wN,Icon:Oqe,IdCard:gY,IdCardIcon:gY,Image:bl,ImageDown:yY,ImageDownIcon:yY,ImageIcon:bl,ImageMinus:vY,ImageMinusIcon:vY,ImageOff:bY,ImageOffIcon:bY,ImagePlay:_Y,ImagePlayIcon:_Y,ImagePlus:p1,ImagePlusIcon:p1,ImageUp:wY,ImageUpIcon:wY,ImageUpscale:jY,ImageUpscaleIcon:jY,Images:NY,ImagesIcon:NY,Import:kY,ImportIcon:kY,Inbox:SY,InboxIcon:SY,Indent:NN,IndentDecrease:jN,IndentDecreaseIcon:jN,IndentIcon:NN,IndentIncrease:NN,IndentIncreaseIcon:NN,IndianRupee:CY,IndianRupeeIcon:CY,Infinity:MY,InfinityIcon:MY,Info:cS,InfoIcon:cS,Inspect:Mk,InspectIcon:Mk,InspectionPanel:TY,InspectionPanelIcon:TY,Instagram:Pu,InstagramIcon:Pu,Italic:dS,ItalicIcon:dS,IterationCcw:AY,IterationCcwIcon:AY,IterationCw:EY,IterationCwIcon:EY,JapaneseYen:PY,JapaneseYenIcon:PY,Joystick:IY,JoystickIcon:IY,Kanban:x0,KanbanIcon:x0,KanbanSquare:jk,KanbanSquareDashed:xk,KanbanSquareDashedIcon:xk,KanbanSquareIcon:jk,Key:Mp,KeyIcon:Mp,KeyRound:uS,KeyRoundIcon:uS,KeySquare:LY,KeySquareIcon:LY,Keyboard:RY,KeyboardIcon:RY,KeyboardMusic:DY,KeyboardMusicIcon:DY,KeyboardOff:OY,KeyboardOffIcon:OY,Lamp:UY,LampCeiling:FY,LampCeilingIcon:FY,LampDesk:zY,LampDeskIcon:zY,LampFloor:BY,LampFloorIcon:BY,LampIcon:UY,LampWallDown:$Y,LampWallDownIcon:$Y,LampWallUp:qY,LampWallUpIcon:qY,LandPlot:VY,LandPlotIcon:VY,Landmark:HY,LandmarkIcon:HY,Languages:GY,LanguagesIcon:GY,Laptop:KY,Laptop2:kN,Laptop2Icon:kN,LaptopIcon:KY,LaptopMinimal:kN,LaptopMinimalCheck:WY,LaptopMinimalCheckIcon:WY,LaptopMinimalIcon:kN,Lasso:YY,LassoIcon:YY,LassoSelect:ZY,LassoSelectIcon:ZY,Laugh:QY,LaughIcon:QY,Layers:ZM,Layers2:XY,Layers2Icon:XY,Layers3:JY,Layers3Icon:JY,LayersIcon:ZM,Layout:Hv,LayoutDashboard:hS,LayoutDashboardIcon:hS,LayoutGrid:Tp,LayoutGridIcon:Tp,LayoutIcon:Hv,LayoutList:eQ,LayoutListIcon:eQ,LayoutPanelLeft:tQ,LayoutPanelLeftIcon:tQ,LayoutPanelTop:sQ,LayoutPanelTopIcon:sQ,LayoutTemplate:mS,LayoutTemplateIcon:mS,Leaf:rQ,LeafIcon:rQ,LeafyGreen:nQ,LeafyGreenIcon:nQ,Lectern:aQ,LecternIcon:aQ,LetterText:iQ,LetterTextIcon:iQ,Library:YM,LibraryBig:oQ,LibraryBigIcon:oQ,LibraryIcon:YM,LibrarySquare:Nk,LibrarySquareIcon:Nk,LifeBuoy:QM,LifeBuoyIcon:QM,Ligature:lQ,LigatureIcon:lQ,Lightbulb:Q_,LightbulbIcon:Q_,LightbulbOff:cQ,LightbulbOffIcon:cQ,LineChart:bj,LineChartIcon:bj,Link:Uo,Link2:pl,Link2Icon:pl,Link2Off:dQ,Link2OffIcon:dQ,LinkIcon:Uo,Linkedin:Ap,LinkedinIcon:Ap,List:nh,ListCheck:uQ,ListCheckIcon:uQ,ListChecks:hQ,ListChecksIcon:hQ,ListCollapse:mQ,ListCollapseIcon:mQ,ListEnd:pQ,ListEndIcon:pQ,ListFilter:fQ,ListFilterIcon:fQ,ListIcon:nh,ListMinus:xQ,ListMinusIcon:xQ,ListMusic:gQ,ListMusicIcon:gQ,ListOrdered:g0,ListOrderedIcon:g0,ListPlus:yQ,ListPlusIcon:yQ,ListRestart:vQ,ListRestartIcon:vQ,ListStart:bQ,ListStartIcon:bQ,ListTodo:_Q,ListTodoIcon:_Q,ListTree:wQ,ListTreeIcon:wQ,ListVideo:jQ,ListVideoIcon:jQ,ListX:NQ,ListXIcon:NQ,Loader:SQ,Loader2:ys,Loader2Icon:ys,LoaderCircle:ys,LoaderCircleIcon:ys,LoaderIcon:SQ,LoaderPinwheel:kQ,LoaderPinwheelIcon:kQ,Locate:XM,LocateFixed:CQ,LocateFixedIcon:CQ,LocateIcon:XM,LocateOff:MQ,LocateOffIcon:MQ,Lock:zd,LockIcon:zd,LockKeyhole:TQ,LockKeyholeIcon:TQ,LockKeyholeOpen:SN,LockKeyholeOpenIcon:SN,LockOpen:CN,LockOpenIcon:CN,LogIn:pS,LogInIcon:pS,LogOut:fS,LogOutIcon:fS,Logs:AQ,LogsIcon:AQ,Lollipop:EQ,LollipopIcon:EQ,LucideAArrowDown:B9,LucideAArrowUp:$9,LucideALargeSmall:q9,LucideAccessibility:U9,LucideActivity:Mh,LucideActivitySquare:ZN,LucideAirVent:V9,LucideAirplay:H9,LucideAlarmCheck:X2,LucideAlarmClock:W9,LucideAlarmClockCheck:X2,LucideAlarmClockMinus:J2,LucideAlarmClockOff:G9,LucideAlarmClockPlus:ej,LucideAlarmMinus:J2,LucideAlarmPlus:ej,LucideAlarmSmoke:K9,LucideAlbum:Z9,LucideAlertCircle:ul,LucideAlertOctagon:Vv,LucideAlertTriangle:vd,LucideAlignCenter:Q4,LucideAlignCenterHorizontal:Y9,LucideAlignCenterVertical:Q9,LucideAlignEndHorizontal:X9,LucideAlignEndVertical:J9,LucideAlignHorizontalDistributeCenter:eB,LucideAlignHorizontalDistributeEnd:tB,LucideAlignHorizontalDistributeStart:sB,LucideAlignHorizontalJustifyCenter:rB,LucideAlignHorizontalJustifyEnd:nB,LucideAlignHorizontalJustifyStart:aB,LucideAlignHorizontalSpaceAround:iB,LucideAlignHorizontalSpaceBetween:oB,LucideAlignJustify:lB,LucideAlignLeft:X4,LucideAlignRight:J4,LucideAlignStartHorizontal:cB,LucideAlignStartVertical:dB,LucideAlignVerticalDistributeCenter:uB,LucideAlignVerticalDistributeEnd:hB,LucideAlignVerticalDistributeStart:mB,LucideAlignVerticalJustifyCenter:pB,LucideAlignVerticalJustifyEnd:fB,LucideAlignVerticalJustifyStart:xB,LucideAlignVerticalSpaceAround:gB,LucideAlignVerticalSpaceBetween:yB,LucideAmbulance:vB,LucideAmpersand:bB,LucideAmpersands:_B,LucideAmphora:wB,LucideAnchor:jB,LucideAngry:NB,LucideAnnoyed:kB,LucideAntenna:SB,LucideAnvil:CB,LucideAperture:MB,LucideAppWindow:dL,LucideAppWindowMac:TB,LucideApple:AB,LucideArchive:zM,LucideArchiveRestore:uL,LucideArchiveX:EB,LucideAreaChart:pj,LucideArmchair:PB,LucideArrowBigDown:LB,LucideArrowBigDownDash:IB,LucideArrowBigLeft:OB,LucideArrowBigLeftDash:DB,LucideArrowBigRight:FB,LucideArrowBigRightDash:RB,LucideArrowBigUp:BB,LucideArrowBigUpDash:zB,LucideArrowDown:Yh,LucideArrowDown01:$B,LucideArrowDown10:qB,LucideArrowDownAZ:tj,LucideArrowDownAz:tj,LucideArrowDownCircle:Sj,LucideArrowDownFromLine:UB,LucideArrowDownLeft:VB,LucideArrowDownLeftFromCircle:Mj,LucideArrowDownLeftFromSquare:ek,LucideArrowDownLeftSquare:YN,LucideArrowDownNarrowWide:HB,LucideArrowDownRight:hL,LucideArrowDownRightFromCircle:Tj,LucideArrowDownRightFromSquare:tk,LucideArrowDownRightSquare:QN,LucideArrowDownSquare:XN,LucideArrowDownToDot:GB,LucideArrowDownToLine:WB,LucideArrowDownUp:KB,LucideArrowDownWideNarrow:sj,LucideArrowDownZA:rj,LucideArrowDownZa:rj,LucideArrowLeft:Ga,LucideArrowLeftCircle:Cj,LucideArrowLeftFromLine:ZB,LucideArrowLeftRight:YB,LucideArrowLeftSquare:JN,LucideArrowLeftToLine:QB,LucideArrowRight:ba,LucideArrowRightCircle:Pj,LucideArrowRightFromLine:XB,LucideArrowRightLeft:l1,LucideArrowRightSquare:nk,LucideArrowRightToLine:JB,LucideArrowUp:Tu,LucideArrowUp01:e$,LucideArrowUp10:t$,LucideArrowUpAZ:nj,LucideArrowUpAz:nj,LucideArrowUpCircle:Ij,LucideArrowUpDown:wd,LucideArrowUpFromDot:s$,LucideArrowUpFromLine:r$,LucideArrowUpLeft:n$,LucideArrowUpLeftFromCircle:Aj,LucideArrowUpLeftFromSquare:sk,LucideArrowUpLeftSquare:ak,LucideArrowUpNarrowWide:aj,LucideArrowUpRight:mL,LucideArrowUpRightFromCircle:Ej,LucideArrowUpRightFromSquare:rk,LucideArrowUpRightSquare:ik,LucideArrowUpSquare:ok,LucideArrowUpToLine:a$,LucideArrowUpWideNarrow:i$,LucideArrowUpZA:ij,LucideArrowUpZa:ij,LucideArrowsUpFromLine:o$,LucideAsterisk:l$,LucideAsteriskSquare:lk,LucideAtSign:c$,LucideAtom:d$,LucideAudioLines:u$,LucideAudioWaveform:h$,LucideAward:rc,LucideAxe:m$,LucideAxis3D:oj,LucideAxis3d:oj,LucideBaby:p$,LucideBackpack:f$,LucideBadge:E$,LucideBadgeAlert:x$,LucideBadgeCent:g$,LucideBadgeCheck:lj,LucideBadgeDollarSign:y$,LucideBadgeEuro:v$,LucideBadgeHelp:b$,LucideBadgeIndianRupee:_$,LucideBadgeInfo:w$,LucideBadgeJapaneseYen:j$,LucideBadgeMinus:N$,LucideBadgePercent:k$,LucideBadgePlus:S$,LucideBadgePoundSterling:C$,LucideBadgeRussianRuble:M$,LucideBadgeSwissFranc:T$,LucideBadgeX:A$,LucideBaggageClaim:P$,LucideBan:pL,LucideBanana:I$,LucideBandage:L$,LucideBanknote:D$,LucideBarChart:_j,LucideBarChart2:wj,LucideBarChart3:co,LucideBarChart4:vj,LucideBarChartBig:yj,LucideBarChartHorizontal:xj,LucideBarChartHorizontalBig:fj,LucideBarcode:O$,LucideBaseline:R$,LucideBath:au,LucideBattery:U$,LucideBatteryCharging:F$,LucideBatteryFull:z$,LucideBatteryLow:B$,LucideBatteryMedium:$$,LucideBatteryWarning:q$,LucideBeaker:V$,LucideBean:G$,LucideBeanOff:H$,LucideBed:Th,LucideBedDouble:eS,LucideBedSingle:W$,LucideBeef:K$,LucideBeer:Y$,LucideBeerOff:Z$,LucideBell:Fm,LucideBellDot:Q$,LucideBellElectric:X$,LucideBellMinus:J$,LucideBellOff:c1,LucideBellPlus:eq,LucideBellRing:tq,LucideBetweenHorizonalEnd:cj,LucideBetweenHorizonalStart:dj,LucideBetweenHorizontalEnd:cj,LucideBetweenHorizontalStart:dj,LucideBetweenVerticalEnd:sq,LucideBetweenVerticalStart:rq,LucideBicepsFlexed:nq,LucideBike:aq,LucideBinary:iq,LucideBinoculars:oq,LucideBiohazard:lq,LucideBird:cq,LucideBitcoin:dq,LucideBlend:uq,LucideBlinds:hq,LucideBlocks:mq,LucideBluetooth:gq,LucideBluetoothConnected:pq,LucideBluetoothOff:fq,LucideBluetoothSearching:xq,LucideBold:tS,LucideBolt:yq,LucideBomb:vq,LucideBone:bq,LucideBook:qq,LucideBookA:_q,LucideBookAudio:wq,LucideBookCheck:jq,LucideBookCopy:Nq,LucideBookDashed:uj,LucideBookDown:kq,LucideBookHeadphones:Sq,LucideBookHeart:Cq,LucideBookImage:Mq,LucideBookKey:Tq,LucideBookLock:Aq,LucideBookMarked:Eq,LucideBookMinus:Pq,LucideBookOpen:Ah,LucideBookOpenCheck:Iq,LucideBookOpenText:Lq,LucideBookPlus:Dq,LucideBookTemplate:uj,LucideBookText:Oq,LucideBookType:Rq,LucideBookUp:zq,LucideBookUp2:Fq,LucideBookUser:Bq,LucideBookX:$q,LucideBookmark:Ax,LucideBookmarkCheck:Uq,LucideBookmarkMinus:Vq,LucideBookmarkPlus:fL,LucideBookmarkX:Hq,LucideBoomBox:Gq,LucideBot:BM,LucideBotMessageSquare:Wq,LucideBotOff:Kq,LucideBox:Zq,LucideBoxSelect:yk,LucideBoxes:Yq,LucideBraces:hj,LucideBrackets:Qq,LucideBrain:xL,LucideBrainCircuit:Xq,LucideBrainCog:Jq,LucideBrickWall:eU,LucideBriefcase:sh,LucideBriefcaseBusiness:tU,LucideBriefcaseConveyorBelt:sU,LucideBriefcaseMedical:rU,LucideBringToFront:nU,LucideBrush:aU,LucideBug:lU,LucideBugOff:iU,LucideBugPlay:oU,LucideBuilding:sS,LucideBuilding2:Ta,LucideBus:dU,LucideBusFront:cU,LucideCable:hU,LucideCableCar:uU,LucideCake:Eh,LucideCakeSlice:mU,LucideCalculator:rS,LucideCalendar:fn,LucideCalendar1:pU,LucideCalendarArrowDown:fU,LucideCalendarArrowUp:xU,LucideCalendarCheck:gL,LucideCalendarCheck2:gU,LucideCalendarClock:$M,LucideCalendarCog:yU,LucideCalendarDays:Fd,LucideCalendarFold:vU,LucideCalendarHeart:bU,LucideCalendarMinus:wU,LucideCalendarMinus2:_U,LucideCalendarOff:yL,LucideCalendarPlus:G_,LucideCalendarPlus2:jU,LucideCalendarRange:NU,LucideCalendarSearch:kU,LucideCalendarSync:SU,LucideCalendarX:MU,LucideCalendarX2:CU,LucideCamera:gf,LucideCameraOff:TU,LucideCandlestickChart:gj,LucideCandy:PU,LucideCandyCane:AU,LucideCandyOff:EU,LucideCannabis:IU,LucideCaptions:mj,LucideCaptionsOff:LU,LucideCar:qM,LucideCarFront:DU,LucideCarTaxiFront:OU,LucideCaravan:RU,LucideCarrot:FU,LucideCaseLower:zU,LucideCaseSensitive:BU,LucideCaseUpper:$U,LucideCassetteTape:qU,LucideCast:UU,LucideCastle:VU,LucideCat:HU,LucideCctv:GU,LucideChartArea:pj,LucideChartBar:xj,LucideChartBarBig:fj,LucideChartBarDecreasing:WU,LucideChartBarIncreasing:KU,LucideChartBarStacked:ZU,LucideChartCandlestick:gj,LucideChartColumn:co,LucideChartColumnBig:yj,LucideChartColumnDecreasing:YU,LucideChartColumnIncreasing:vj,LucideChartColumnStacked:QU,LucideChartGantt:XU,LucideChartLine:bj,LucideChartNetwork:JU,LucideChartNoAxesColumn:wj,LucideChartNoAxesColumnDecreasing:eV,LucideChartNoAxesColumnIncreasing:_j,LucideChartNoAxesCombined:tV,LucideChartNoAxesGantt:jj,LucideChartPie:Nj,LucideChartScatter:kj,LucideChartSpline:sV,LucideCheck:ua,LucideCheckCheck:vL,LucideCheckCircle:wi,LucideCheckCircle2:sa,LucideCheckSquare:Wv,LucideCheckSquare2:dk,LucideChefHat:rV,LucideCherry:nV,LucideChevronDown:Ji,LucideChevronDownCircle:Lj,LucideChevronDownSquare:uk,LucideChevronFirst:aV,LucideChevronLast:iV,LucideChevronLeft:tl,LucideChevronLeftCircle:Dj,LucideChevronLeftSquare:hk,LucideChevronRight:da,LucideChevronRightCircle:Oj,LucideChevronRightSquare:mk,LucideChevronUp:Sp,LucideChevronUpCircle:Rj,LucideChevronUpSquare:pk,LucideChevronsDown:lV,LucideChevronsDownUp:oV,LucideChevronsLeft:uV,LucideChevronsLeftRight:dV,LucideChevronsLeftRightEllipsis:cV,LucideChevronsRight:mV,LucideChevronsRightLeft:hV,LucideChevronsUp:pV,LucideChevronsUpDown:Ex,LucideChrome:fV,LucideChurch:xV,LucideCigarette:yV,LucideCigaretteOff:gV,LucideCircle:jd,LucideCircleAlert:ul,LucideCircleArrowDown:Sj,LucideCircleArrowLeft:Cj,LucideCircleArrowOutDownLeft:Mj,LucideCircleArrowOutDownRight:Tj,LucideCircleArrowOutUpLeft:Aj,LucideCircleArrowOutUpRight:Ej,LucideCircleArrowRight:Pj,LucideCircleArrowUp:Ij,LucideCircleCheck:sa,LucideCircleCheckBig:wi,LucideCircleChevronDown:Lj,LucideCircleChevronLeft:Dj,LucideCircleChevronRight:Oj,LucideCircleChevronUp:Rj,LucideCircleDashed:vV,LucideCircleDivide:Fj,LucideCircleDollarSign:bV,LucideCircleDot:wV,LucideCircleDotDashed:_V,LucideCircleEllipsis:jV,LucideCircleEqual:NV,LucideCircleFadingArrowUp:kV,LucideCircleFadingPlus:SV,LucideCircleGauge:zj,LucideCircleHelp:Uv,LucideCircleMinus:Bj,LucideCircleOff:CV,LucideCircleParking:qj,LucideCircleParkingOff:$j,LucideCirclePause:Uj,LucideCirclePercent:Vj,LucideCirclePlay:fp,LucideCirclePlus:Hj,LucideCirclePower:Gj,LucideCircleSlash:MV,LucideCircleSlash2:Wj,LucideCircleSlashed:Wj,LucideCircleStop:Kj,LucideCircleUser:Yj,LucideCircleUserRound:Zj,LucideCircleX:Nc,LucideCircuitBoard:TV,LucideCitrus:AV,LucideClapperboard:EV,LucideClipboard:FV,LucideClipboardCheck:UM,LucideClipboardCopy:PV,LucideClipboardEdit:Xj,LucideClipboardList:W_,LucideClipboardMinus:IV,LucideClipboardPaste:LV,LucideClipboardPen:Xj,LucideClipboardPenLine:Qj,LucideClipboardPlus:DV,LucideClipboardSignature:Qj,LucideClipboardType:OV,LucideClipboardX:RV,LucideClock:mn,LucideClock1:zV,LucideClock10:BV,LucideClock11:$V,LucideClock12:qV,LucideClock2:UV,LucideClock3:VV,LucideClock4:HV,LucideClock5:GV,LucideClock6:WV,LucideClock7:KV,LucideClock8:ZV,LucideClock9:YV,LucideClockAlert:QV,LucideClockArrowDown:XV,LucideClockArrowUp:JV,LucideCloud:pH,LucideCloudAlert:eH,LucideCloudCog:tH,LucideCloudDownload:Jj,LucideCloudDrizzle:sH,LucideCloudFog:rH,LucideCloudHail:nH,LucideCloudLightning:aH,LucideCloudMoon:oH,LucideCloudMoonRain:iH,LucideCloudOff:lH,LucideCloudRain:dH,LucideCloudRainWind:cH,LucideCloudSnow:uH,LucideCloudSun:mH,LucideCloudSunRain:hH,LucideCloudUpload:eN,LucideCloudy:fH,LucideClover:s1,LucideClub:xH,LucideCode:nS,LucideCode2:tN,LucideCodeSquare:fk,LucideCodeXml:tN,LucideCodepen:gH,LucideCodesandbox:yH,LucideCoffee:aS,LucideCog:vH,LucideCoins:bL,LucideColumns:sN,LucideColumns2:sN,LucideColumns3:rN,LucideColumns4:bH,LucideCombine:_H,LucideCommand:wH,LucideCompass:d1,LucideComponent:jH,LucideComputer:NH,LucideConciergeBell:kH,LucideCone:SH,LucideConstruction:CH,LucideContact:iS,LucideContact2:nN,LucideContactRound:nN,LucideContainer:MH,LucideContrast:TH,LucideCookie:AH,LucideCookingPot:EH,LucideCopy:yi,LucideCopyCheck:PH,LucideCopyMinus:IH,LucideCopyPlus:LH,LucideCopySlash:DH,LucideCopyX:OH,LucideCopyleft:RH,LucideCopyright:FH,LucideCornerDownLeft:zH,LucideCornerDownRight:BH,LucideCornerLeftDown:$H,LucideCornerLeftUp:qH,LucideCornerRightDown:UH,LucideCornerRightUp:VH,LucideCornerUpLeft:HH,LucideCornerUpRight:GH,LucideCpu:WH,LucideCreativeCommons:KH,LucideCreditCard:Px,LucideCroissant:ZH,LucideCrop:YH,LucideCross:QH,LucideCrosshair:XH,LucideCrown:zm,LucideCuboid:JH,LucideCupSoda:eG,LucideCurlyBraces:hj,LucideCurrency:tG,LucideCylinder:sG,LucideDam:rG,LucideDatabase:_L,LucideDatabaseBackup:nG,LucideDatabaseZap:aG,LucideDelete:iG,LucideDessert:oG,LucideDiameter:lG,LucideDiamond:uG,LucideDiamondMinus:cG,LucideDiamondPercent:aN,LucideDiamondPlus:dG,LucideDice1:hG,LucideDice2:mG,LucideDice3:pG,LucideDice4:fG,LucideDice5:xG,LucideDice6:gG,LucideDices:yG,LucideDiff:vG,LucideDisc:jG,LucideDisc2:bG,LucideDisc3:_G,LucideDiscAlbum:wG,LucideDivide:NG,LucideDivideCircle:Fj,LucideDivideSquare:vk,LucideDna:SG,LucideDnaOff:kG,LucideDock:CG,LucideDog:MG,LucideDollarSign:ml,LucideDonut:TG,LucideDoorClosed:AG,LucideDoorOpen:u1,LucideDot:EG,LucideDotSquare:bk,LucideDownload:vi,LucideDownloadCloud:Jj,LucideDraftingCompass:PG,LucideDrama:IG,LucideDribbble:LG,LucideDrill:DG,LucideDroplet:OG,LucideDroplets:ey,LucideDrum:RG,LucideDrumstick:FG,LucideDumbbell:zG,LucideEar:$G,LucideEarOff:BG,LucideEarth:iN,LucideEarthLock:qG,LucideEclipse:UG,LucideEdit:md,LucideEdit2:r0,LucideEdit3:Gv,LucideEgg:VM,LucideEggFried:VG,LucideEggOff:HG,LucideEllipsis:bx,LucideEllipsisVertical:vx,LucideEqual:KG,LucideEqualApproximately:GG,LucideEqualNot:WG,LucideEqualSquare:_k,LucideEraser:ZG,LucideEthernetPort:YG,LucideEuro:QG,LucideExpand:wL,LucideExternalLink:rn,LucideEye:Tn,LucideEyeClosed:XG,LucideEyeOff:Cp,LucideFacebook:Au,LucideFactory:JG,LucideFan:eW,LucideFastForward:tW,LucideFeather:sW,LucideFence:rW,LucideFerrisWheel:nW,LucideFigma:aW,LucideFile:HM,LucideFileArchive:iW,LucideFileAudio:lW,LucideFileAudio2:oW,LucideFileAxis3D:oN,LucideFileAxis3d:oN,LucideFileBadge:dW,LucideFileBadge2:cW,LucideFileBarChart:lN,LucideFileBarChart2:cN,LucideFileBox:uW,LucideFileChartColumn:cN,LucideFileChartColumnIncreasing:lN,LucideFileChartLine:dN,LucideFileChartPie:uN,LucideFileCheck:mW,LucideFileCheck2:hW,LucideFileClock:pW,LucideFileCode:xW,LucideFileCode2:fW,LucideFileCog:hN,LucideFileCog2:hN,LucideFileDiff:gW,LucideFileDigit:yW,LucideFileDown:oS,LucideFileEdit:pN,LucideFileHeart:vW,LucideFileImage:K_,LucideFileInput:bW,LucideFileJson:wW,LucideFileJson2:_W,LucideFileKey:NW,LucideFileKey2:jW,LucideFileLineChart:dN,LucideFileLock:SW,LucideFileLock2:kW,LucideFileMinus:MW,LucideFileMinus2:CW,LucideFileMusic:TW,LucideFileOutput:AW,LucideFilePen:pN,LucideFilePenLine:mN,LucideFilePieChart:uN,LucideFilePlus:PW,LucideFilePlus2:EW,LucideFileQuestion:IW,LucideFileScan:LW,LucideFileSearch:OW,LucideFileSearch2:DW,LucideFileSignature:mN,LucideFileSliders:RW,LucideFileSpreadsheet:h1,LucideFileStack:jL,LucideFileSymlink:FW,LucideFileTerminal:zW,LucideFileText:wn,LucideFileType:$W,LucideFileType2:BW,LucideFileUp:qW,LucideFileUser:UW,LucideFileVideo:HW,LucideFileVideo2:VW,LucideFileVolume:WW,LucideFileVolume2:GW,LucideFileWarning:KW,LucideFileX:YW,LucideFileX2:ZW,LucideFiles:QW,LucideFilm:_u,LucideFilter:ty,LucideFilterX:XW,LucideFingerprint:JW,LucideFireExtinguisher:eK,LucideFish:rK,LucideFishOff:tK,LucideFishSymbol:sK,LucideFlag:m1,LucideFlagOff:nK,LucideFlagTriangleLeft:aK,LucideFlagTriangleRight:iK,LucideFlame:rh,LucideFlameKindling:oK,LucideFlashlight:cK,LucideFlashlightOff:lK,LucideFlaskConical:Z_,LucideFlaskConicalOff:dK,LucideFlaskRound:uK,LucideFlipHorizontal:NL,LucideFlipHorizontal2:hK,LucideFlipVertical:pK,LucideFlipVertical2:mK,LucideFlower:fK,LucideFlower2:Zg,LucideFocus:xK,LucideFoldHorizontal:gK,LucideFoldVertical:yK,LucideFolder:HK,LucideFolderArchive:vK,LucideFolderCheck:bK,LucideFolderClock:_K,LucideFolderClosed:wK,LucideFolderCode:jK,LucideFolderCog:fN,LucideFolderCog2:fN,LucideFolderDot:NK,LucideFolderDown:kK,LucideFolderEdit:xN,LucideFolderGit:CK,LucideFolderGit2:SK,LucideFolderHeart:MK,LucideFolderInput:TK,LucideFolderKanban:AK,LucideFolderKey:EK,LucideFolderLock:PK,LucideFolderMinus:IK,LucideFolderOpen:Bm,LucideFolderOpenDot:LK,LucideFolderOutput:DK,LucideFolderPen:xN,LucideFolderPlus:OK,LucideFolderRoot:RK,LucideFolderSearch:zK,LucideFolderSearch2:FK,LucideFolderSymlink:BK,LucideFolderSync:$K,LucideFolderTree:qK,LucideFolderUp:UK,LucideFolderX:VK,LucideFolders:GK,LucideFootprints:WK,LucideForkKnife:i4,LucideForkKnifeCrossed:a4,LucideForklift:KK,LucideFormInput:$N,LucideForward:ZK,LucideFrame:YK,LucideFramer:QK,LucideFrown:XK,LucideFuel:JK,LucideFullscreen:eZ,LucideFunctionSquare:wk,LucideGalleryHorizontal:sZ,LucideGalleryHorizontalEnd:tZ,LucideGalleryThumbnails:rZ,LucideGalleryVertical:aZ,LucideGalleryVerticalEnd:nZ,LucideGamepad:oZ,LucideGamepad2:iZ,LucideGanttChart:jj,LucideGanttChartSquare:Wy,LucideGauge:lZ,LucideGaugeCircle:zj,LucideGavel:cZ,LucideGem:dZ,LucideGhost:lS,LucideGift:bo,LucideGitBranch:hZ,LucideGitBranchPlus:uZ,LucideGitCommit:gN,LucideGitCommitHorizontal:gN,LucideGitCommitVertical:mZ,LucideGitCompare:fZ,LucideGitCompareArrows:pZ,LucideGitFork:xZ,LucideGitGraph:gZ,LucideGitMerge:yZ,LucideGitPullRequest:NZ,LucideGitPullRequestArrow:vZ,LucideGitPullRequestClosed:bZ,LucideGitPullRequestCreate:wZ,LucideGitPullRequestCreateArrow:_Z,LucideGitPullRequestDraft:jZ,LucideGithub:kZ,LucideGitlab:SZ,LucideGlassWater:CZ,LucideGlasses:MZ,LucideGlobe:Nd,LucideGlobe2:iN,LucideGlobeLock:TZ,LucideGoal:AZ,LucideGrab:EZ,LucideGraduationCap:Qh,LucideGrape:PZ,LucideGrid:dx,LucideGrid2X2:vN,LucideGrid2X2Plus:yN,LucideGrid2x2:vN,LucideGrid2x2Check:IZ,LucideGrid2x2Plus:yN,LucideGrid2x2X:LZ,LucideGrid3X3:dx,LucideGrid3x3:dx,LucideGrip:OZ,LucideGripHorizontal:DZ,LucideGripVertical:Eu,LucideGroup:RZ,LucideGuitar:FZ,LucideHam:zZ,LucideHammer:BZ,LucideHand:kL,LucideHandCoins:$Z,LucideHandHeart:qZ,LucideHandHelping:bN,LucideHandMetal:UZ,LucideHandPlatter:VZ,LucideHandshake:SL,LucideHardDrive:CL,LucideHardDriveDownload:HZ,LucideHardDriveUpload:GZ,LucideHardHat:WZ,LucideHash:Y_,LucideHaze:KZ,LucideHdmiPort:ZZ,LucideHeading:JZ,LucideHeading1:GM,LucideHeading2:WM,LucideHeading3:ML,LucideHeading4:YZ,LucideHeading5:QZ,LucideHeading6:XZ,LucideHeadphoneOff:eY,LucideHeadphones:tY,LucideHeadset:sY,LucideHeart:Ja,LucideHeartCrack:rY,LucideHeartHandshake:nY,LucideHeartOff:aY,LucideHeartPulse:iY,LucideHeater:oY,LucideHelpCircle:Uv,LucideHelpingHand:bN,LucideHexagon:lY,LucideHighlighter:cY,LucideHistory:KM,LucideHome:xn,LucideHop:uY,LucideHopOff:dY,LucideHospital:hY,LucideHotel:mY,LucideHourglass:pY,LucideHouse:xn,LucideHousePlug:fY,LucideHousePlus:xY,LucideIceCream:wN,LucideIceCream2:_N,LucideIceCreamBowl:_N,LucideIceCreamCone:wN,LucideIdCard:gY,LucideImage:bl,LucideImageDown:yY,LucideImageMinus:vY,LucideImageOff:bY,LucideImagePlay:_Y,LucideImagePlus:p1,LucideImageUp:wY,LucideImageUpscale:jY,LucideImages:NY,LucideImport:kY,LucideInbox:SY,LucideIndent:NN,LucideIndentDecrease:jN,LucideIndentIncrease:NN,LucideIndianRupee:CY,LucideInfinity:MY,LucideInfo:cS,LucideInspect:Mk,LucideInspectionPanel:TY,LucideInstagram:Pu,LucideItalic:dS,LucideIterationCcw:AY,LucideIterationCw:EY,LucideJapaneseYen:PY,LucideJoystick:IY,LucideKanban:x0,LucideKanbanSquare:jk,LucideKanbanSquareDashed:xk,LucideKey:Mp,LucideKeyRound:uS,LucideKeySquare:LY,LucideKeyboard:RY,LucideKeyboardMusic:DY,LucideKeyboardOff:OY,LucideLamp:UY,LucideLampCeiling:FY,LucideLampDesk:zY,LucideLampFloor:BY,LucideLampWallDown:$Y,LucideLampWallUp:qY,LucideLandPlot:VY,LucideLandmark:HY,LucideLanguages:GY,LucideLaptop:KY,LucideLaptop2:kN,LucideLaptopMinimal:kN,LucideLaptopMinimalCheck:WY,LucideLasso:YY,LucideLassoSelect:ZY,LucideLaugh:QY,LucideLayers:ZM,LucideLayers2:XY,LucideLayers3:JY,LucideLayout:Hv,LucideLayoutDashboard:hS,LucideLayoutGrid:Tp,LucideLayoutList:eQ,LucideLayoutPanelLeft:tQ,LucideLayoutPanelTop:sQ,LucideLayoutTemplate:mS,LucideLeaf:rQ,LucideLeafyGreen:nQ,LucideLectern:aQ,LucideLetterText:iQ,LucideLibrary:YM,LucideLibraryBig:oQ,LucideLibrarySquare:Nk,LucideLifeBuoy:QM,LucideLigature:lQ,LucideLightbulb:Q_,LucideLightbulbOff:cQ,LucideLineChart:bj,LucideLink:Uo,LucideLink2:pl,LucideLink2Off:dQ,LucideLinkedin:Ap,LucideList:nh,LucideListCheck:uQ,LucideListChecks:hQ,LucideListCollapse:mQ,LucideListEnd:pQ,LucideListFilter:fQ,LucideListMinus:xQ,LucideListMusic:gQ,LucideListOrdered:g0,LucideListPlus:yQ,LucideListRestart:vQ,LucideListStart:bQ,LucideListTodo:_Q,LucideListTree:wQ,LucideListVideo:jQ,LucideListX:NQ,LucideLoader:SQ,LucideLoader2:ys,LucideLoaderCircle:ys,LucideLoaderPinwheel:kQ,LucideLocate:XM,LucideLocateFixed:CQ,LucideLocateOff:MQ,LucideLock:zd,LucideLockKeyhole:TQ,LucideLockKeyholeOpen:SN,LucideLockOpen:CN,LucideLogIn:pS,LucideLogOut:fS,LucideLogs:AQ,LucideLollipop:EQ,LucideLuggage:PQ,LucideMSquare:kk,LucideMagnet:IQ,LucideMail:rr,LucideMailCheck:LQ,LucideMailMinus:DQ,LucideMailOpen:OQ,LucideMailPlus:TL,LucideMailQuestion:RQ,LucideMailSearch:FQ,LucideMailWarning:zQ,LucideMailX:AL,LucideMailbox:BQ,LucideMails:$Q,LucideMap:y0,LucideMapPin:aa,LucideMapPinCheck:UQ,LucideMapPinCheckInside:qQ,LucideMapPinHouse:VQ,LucideMapPinMinus:GQ,LucideMapPinMinusInside:HQ,LucideMapPinOff:WQ,LucideMapPinPlus:ZQ,LucideMapPinPlusInside:KQ,LucideMapPinX:QQ,LucideMapPinXInside:YQ,LucideMapPinned:XQ,LucideMartini:JQ,LucideMaximize:xS,LucideMaximize2:eX,LucideMedal:f1,LucideMegaphone:Ph,LucideMegaphoneOff:tX,LucideMeh:sX,LucideMemoryStick:rX,LucideMenu:gS,LucideMenuSquare:Sk,LucideMerge:nX,LucideMessageCircle:Uc,LucideMessageCircleCode:aX,LucideMessageCircleDashed:iX,LucideMessageCircleHeart:JM,LucideMessageCircleMore:oX,LucideMessageCircleOff:lX,LucideMessageCirclePlus:cX,LucideMessageCircleQuestion:EL,LucideMessageCircleReply:dX,LucideMessageCircleWarning:uX,LucideMessageCircleX:hX,LucideMessageSquare:Ki,LucideMessageSquareCode:mX,LucideMessageSquareDashed:pX,LucideMessageSquareDiff:fX,LucideMessageSquareDot:xX,LucideMessageSquareHeart:gX,LucideMessageSquareLock:yX,LucideMessageSquareMore:PL,LucideMessageSquareOff:vX,LucideMessageSquarePlus:eT,LucideMessageSquareQuote:IL,LucideMessageSquareReply:bX,LucideMessageSquareShare:_X,LucideMessageSquareText:wX,LucideMessageSquareWarning:jX,LucideMessageSquareX:NX,LucideMessagesSquare:kX,LucideMic:LL,LucideMic2:MN,LucideMicOff:SX,LucideMicVocal:MN,LucideMicrochip:CX,LucideMicroscope:MX,LucideMicrowave:TX,LucideMilestone:AX,LucideMilk:PX,LucideMilkOff:EX,LucideMinimize:LX,LucideMinimize2:IX,LucideMinus:v0,LucideMinusCircle:Bj,LucideMinusSquare:Ck,LucideMonitor:vS,LucideMonitorCheck:DX,LucideMonitorCog:OX,LucideMonitorDot:RX,LucideMonitorDown:FX,LucideMonitorOff:zX,LucideMonitorPause:BX,LucideMonitorPlay:$X,LucideMonitorSmartphone:qX,LucideMonitorSpeaker:UX,LucideMonitorStop:VX,LucideMonitorUp:yS,LucideMonitorX:HX,LucideMoon:WX,LucideMoonStar:GX,LucideMoreHorizontal:bx,LucideMoreVertical:vx,LucideMountain:DL,LucideMountainSnow:KX,LucideMouse:XX,LucideMouseOff:ZX,LucideMousePointer:kh,LucideMousePointer2:YX,LucideMousePointerBan:QX,LucideMousePointerClick:$m,LucideMousePointerSquareDashed:gk,LucideMove:uJ,LucideMove3D:TN,LucideMove3d:TN,LucideMoveDiagonal:eJ,LucideMoveDiagonal2:JX,LucideMoveDown:rJ,LucideMoveDownLeft:tJ,LucideMoveDownRight:sJ,LucideMoveHorizontal:nJ,LucideMoveLeft:aJ,LucideMoveRight:iJ,LucideMoveUp:cJ,LucideMoveUpLeft:oJ,LucideMoveUpRight:lJ,LucideMoveVertical:dJ,LucideMusic:fJ,LucideMusic2:hJ,LucideMusic3:mJ,LucideMusic4:pJ,LucideNavigation:OL,LucideNavigation2:gJ,LucideNavigation2Off:xJ,LucideNavigationOff:yJ,LucideNetwork:vJ,LucideNewspaper:x1,LucideNfc:bJ,LucideNotebook:NJ,LucideNotebookPen:_J,LucideNotebookTabs:wJ,LucideNotebookText:jJ,LucideNotepadText:SJ,LucideNotepadTextDashed:kJ,LucideNut:MJ,LucideNutOff:CJ,LucideOctagon:AJ,LucideOctagonAlert:Vv,LucideOctagonMinus:TJ,LucideOctagonPause:AN,LucideOctagonX:EN,LucideOmega:EJ,LucideOption:PJ,LucideOrbit:IJ,LucideOrigami:LJ,LucideOutdent:jN,LucidePackage:Al,LucidePackage2:DJ,LucidePackageCheck:OJ,LucidePackageMinus:RJ,LucidePackageOpen:FJ,LucidePackagePlus:zJ,LucidePackageSearch:BJ,LucidePackageX:$J,LucidePaintBucket:qJ,LucidePaintRoller:UJ,LucidePaintbrush:VJ,LucidePaintbrush2:PN,LucidePaintbrushVertical:PN,LucidePalette:$l,LucidePalmtree:Zk,LucidePanelBottom:WJ,LucidePanelBottomClose:HJ,LucidePanelBottomDashed:IN,LucidePanelBottomInactive:IN,LucidePanelBottomOpen:GJ,LucidePanelLeft:RN,LucidePanelLeftClose:LN,LucidePanelLeftDashed:DN,LucidePanelLeftInactive:DN,LucidePanelLeftOpen:ON,LucidePanelRight:YJ,LucidePanelRightClose:KJ,LucidePanelRightDashed:FN,LucidePanelRightInactive:FN,LucidePanelRightOpen:ZJ,LucidePanelTop:JJ,LucidePanelTopClose:QJ,LucidePanelTopDashed:zN,LucidePanelTopInactive:zN,LucidePanelTopOpen:XJ,LucidePanelsLeftBottom:eee,LucidePanelsLeftRight:rN,LucidePanelsRightBottom:tee,LucidePanelsTopBottom:VN,LucidePanelsTopLeft:Hv,LucidePaperclip:bS,LucideParentheses:see,LucideParkingCircle:qj,LucideParkingCircleOff:$j,LucideParkingMeter:ree,LucideParkingSquare:Ak,LucideParkingSquareOff:Tk,LucidePartyPopper:iu,LucidePause:Ih,LucidePauseCircle:Uj,LucidePauseOctagon:AN,LucidePawPrint:nee,LucidePcCase:aee,LucidePen:r0,LucidePenBox:md,LucidePenLine:Gv,LucidePenOff:iee,LucidePenSquare:md,LucidePenTool:X_,LucidePencil:Pa,LucidePencilLine:oee,LucidePencilOff:lee,LucidePencilRuler:cee,LucidePentagon:dee,LucidePercent:_S,LucidePercentCircle:Vj,LucidePercentDiamond:aN,LucidePercentSquare:Ek,LucidePersonStanding:uee,LucidePhilippinePeso:hee,LucidePhone:Nn,LucidePhoneCall:mee,LucidePhoneForwarded:pee,LucidePhoneIncoming:fee,LucidePhoneMissed:xee,LucidePhoneOff:gee,LucidePhoneOutgoing:yee,LucidePi:vee,LucidePiSquare:Pk,LucidePiano:bee,LucidePickaxe:_ee,LucidePictureInPicture:jee,LucidePictureInPicture2:wee,LucidePieChart:Nj,LucidePiggyBank:Nee,LucidePilcrow:Cee,LucidePilcrowLeft:kee,LucidePilcrowRight:See,LucidePilcrowSquare:Ik,LucidePill:Tee,LucidePillBottle:Mee,LucidePin:J_,LucidePinOff:RL,LucidePipette:Aee,LucidePizza:Eee,LucidePlane:Lee,LucidePlaneLanding:Pee,LucidePlaneTakeoff:Iee,LucidePlay:sl,LucidePlayCircle:fp,LucidePlaySquare:Lk,LucidePlug:FL,LucidePlug2:Dee,LucidePlugZap:BN,LucidePlugZap2:BN,LucidePlus:qs,LucidePlusCircle:Hj,LucidePlusSquare:Dk,LucidePocket:Ree,LucidePocketKnife:Oee,LucidePodcast:Fee,LucidePointer:Bee,LucidePointerOff:zee,LucidePopcorn:$ee,LucidePopsicle:qee,LucidePoundSterling:Uee,LucidePower:zL,LucidePowerCircle:Gj,LucidePowerOff:Vee,LucidePowerSquare:Ok,LucidePresentation:sy,LucidePrinter:BL,LucidePrinterCheck:Hee,LucideProjector:Gee,LucideProportions:Wee,LucidePuzzle:Kee,LucidePyramid:Zee,LucideQrCode:b0,LucideQuote:g1,LucideRabbit:Yee,LucideRadar:Qee,LucideRadiation:Xee,LucideRadical:Jee,LucideRadio:y1,LucideRadioReceiver:ete,LucideRadioTower:tte,LucideRadius:ste,LucideRailSymbol:rte,LucideRainbow:nte,LucideRat:ate,LucideRatio:ite,LucideReceipt:fte,LucideReceiptCent:ote,LucideReceiptEuro:lte,LucideReceiptIndianRupee:cte,LucideReceiptJapaneseYen:dte,LucideReceiptPoundSterling:ute,LucideReceiptRussianRuble:hte,LucideReceiptSwissFranc:mte,LucideReceiptText:pte,LucideRectangleEllipsis:$N,LucideRectangleHorizontal:xte,LucideRectangleVertical:gte,LucideRecycle:yte,LucideRedo:wS,LucideRedo2:vte,LucideRedoDot:bte,LucideRefreshCcw:tT,LucideRefreshCcwDot:_te,LucideRefreshCw:zo,LucideRefreshCwOff:wte,LucideRefrigerator:jte,LucideRegex:Nte,LucideRemoveFormatting:kte,LucideRepeat:$L,LucideRepeat1:Ste,LucideRepeat2:Cte,LucideReplace:Tte,LucideReplaceAll:Mte,LucideReply:qL,LucideReplyAll:Ate,LucideRewind:Ete,LucideRibbon:Pte,LucideRocket:_0,LucideRockingChair:Ite,LucideRollerCoaster:Lte,LucideRotate3D:qN,LucideRotate3d:qN,LucideRotateCcw:w0,LucideRotateCcwSquare:Dte,LucideRotateCw:UL,LucideRotateCwSquare:Ote,LucideRoute:Fte,LucideRouteOff:Rte,LucideRouter:zte,LucideRows:UN,LucideRows2:UN,LucideRows3:VN,LucideRows4:Bte,LucideRss:$te,LucideRuler:Ix,LucideRussianRuble:qte,LucideSailboat:Ute,LucideSalad:Vte,LucideSandwich:Hte,LucideSatellite:Wte,LucideSatelliteDish:Gte,LucideSave:Vc,LucideSaveAll:Kte,LucideSaveOff:Zte,LucideScale:VL,LucideScale3D:HN,LucideScale3d:HN,LucideScaling:Yte,LucideScan:nse,LucideScanBarcode:Qte,LucideScanEye:Xte,LucideScanFace:Jte,LucideScanLine:ese,LucideScanQrCode:tse,LucideScanSearch:sse,LucideScanText:rse,LucideScatterChart:kj,LucideSchool:ase,LucideSchool2:Qk,LucideScissors:ose,LucideScissorsLineDashed:ise,LucideScissorsSquare:Rk,LucideScissorsSquareDashedBottom:ck,LucideScreenShare:cse,LucideScreenShareOff:lse,LucideScroll:use,LucideScrollText:dse,LucideSearch:sn,LucideSearchCheck:hse,LucideSearchCode:mse,LucideSearchSlash:pse,LucideSearchX:HL,LucideSection:fse,LucideSend:Fn,LucideSendHorizonal:GN,LucideSendHorizontal:GN,LucideSendToBack:xse,LucideSeparatorHorizontal:gse,LucideSeparatorVertical:yse,LucideServer:wse,LucideServerCog:vse,LucideServerCrash:bse,LucideServerOff:_se,LucideSettings:el,LucideSettings2:GL,LucideShapes:jse,LucideShare:WL,LucideShare2:nd,LucideSheet:Nse,LucideShell:kse,LucideShield:ou,LucideShieldAlert:Sse,LucideShieldBan:Cse,LucideShieldCheck:jS,LucideShieldClose:WN,LucideShieldEllipsis:Mse,LucideShieldHalf:Tse,LucideShieldMinus:Ase,LucideShieldOff:NS,LucideShieldPlus:Ese,LucideShieldQuestion:Pse,LucideShieldX:WN,LucideShip:Lse,LucideShipWheel:Ise,LucideShirt:Dse,LucideShoppingBag:j0,LucideShoppingBasket:Ose,LucideShoppingCart:bp,LucideShovel:Rse,LucideShowerHead:Fse,LucideShrink:zse,LucideShrub:Bse,LucideShuffle:kS,LucideSidebar:RN,LucideSidebarClose:LN,LucideSidebarOpen:ON,LucideSigma:$se,LucideSigmaSquare:Fk,LucideSignal:Gse,LucideSignalHigh:qse,LucideSignalLow:Use,LucideSignalMedium:Vse,LucideSignalZero:Hse,LucideSignature:Wse,LucideSignpost:Zse,LucideSignpostBig:Kse,LucideSiren:Yse,LucideSkipBack:Qse,LucideSkipForward:Xse,LucideSkull:Jse,LucideSlack:ere,LucideSlash:tre,LucideSlashSquare:zk,LucideSlice:sre,LucideSliders:KN,LucideSlidersHorizontal:v1,LucideSlidersVertical:KN,LucideSmartphone:N0,LucideSmartphoneCharging:rre,LucideSmartphoneNfc:nre,LucideSmile:ire,LucideSmilePlus:are,LucideSnail:ore,LucideSnowflake:l0,LucideSofa:lre,LucideSortAsc:aj,LucideSortDesc:sj,LucideSoup:cre,LucideSpace:dre,LucideSpade:ure,LucideSparkle:hre,LucideSparkles:nn,LucideSpeaker:mre,LucideSpeech:pre,LucideSpellCheck:xre,LucideSpellCheck2:fre,LucideSpline:gre,LucideSplit:yre,LucideSplitSquareHorizontal:Bk,LucideSplitSquareVertical:$k,LucideSprayCan:vre,LucideSprout:SS,LucideSquare:k0,LucideSquareActivity:ZN,LucideSquareArrowDown:XN,LucideSquareArrowDownLeft:YN,LucideSquareArrowDownRight:QN,LucideSquareArrowLeft:JN,LucideSquareArrowOutDownLeft:ek,LucideSquareArrowOutDownRight:tk,LucideSquareArrowOutUpLeft:sk,LucideSquareArrowOutUpRight:rk,LucideSquareArrowRight:nk,LucideSquareArrowUp:ok,LucideSquareArrowUpLeft:ak,LucideSquareArrowUpRight:ik,LucideSquareAsterisk:lk,LucideSquareBottomDashedScissors:ck,LucideSquareChartGantt:Wy,LucideSquareCheck:dk,LucideSquareCheckBig:Wv,LucideSquareChevronDown:uk,LucideSquareChevronLeft:hk,LucideSquareChevronRight:mk,LucideSquareChevronUp:pk,LucideSquareCode:fk,LucideSquareDashed:yk,LucideSquareDashedBottom:_re,LucideSquareDashedBottomCode:bre,LucideSquareDashedKanban:xk,LucideSquareDashedMousePointer:gk,LucideSquareDivide:vk,LucideSquareDot:bk,LucideSquareEqual:_k,LucideSquareFunction:wk,LucideSquareGanttChart:Wy,LucideSquareKanban:jk,LucideSquareLibrary:Nk,LucideSquareM:kk,LucideSquareMenu:Sk,LucideSquareMinus:Ck,LucideSquareMousePointer:Mk,LucideSquareParking:Ak,LucideSquareParkingOff:Tk,LucideSquarePen:md,LucideSquarePercent:Ek,LucideSquarePi:Pk,LucideSquarePilcrow:Ik,LucideSquarePlay:Lk,LucideSquarePlus:Dk,LucideSquarePower:Ok,LucideSquareRadical:wre,LucideSquareScissors:Rk,LucideSquareSigma:Fk,LucideSquareSlash:zk,LucideSquareSplitHorizontal:Bk,LucideSquareSplitVertical:$k,LucideSquareSquare:jre,LucideSquareStack:Nre,LucideSquareTerminal:qk,LucideSquareUser:Vk,LucideSquareUserRound:Uk,LucideSquareX:Hk,LucideSquircle:kre,LucideSquirrel:Sre,LucideStamp:Cre,LucideStar:ea,LucideStarHalf:Mre,LucideStarOff:Tre,LucideStars:nn,LucideStepBack:Are,LucideStepForward:Ere,LucideStethoscope:Pre,LucideSticker:Ire,LucideStickyNote:Lre,LucideStopCircle:Kj,LucideStore:sT,LucideStretchHorizontal:Dre,LucideStretchVertical:Ore,LucideStrikethrough:KL,LucideSubscript:Rre,LucideSubtitles:mj,LucideSun:b1,LucideSunDim:Fre,LucideSunMedium:zre,LucideSunMoon:Bre,LucideSunSnow:$re,LucideSunrise:qre,LucideSunset:Ure,LucideSuperscript:Vre,LucideSwatchBook:Hre,LucideSwissFranc:Gre,LucideSwitchCamera:Wre,LucideSword:Kre,LucideSwords:Zre,LucideSyringe:Yre,LucideTable:nT,LucideTable2:rT,LucideTableCellsMerge:Qre,LucideTableCellsSplit:Xre,LucideTableColumnsSplit:Jre,LucideTableOfContents:ene,LucideTableProperties:tne,LucideTableRowsSplit:sne,LucideTablet:nne,LucideTabletSmartphone:rne,LucideTablets:ane,LucideTag:Lh,LucideTags:ine,LucideTally1:one,LucideTally2:lne,LucideTally3:cne,LucideTally4:dne,LucideTally5:une,LucideTangent:hne,LucideTarget:Xh,LucideTelescope:mne,LucideTent:fne,LucideTentTree:pne,LucideTerminal:xne,LucideTerminalSquare:qk,LucideTestTube:gne,LucideTestTube2:Gk,LucideTestTubeDiagonal:Gk,LucideTestTubes:yne,LucideText:jne,LucideTextCursor:bne,LucideTextCursorInput:vne,LucideTextQuote:_ne,LucideTextSearch:wne,LucideTextSelect:Wk,LucideTextSelection:Wk,LucideTheater:Nne,LucideThermometer:ZL,LucideThermometerSnowflake:kne,LucideThermometerSun:Sne,LucideThumbsDown:YL,LucideThumbsUp:ah,LucideTicket:QL,LucideTicketCheck:Cne,LucideTicketMinus:Mne,LucideTicketPercent:Tne,LucideTicketPlus:Ane,LucideTicketSlash:Ene,LucideTicketX:Pne,LucideTickets:Lne,LucideTicketsPlane:Ine,LucideTimer:Rne,LucideTimerOff:Dne,LucideTimerReset:One,LucideToggleLeft:Fne,LucideToggleRight:zne,LucideToilet:Bne,LucideTornado:$ne,LucideTorus:qne,LucideTouchpad:Vne,LucideTouchpadOff:Une,LucideTowerControl:Hne,LucideToyBrick:Gne,LucideTractor:Wne,LucideTrafficCone:Kne,LucideTrain:Kk,LucideTrainFront:Yne,LucideTrainFrontTunnel:Zne,LucideTrainTrack:Qne,LucideTramFront:Kk,LucideTrash:Xne,LucideTrash2:kr,LucideTreeDeciduous:Jne,LucideTreePalm:Zk,LucideTreePine:S0,LucideTrees:eae,LucideTrello:tae,LucideTrendingDown:CS,LucideTrendingUp:Bo,LucideTrendingUpDown:sae,LucideTriangle:nae,LucideTriangleAlert:vd,LucideTriangleRight:rae,LucideTrophy:_o,LucideTruck:aT,LucideTurtle:aae,LucideTv:oae,LucideTv2:Yk,LucideTvMinimal:Yk,LucideTvMinimalPlay:iae,LucideTwitch:lae,LucideTwitter:cae,LucideType:uae,LucideTypeOutline:dae,LucideUmbrella:mae,LucideUmbrellaOff:hae,LucideUnderline:XL,LucideUndo:MS,LucideUndo2:pae,LucideUndoDot:fae,LucideUnfoldHorizontal:xae,LucideUnfoldVertical:gae,LucideUngroup:yae,LucideUniversity:Qk,LucideUnlink:TS,LucideUnlink2:vae,LucideUnlock:CN,LucideUnlockKeyhole:SN,LucideUnplug:bae,LucideUpload:ci,LucideUploadCloud:eN,LucideUsb:_ae,LucideUser:Zi,LucideUser2:r4,LucideUserCheck:ew,LucideUserCheck2:Xk,LucideUserCircle:Yj,LucideUserCircle2:Zj,LucideUserCog:JL,LucideUserCog2:Jk,LucideUserMinus:e8,LucideUserMinus2:e4,LucideUserPen:wae,LucideUserPlus:El,LucideUserPlus2:t4,LucideUserRound:r4,LucideUserRoundCheck:Xk,LucideUserRoundCog:Jk,LucideUserRoundMinus:e4,LucideUserRoundPen:jae,LucideUserRoundPlus:t4,LucideUserRoundSearch:Nae,LucideUserRoundX:s4,LucideUserSearch:kae,LucideUserSquare:Vk,LucideUserSquare2:Uk,LucideUserX:Sae,LucideUserX2:s4,LucideUsers:ur,LucideUsers2:n4,LucideUsersRound:n4,LucideUtensils:i4,LucideUtensilsCrossed:a4,LucideUtilityPole:Cae,LucideVariable:iT,LucideVault:Mae,LucideVegan:Tae,LucideVenetianMask:Aae,LucideVerified:lj,LucideVibrate:Pae,LucideVibrateOff:Eae,LucideVideo:An,LucideVideoOff:Iae,LucideVideotape:Lae,LucideView:Dae,LucideVoicemail:Oae,LucideVolleyball:Rae,LucideVolume:qae,LucideVolume1:Fae,LucideVolume2:zae,LucideVolumeOff:Bae,LucideVolumeX:$ae,LucideVote:Uae,LucideWallet:t8,LucideWallet2:o4,LucideWalletCards:Vae,LucideWalletMinimal:o4,LucideWallpaper:Hae,LucideWand:Gae,LucideWand2:Kv,LucideWandSparkles:Kv,LucideWarehouse:Wae,LucideWashingMachine:Kae,LucideWatch:Zae,LucideWaves:s8,LucideWaypoints:Yae,LucideWebcam:Qae,LucideWebhook:Jae,LucideWebhookOff:Xae,LucideWeight:eie,LucideWheat:sie,LucideWheatOff:tie,LucideWholeWord:rie,LucideWifi:lie,LucideWifiHigh:nie,LucideWifiLow:aie,LucideWifiOff:iie,LucideWifiZero:oie,LucideWind:die,LucideWindArrowDown:cie,LucideWine:hie,LucideWineOff:uie,LucideWorkflow:mie,LucideWorm:pie,LucideWrapText:fie,LucideWrench:ry,LucideX:Er,LucideXCircle:Nc,LucideXOctagon:EN,LucideXSquare:Hk,LucideYoutube:xie,LucideZap:Jh,LucideZapOff:gie,LucideZoomIn:tw,LucideZoomOut:oT,Luggage:PQ,LuggageIcon:PQ,MSquare:kk,MSquareIcon:kk,Magnet:IQ,MagnetIcon:IQ,Mail:rr,MailCheck:LQ,MailCheckIcon:LQ,MailIcon:rr,MailMinus:DQ,MailMinusIcon:DQ,MailOpen:OQ,MailOpenIcon:OQ,MailPlus:TL,MailPlusIcon:TL,MailQuestion:RQ,MailQuestionIcon:RQ,MailSearch:FQ,MailSearchIcon:FQ,MailWarning:zQ,MailWarningIcon:zQ,MailX:AL,MailXIcon:AL,Mailbox:BQ,MailboxIcon:BQ,Mails:$Q,MailsIcon:$Q,Map:y0,MapIcon:y0,MapPin:aa,MapPinCheck:UQ,MapPinCheckIcon:UQ,MapPinCheckInside:qQ,MapPinCheckInsideIcon:qQ,MapPinHouse:VQ,MapPinHouseIcon:VQ,MapPinIcon:aa,MapPinMinus:GQ,MapPinMinusIcon:GQ,MapPinMinusInside:HQ,MapPinMinusInsideIcon:HQ,MapPinOff:WQ,MapPinOffIcon:WQ,MapPinPlus:ZQ,MapPinPlusIcon:ZQ,MapPinPlusInside:KQ,MapPinPlusInsideIcon:KQ,MapPinX:QQ,MapPinXIcon:QQ,MapPinXInside:YQ,MapPinXInsideIcon:YQ,MapPinned:XQ,MapPinnedIcon:XQ,Martini:JQ,MartiniIcon:JQ,Maximize:xS,Maximize2:eX,Maximize2Icon:eX,MaximizeIcon:xS,Medal:f1,MedalIcon:f1,Megaphone:Ph,MegaphoneIcon:Ph,MegaphoneOff:tX,MegaphoneOffIcon:tX,Meh:sX,MehIcon:sX,MemoryStick:rX,MemoryStickIcon:rX,Menu:gS,MenuIcon:gS,MenuSquare:Sk,MenuSquareIcon:Sk,Merge:nX,MergeIcon:nX,MessageCircle:Uc,MessageCircleCode:aX,MessageCircleCodeIcon:aX,MessageCircleDashed:iX,MessageCircleDashedIcon:iX,MessageCircleHeart:JM,MessageCircleHeartIcon:JM,MessageCircleIcon:Uc,MessageCircleMore:oX,MessageCircleMoreIcon:oX,MessageCircleOff:lX,MessageCircleOffIcon:lX,MessageCirclePlus:cX,MessageCirclePlusIcon:cX,MessageCircleQuestion:EL,MessageCircleQuestionIcon:EL,MessageCircleReply:dX,MessageCircleReplyIcon:dX,MessageCircleWarning:uX,MessageCircleWarningIcon:uX,MessageCircleX:hX,MessageCircleXIcon:hX,MessageSquare:Ki,MessageSquareCode:mX,MessageSquareCodeIcon:mX,MessageSquareDashed:pX,MessageSquareDashedIcon:pX,MessageSquareDiff:fX,MessageSquareDiffIcon:fX,MessageSquareDot:xX,MessageSquareDotIcon:xX,MessageSquareHeart:gX,MessageSquareHeartIcon:gX,MessageSquareIcon:Ki,MessageSquareLock:yX,MessageSquareLockIcon:yX,MessageSquareMore:PL,MessageSquareMoreIcon:PL,MessageSquareOff:vX,MessageSquareOffIcon:vX,MessageSquarePlus:eT,MessageSquarePlusIcon:eT,MessageSquareQuote:IL,MessageSquareQuoteIcon:IL,MessageSquareReply:bX,MessageSquareReplyIcon:bX,MessageSquareShare:_X,MessageSquareShareIcon:_X,MessageSquareText:wX,MessageSquareTextIcon:wX,MessageSquareWarning:jX,MessageSquareWarningIcon:jX,MessageSquareX:NX,MessageSquareXIcon:NX,MessagesSquare:kX,MessagesSquareIcon:kX,Mic:LL,Mic2:MN,Mic2Icon:MN,MicIcon:LL,MicOff:SX,MicOffIcon:SX,MicVocal:MN,MicVocalIcon:MN,Microchip:CX,MicrochipIcon:CX,Microscope:MX,MicroscopeIcon:MX,Microwave:TX,MicrowaveIcon:TX,Milestone:AX,MilestoneIcon:AX,Milk:PX,MilkIcon:PX,MilkOff:EX,MilkOffIcon:EX,Minimize:LX,Minimize2:IX,Minimize2Icon:IX,MinimizeIcon:LX,Minus:v0,MinusCircle:Bj,MinusCircleIcon:Bj,MinusIcon:v0,MinusSquare:Ck,MinusSquareIcon:Ck,Monitor:vS,MonitorCheck:DX,MonitorCheckIcon:DX,MonitorCog:OX,MonitorCogIcon:OX,MonitorDot:RX,MonitorDotIcon:RX,MonitorDown:FX,MonitorDownIcon:FX,MonitorIcon:vS,MonitorOff:zX,MonitorOffIcon:zX,MonitorPause:BX,MonitorPauseIcon:BX,MonitorPlay:$X,MonitorPlayIcon:$X,MonitorSmartphone:qX,MonitorSmartphoneIcon:qX,MonitorSpeaker:UX,MonitorSpeakerIcon:UX,MonitorStop:VX,MonitorStopIcon:VX,MonitorUp:yS,MonitorUpIcon:yS,MonitorX:HX,MonitorXIcon:HX,Moon:WX,MoonIcon:WX,MoonStar:GX,MoonStarIcon:GX,MoreHorizontal:bx,MoreHorizontalIcon:bx,MoreVertical:vx,MoreVerticalIcon:vx,Mountain:DL,MountainIcon:DL,MountainSnow:KX,MountainSnowIcon:KX,Mouse:XX,MouseIcon:XX,MouseOff:ZX,MouseOffIcon:ZX,MousePointer:kh,MousePointer2:YX,MousePointer2Icon:YX,MousePointerBan:QX,MousePointerBanIcon:QX,MousePointerClick:$m,MousePointerClickIcon:$m,MousePointerIcon:kh,MousePointerSquareDashed:gk,MousePointerSquareDashedIcon:gk,Move:uJ,Move3D:TN,Move3DIcon:TN,Move3d:TN,Move3dIcon:TN,MoveDiagonal:eJ,MoveDiagonal2:JX,MoveDiagonal2Icon:JX,MoveDiagonalIcon:eJ,MoveDown:rJ,MoveDownIcon:rJ,MoveDownLeft:tJ,MoveDownLeftIcon:tJ,MoveDownRight:sJ,MoveDownRightIcon:sJ,MoveHorizontal:nJ,MoveHorizontalIcon:nJ,MoveIcon:uJ,MoveLeft:aJ,MoveLeftIcon:aJ,MoveRight:iJ,MoveRightIcon:iJ,MoveUp:cJ,MoveUpIcon:cJ,MoveUpLeft:oJ,MoveUpLeftIcon:oJ,MoveUpRight:lJ,MoveUpRightIcon:lJ,MoveVertical:dJ,MoveVerticalIcon:dJ,Music:fJ,Music2:hJ,Music2Icon:hJ,Music3:mJ,Music3Icon:mJ,Music4:pJ,Music4Icon:pJ,MusicIcon:fJ,Navigation:OL,Navigation2:gJ,Navigation2Icon:gJ,Navigation2Off:xJ,Navigation2OffIcon:xJ,NavigationIcon:OL,NavigationOff:yJ,NavigationOffIcon:yJ,Network:vJ,NetworkIcon:vJ,Newspaper:x1,NewspaperIcon:x1,Nfc:bJ,NfcIcon:bJ,Notebook:NJ,NotebookIcon:NJ,NotebookPen:_J,NotebookPenIcon:_J,NotebookTabs:wJ,NotebookTabsIcon:wJ,NotebookText:jJ,NotebookTextIcon:jJ,NotepadText:SJ,NotepadTextDashed:kJ,NotepadTextDashedIcon:kJ,NotepadTextIcon:SJ,Nut:MJ,NutIcon:MJ,NutOff:CJ,NutOffIcon:CJ,Octagon:AJ,OctagonAlert:Vv,OctagonAlertIcon:Vv,OctagonIcon:AJ,OctagonMinus:TJ,OctagonMinusIcon:TJ,OctagonPause:AN,OctagonPauseIcon:AN,OctagonX:EN,OctagonXIcon:EN,Omega:EJ,OmegaIcon:EJ,Option:PJ,OptionIcon:PJ,Orbit:IJ,OrbitIcon:IJ,Origami:LJ,OrigamiIcon:LJ,Outdent:jN,OutdentIcon:jN,Package:Al,Package2:DJ,Package2Icon:DJ,PackageCheck:OJ,PackageCheckIcon:OJ,PackageIcon:Al,PackageMinus:RJ,PackageMinusIcon:RJ,PackageOpen:FJ,PackageOpenIcon:FJ,PackagePlus:zJ,PackagePlusIcon:zJ,PackageSearch:BJ,PackageSearchIcon:BJ,PackageX:$J,PackageXIcon:$J,PaintBucket:qJ,PaintBucketIcon:qJ,PaintRoller:UJ,PaintRollerIcon:UJ,Paintbrush:VJ,Paintbrush2:PN,Paintbrush2Icon:PN,PaintbrushIcon:VJ,PaintbrushVertical:PN,PaintbrushVerticalIcon:PN,Palette:$l,PaletteIcon:$l,Palmtree:Zk,PalmtreeIcon:Zk,PanelBottom:WJ,PanelBottomClose:HJ,PanelBottomCloseIcon:HJ,PanelBottomDashed:IN,PanelBottomDashedIcon:IN,PanelBottomIcon:WJ,PanelBottomInactive:IN,PanelBottomInactiveIcon:IN,PanelBottomOpen:GJ,PanelBottomOpenIcon:GJ,PanelLeft:RN,PanelLeftClose:LN,PanelLeftCloseIcon:LN,PanelLeftDashed:DN,PanelLeftDashedIcon:DN,PanelLeftIcon:RN,PanelLeftInactive:DN,PanelLeftInactiveIcon:DN,PanelLeftOpen:ON,PanelLeftOpenIcon:ON,PanelRight:YJ,PanelRightClose:KJ,PanelRightCloseIcon:KJ,PanelRightDashed:FN,PanelRightDashedIcon:FN,PanelRightIcon:YJ,PanelRightInactive:FN,PanelRightInactiveIcon:FN,PanelRightOpen:ZJ,PanelRightOpenIcon:ZJ,PanelTop:JJ,PanelTopClose:QJ,PanelTopCloseIcon:QJ,PanelTopDashed:zN,PanelTopDashedIcon:zN,PanelTopIcon:JJ,PanelTopInactive:zN,PanelTopInactiveIcon:zN,PanelTopOpen:XJ,PanelTopOpenIcon:XJ,PanelsLeftBottom:eee,PanelsLeftBottomIcon:eee,PanelsLeftRight:rN,PanelsLeftRightIcon:rN,PanelsRightBottom:tee,PanelsRightBottomIcon:tee,PanelsTopBottom:VN,PanelsTopBottomIcon:VN,PanelsTopLeft:Hv,PanelsTopLeftIcon:Hv,Paperclip:bS,PaperclipIcon:bS,Parentheses:see,ParenthesesIcon:see,ParkingCircle:qj,ParkingCircleIcon:qj,ParkingCircleOff:$j,ParkingCircleOffIcon:$j,ParkingMeter:ree,ParkingMeterIcon:ree,ParkingSquare:Ak,ParkingSquareIcon:Ak,ParkingSquareOff:Tk,ParkingSquareOffIcon:Tk,PartyPopper:iu,PartyPopperIcon:iu,Pause:Ih,PauseCircle:Uj,PauseCircleIcon:Uj,PauseIcon:Ih,PauseOctagon:AN,PauseOctagonIcon:AN,PawPrint:nee,PawPrintIcon:nee,PcCase:aee,PcCaseIcon:aee,Pen:r0,PenBox:md,PenBoxIcon:md,PenIcon:r0,PenLine:Gv,PenLineIcon:Gv,PenOff:iee,PenOffIcon:iee,PenSquare:md,PenSquareIcon:md,PenTool:X_,PenToolIcon:X_,Pencil:Pa,PencilIcon:Pa,PencilLine:oee,PencilLineIcon:oee,PencilOff:lee,PencilOffIcon:lee,PencilRuler:cee,PencilRulerIcon:cee,Pentagon:dee,PentagonIcon:dee,Percent:_S,PercentCircle:Vj,PercentCircleIcon:Vj,PercentDiamond:aN,PercentDiamondIcon:aN,PercentIcon:_S,PercentSquare:Ek,PercentSquareIcon:Ek,PersonStanding:uee,PersonStandingIcon:uee,PhilippinePeso:hee,PhilippinePesoIcon:hee,Phone:Nn,PhoneCall:mee,PhoneCallIcon:mee,PhoneForwarded:pee,PhoneForwardedIcon:pee,PhoneIcon:Nn,PhoneIncoming:fee,PhoneIncomingIcon:fee,PhoneMissed:xee,PhoneMissedIcon:xee,PhoneOff:gee,PhoneOffIcon:gee,PhoneOutgoing:yee,PhoneOutgoingIcon:yee,Pi:vee,PiIcon:vee,PiSquare:Pk,PiSquareIcon:Pk,Piano:bee,PianoIcon:bee,Pickaxe:_ee,PickaxeIcon:_ee,PictureInPicture:jee,PictureInPicture2:wee,PictureInPicture2Icon:wee,PictureInPictureIcon:jee,PieChart:Nj,PieChartIcon:Nj,PiggyBank:Nee,PiggyBankIcon:Nee,Pilcrow:Cee,PilcrowIcon:Cee,PilcrowLeft:kee,PilcrowLeftIcon:kee,PilcrowRight:See,PilcrowRightIcon:See,PilcrowSquare:Ik,PilcrowSquareIcon:Ik,Pill:Tee,PillBottle:Mee,PillBottleIcon:Mee,PillIcon:Tee,Pin:J_,PinIcon:J_,PinOff:RL,PinOffIcon:RL,Pipette:Aee,PipetteIcon:Aee,Pizza:Eee,PizzaIcon:Eee,Plane:Lee,PlaneIcon:Lee,PlaneLanding:Pee,PlaneLandingIcon:Pee,PlaneTakeoff:Iee,PlaneTakeoffIcon:Iee,Play:sl,PlayCircle:fp,PlayCircleIcon:fp,PlayIcon:sl,PlaySquare:Lk,PlaySquareIcon:Lk,Plug:FL,Plug2:Dee,Plug2Icon:Dee,PlugIcon:FL,PlugZap:BN,PlugZap2:BN,PlugZap2Icon:BN,PlugZapIcon:BN,Plus:qs,PlusCircle:Hj,PlusCircleIcon:Hj,PlusIcon:qs,PlusSquare:Dk,PlusSquareIcon:Dk,Pocket:Ree,PocketIcon:Ree,PocketKnife:Oee,PocketKnifeIcon:Oee,Podcast:Fee,PodcastIcon:Fee,Pointer:Bee,PointerIcon:Bee,PointerOff:zee,PointerOffIcon:zee,Popcorn:$ee,PopcornIcon:$ee,Popsicle:qee,PopsicleIcon:qee,PoundSterling:Uee,PoundSterlingIcon:Uee,Power:zL,PowerCircle:Gj,PowerCircleIcon:Gj,PowerIcon:zL,PowerOff:Vee,PowerOffIcon:Vee,PowerSquare:Ok,PowerSquareIcon:Ok,Presentation:sy,PresentationIcon:sy,Printer:BL,PrinterCheck:Hee,PrinterCheckIcon:Hee,PrinterIcon:BL,Projector:Gee,ProjectorIcon:Gee,Proportions:Wee,ProportionsIcon:Wee,Puzzle:Kee,PuzzleIcon:Kee,Pyramid:Zee,PyramidIcon:Zee,QrCode:b0,QrCodeIcon:b0,Quote:g1,QuoteIcon:g1,Rabbit:Yee,RabbitIcon:Yee,Radar:Qee,RadarIcon:Qee,Radiation:Xee,RadiationIcon:Xee,Radical:Jee,RadicalIcon:Jee,Radio:y1,RadioIcon:y1,RadioReceiver:ete,RadioReceiverIcon:ete,RadioTower:tte,RadioTowerIcon:tte,Radius:ste,RadiusIcon:ste,RailSymbol:rte,RailSymbolIcon:rte,Rainbow:nte,RainbowIcon:nte,Rat:ate,RatIcon:ate,Ratio:ite,RatioIcon:ite,Receipt:fte,ReceiptCent:ote,ReceiptCentIcon:ote,ReceiptEuro:lte,ReceiptEuroIcon:lte,ReceiptIcon:fte,ReceiptIndianRupee:cte,ReceiptIndianRupeeIcon:cte,ReceiptJapaneseYen:dte,ReceiptJapaneseYenIcon:dte,ReceiptPoundSterling:ute,ReceiptPoundSterlingIcon:ute,ReceiptRussianRuble:hte,ReceiptRussianRubleIcon:hte,ReceiptSwissFranc:mte,ReceiptSwissFrancIcon:mte,ReceiptText:pte,ReceiptTextIcon:pte,RectangleEllipsis:$N,RectangleEllipsisIcon:$N,RectangleHorizontal:xte,RectangleHorizontalIcon:xte,RectangleVertical:gte,RectangleVerticalIcon:gte,Recycle:yte,RecycleIcon:yte,Redo:wS,Redo2:vte,Redo2Icon:vte,RedoDot:bte,RedoDotIcon:bte,RedoIcon:wS,RefreshCcw:tT,RefreshCcwDot:_te,RefreshCcwDotIcon:_te,RefreshCcwIcon:tT,RefreshCw:zo,RefreshCwIcon:zo,RefreshCwOff:wte,RefreshCwOffIcon:wte,Refrigerator:jte,RefrigeratorIcon:jte,Regex:Nte,RegexIcon:Nte,RemoveFormatting:kte,RemoveFormattingIcon:kte,Repeat:$L,Repeat1:Ste,Repeat1Icon:Ste,Repeat2:Cte,Repeat2Icon:Cte,RepeatIcon:$L,Replace:Tte,ReplaceAll:Mte,ReplaceAllIcon:Mte,ReplaceIcon:Tte,Reply:qL,ReplyAll:Ate,ReplyAllIcon:Ate,ReplyIcon:qL,Rewind:Ete,RewindIcon:Ete,Ribbon:Pte,RibbonIcon:Pte,Rocket:_0,RocketIcon:_0,RockingChair:Ite,RockingChairIcon:Ite,RollerCoaster:Lte,RollerCoasterIcon:Lte,Rotate3D:qN,Rotate3DIcon:qN,Rotate3d:qN,Rotate3dIcon:qN,RotateCcw:w0,RotateCcwIcon:w0,RotateCcwSquare:Dte,RotateCcwSquareIcon:Dte,RotateCw:UL,RotateCwIcon:UL,RotateCwSquare:Ote,RotateCwSquareIcon:Ote,Route:Fte,RouteIcon:Fte,RouteOff:Rte,RouteOffIcon:Rte,Router:zte,RouterIcon:zte,Rows:UN,Rows2:UN,Rows2Icon:UN,Rows3:VN,Rows3Icon:VN,Rows4:Bte,Rows4Icon:Bte,RowsIcon:UN,Rss:$te,RssIcon:$te,Ruler:Ix,RulerIcon:Ix,RussianRuble:qte,RussianRubleIcon:qte,Sailboat:Ute,SailboatIcon:Ute,Salad:Vte,SaladIcon:Vte,Sandwich:Hte,SandwichIcon:Hte,Satellite:Wte,SatelliteDish:Gte,SatelliteDishIcon:Gte,SatelliteIcon:Wte,Save:Vc,SaveAll:Kte,SaveAllIcon:Kte,SaveIcon:Vc,SaveOff:Zte,SaveOffIcon:Zte,Scale:VL,Scale3D:HN,Scale3DIcon:HN,Scale3d:HN,Scale3dIcon:HN,ScaleIcon:VL,Scaling:Yte,ScalingIcon:Yte,Scan:nse,ScanBarcode:Qte,ScanBarcodeIcon:Qte,ScanEye:Xte,ScanEyeIcon:Xte,ScanFace:Jte,ScanFaceIcon:Jte,ScanIcon:nse,ScanLine:ese,ScanLineIcon:ese,ScanQrCode:tse,ScanQrCodeIcon:tse,ScanSearch:sse,ScanSearchIcon:sse,ScanText:rse,ScanTextIcon:rse,ScatterChart:kj,ScatterChartIcon:kj,School:ase,School2:Qk,School2Icon:Qk,SchoolIcon:ase,Scissors:ose,ScissorsIcon:ose,ScissorsLineDashed:ise,ScissorsLineDashedIcon:ise,ScissorsSquare:Rk,ScissorsSquareDashedBottom:ck,ScissorsSquareDashedBottomIcon:ck,ScissorsSquareIcon:Rk,ScreenShare:cse,ScreenShareIcon:cse,ScreenShareOff:lse,ScreenShareOffIcon:lse,Scroll:use,ScrollIcon:use,ScrollText:dse,ScrollTextIcon:dse,Search:sn,SearchCheck:hse,SearchCheckIcon:hse,SearchCode:mse,SearchCodeIcon:mse,SearchIcon:sn,SearchSlash:pse,SearchSlashIcon:pse,SearchX:HL,SearchXIcon:HL,Section:fse,SectionIcon:fse,Send:Fn,SendHorizonal:GN,SendHorizonalIcon:GN,SendHorizontal:GN,SendHorizontalIcon:GN,SendIcon:Fn,SendToBack:xse,SendToBackIcon:xse,SeparatorHorizontal:gse,SeparatorHorizontalIcon:gse,SeparatorVertical:yse,SeparatorVerticalIcon:yse,Server:wse,ServerCog:vse,ServerCogIcon:vse,ServerCrash:bse,ServerCrashIcon:bse,ServerIcon:wse,ServerOff:_se,ServerOffIcon:_se,Settings:el,Settings2:GL,Settings2Icon:GL,SettingsIcon:el,Shapes:jse,ShapesIcon:jse,Share:WL,Share2:nd,Share2Icon:nd,ShareIcon:WL,Sheet:Nse,SheetIcon:Nse,Shell:kse,ShellIcon:kse,Shield:ou,ShieldAlert:Sse,ShieldAlertIcon:Sse,ShieldBan:Cse,ShieldBanIcon:Cse,ShieldCheck:jS,ShieldCheckIcon:jS,ShieldClose:WN,ShieldCloseIcon:WN,ShieldEllipsis:Mse,ShieldEllipsisIcon:Mse,ShieldHalf:Tse,ShieldHalfIcon:Tse,ShieldIcon:ou,ShieldMinus:Ase,ShieldMinusIcon:Ase,ShieldOff:NS,ShieldOffIcon:NS,ShieldPlus:Ese,ShieldPlusIcon:Ese,ShieldQuestion:Pse,ShieldQuestionIcon:Pse,ShieldX:WN,ShieldXIcon:WN,Ship:Lse,ShipIcon:Lse,ShipWheel:Ise,ShipWheelIcon:Ise,Shirt:Dse,ShirtIcon:Dse,ShoppingBag:j0,ShoppingBagIcon:j0,ShoppingBasket:Ose,ShoppingBasketIcon:Ose,ShoppingCart:bp,ShoppingCartIcon:bp,Shovel:Rse,ShovelIcon:Rse,ShowerHead:Fse,ShowerHeadIcon:Fse,Shrink:zse,ShrinkIcon:zse,Shrub:Bse,ShrubIcon:Bse,Shuffle:kS,ShuffleIcon:kS,Sidebar:RN,SidebarClose:LN,SidebarCloseIcon:LN,SidebarIcon:RN,SidebarOpen:ON,SidebarOpenIcon:ON,Sigma:$se,SigmaIcon:$se,SigmaSquare:Fk,SigmaSquareIcon:Fk,Signal:Gse,SignalHigh:qse,SignalHighIcon:qse,SignalIcon:Gse,SignalLow:Use,SignalLowIcon:Use,SignalMedium:Vse,SignalMediumIcon:Vse,SignalZero:Hse,SignalZeroIcon:Hse,Signature:Wse,SignatureIcon:Wse,Signpost:Zse,SignpostBig:Kse,SignpostBigIcon:Kse,SignpostIcon:Zse,Siren:Yse,SirenIcon:Yse,SkipBack:Qse,SkipBackIcon:Qse,SkipForward:Xse,SkipForwardIcon:Xse,Skull:Jse,SkullIcon:Jse,Slack:ere,SlackIcon:ere,Slash:tre,SlashIcon:tre,SlashSquare:zk,SlashSquareIcon:zk,Slice:sre,SliceIcon:sre,Sliders:KN,SlidersHorizontal:v1,SlidersHorizontalIcon:v1,SlidersIcon:KN,SlidersVertical:KN,SlidersVerticalIcon:KN,Smartphone:N0,SmartphoneCharging:rre,SmartphoneChargingIcon:rre,SmartphoneIcon:N0,SmartphoneNfc:nre,SmartphoneNfcIcon:nre,Smile:ire,SmileIcon:ire,SmilePlus:are,SmilePlusIcon:are,Snail:ore,SnailIcon:ore,Snowflake:l0,SnowflakeIcon:l0,Sofa:lre,SofaIcon:lre,SortAsc:aj,SortAscIcon:aj,SortDesc:sj,SortDescIcon:sj,Soup:cre,SoupIcon:cre,Space:dre,SpaceIcon:dre,Spade:ure,SpadeIcon:ure,Sparkle:hre,SparkleIcon:hre,Sparkles:nn,SparklesIcon:nn,Speaker:mre,SpeakerIcon:mre,Speech:pre,SpeechIcon:pre,SpellCheck:xre,SpellCheck2:fre,SpellCheck2Icon:fre,SpellCheckIcon:xre,Spline:gre,SplineIcon:gre,Split:yre,SplitIcon:yre,SplitSquareHorizontal:Bk,SplitSquareHorizontalIcon:Bk,SplitSquareVertical:$k,SplitSquareVerticalIcon:$k,SprayCan:vre,SprayCanIcon:vre,Sprout:SS,SproutIcon:SS,Square:k0,SquareActivity:ZN,SquareActivityIcon:ZN,SquareArrowDown:XN,SquareArrowDownIcon:XN,SquareArrowDownLeft:YN,SquareArrowDownLeftIcon:YN,SquareArrowDownRight:QN,SquareArrowDownRightIcon:QN,SquareArrowLeft:JN,SquareArrowLeftIcon:JN,SquareArrowOutDownLeft:ek,SquareArrowOutDownLeftIcon:ek,SquareArrowOutDownRight:tk,SquareArrowOutDownRightIcon:tk,SquareArrowOutUpLeft:sk,SquareArrowOutUpLeftIcon:sk,SquareArrowOutUpRight:rk,SquareArrowOutUpRightIcon:rk,SquareArrowRight:nk,SquareArrowRightIcon:nk,SquareArrowUp:ok,SquareArrowUpIcon:ok,SquareArrowUpLeft:ak,SquareArrowUpLeftIcon:ak,SquareArrowUpRight:ik,SquareArrowUpRightIcon:ik,SquareAsterisk:lk,SquareAsteriskIcon:lk,SquareBottomDashedScissors:ck,SquareBottomDashedScissorsIcon:ck,SquareChartGantt:Wy,SquareChartGanttIcon:Wy,SquareCheck:dk,SquareCheckBig:Wv,SquareCheckBigIcon:Wv,SquareCheckIcon:dk,SquareChevronDown:uk,SquareChevronDownIcon:uk,SquareChevronLeft:hk,SquareChevronLeftIcon:hk,SquareChevronRight:mk,SquareChevronRightIcon:mk,SquareChevronUp:pk,SquareChevronUpIcon:pk,SquareCode:fk,SquareCodeIcon:fk,SquareDashed:yk,SquareDashedBottom:_re,SquareDashedBottomCode:bre,SquareDashedBottomCodeIcon:bre,SquareDashedBottomIcon:_re,SquareDashedIcon:yk,SquareDashedKanban:xk,SquareDashedKanbanIcon:xk,SquareDashedMousePointer:gk,SquareDashedMousePointerIcon:gk,SquareDivide:vk,SquareDivideIcon:vk,SquareDot:bk,SquareDotIcon:bk,SquareEqual:_k,SquareEqualIcon:_k,SquareFunction:wk,SquareFunctionIcon:wk,SquareGanttChart:Wy,SquareGanttChartIcon:Wy,SquareIcon:k0,SquareKanban:jk,SquareKanbanIcon:jk,SquareLibrary:Nk,SquareLibraryIcon:Nk,SquareM:kk,SquareMIcon:kk,SquareMenu:Sk,SquareMenuIcon:Sk,SquareMinus:Ck,SquareMinusIcon:Ck,SquareMousePointer:Mk,SquareMousePointerIcon:Mk,SquareParking:Ak,SquareParkingIcon:Ak,SquareParkingOff:Tk,SquareParkingOffIcon:Tk,SquarePen:md,SquarePenIcon:md,SquarePercent:Ek,SquarePercentIcon:Ek,SquarePi:Pk,SquarePiIcon:Pk,SquarePilcrow:Ik,SquarePilcrowIcon:Ik,SquarePlay:Lk,SquarePlayIcon:Lk,SquarePlus:Dk,SquarePlusIcon:Dk,SquarePower:Ok,SquarePowerIcon:Ok,SquareRadical:wre,SquareRadicalIcon:wre,SquareScissors:Rk,SquareScissorsIcon:Rk,SquareSigma:Fk,SquareSigmaIcon:Fk,SquareSlash:zk,SquareSlashIcon:zk,SquareSplitHorizontal:Bk,SquareSplitHorizontalIcon:Bk,SquareSplitVertical:$k,SquareSplitVerticalIcon:$k,SquareSquare:jre,SquareSquareIcon:jre,SquareStack:Nre,SquareStackIcon:Nre,SquareTerminal:qk,SquareTerminalIcon:qk,SquareUser:Vk,SquareUserIcon:Vk,SquareUserRound:Uk,SquareUserRoundIcon:Uk,SquareX:Hk,SquareXIcon:Hk,Squircle:kre,SquircleIcon:kre,Squirrel:Sre,SquirrelIcon:Sre,Stamp:Cre,StampIcon:Cre,Star:ea,StarHalf:Mre,StarHalfIcon:Mre,StarIcon:ea,StarOff:Tre,StarOffIcon:Tre,Stars:nn,StarsIcon:nn,StepBack:Are,StepBackIcon:Are,StepForward:Ere,StepForwardIcon:Ere,Stethoscope:Pre,StethoscopeIcon:Pre,Sticker:Ire,StickerIcon:Ire,StickyNote:Lre,StickyNoteIcon:Lre,StopCircle:Kj,StopCircleIcon:Kj,Store:sT,StoreIcon:sT,StretchHorizontal:Dre,StretchHorizontalIcon:Dre,StretchVertical:Ore,StretchVerticalIcon:Ore,Strikethrough:KL,StrikethroughIcon:KL,Subscript:Rre,SubscriptIcon:Rre,Subtitles:mj,SubtitlesIcon:mj,Sun:b1,SunDim:Fre,SunDimIcon:Fre,SunIcon:b1,SunMedium:zre,SunMediumIcon:zre,SunMoon:Bre,SunMoonIcon:Bre,SunSnow:$re,SunSnowIcon:$re,Sunrise:qre,SunriseIcon:qre,Sunset:Ure,SunsetIcon:Ure,Superscript:Vre,SuperscriptIcon:Vre,SwatchBook:Hre,SwatchBookIcon:Hre,SwissFranc:Gre,SwissFrancIcon:Gre,SwitchCamera:Wre,SwitchCameraIcon:Wre,Sword:Kre,SwordIcon:Kre,Swords:Zre,SwordsIcon:Zre,Syringe:Yre,SyringeIcon:Yre,Table:nT,Table2:rT,Table2Icon:rT,TableCellsMerge:Qre,TableCellsMergeIcon:Qre,TableCellsSplit:Xre,TableCellsSplitIcon:Xre,TableColumnsSplit:Jre,TableColumnsSplitIcon:Jre,TableIcon:nT,TableOfContents:ene,TableOfContentsIcon:ene,TableProperties:tne,TablePropertiesIcon:tne,TableRowsSplit:sne,TableRowsSplitIcon:sne,Tablet:nne,TabletIcon:nne,TabletSmartphone:rne,TabletSmartphoneIcon:rne,Tablets:ane,TabletsIcon:ane,Tag:Lh,TagIcon:Lh,Tags:ine,TagsIcon:ine,Tally1:one,Tally1Icon:one,Tally2:lne,Tally2Icon:lne,Tally3:cne,Tally3Icon:cne,Tally4:dne,Tally4Icon:dne,Tally5:une,Tally5Icon:une,Tangent:hne,TangentIcon:hne,Target:Xh,TargetIcon:Xh,Telescope:mne,TelescopeIcon:mne,Tent:fne,TentIcon:fne,TentTree:pne,TentTreeIcon:pne,Terminal:xne,TerminalIcon:xne,TerminalSquare:qk,TerminalSquareIcon:qk,TestTube:gne,TestTube2:Gk,TestTube2Icon:Gk,TestTubeDiagonal:Gk,TestTubeDiagonalIcon:Gk,TestTubeIcon:gne,TestTubes:yne,TestTubesIcon:yne,Text:jne,TextCursor:bne,TextCursorIcon:bne,TextCursorInput:vne,TextCursorInputIcon:vne,TextIcon:jne,TextQuote:_ne,TextQuoteIcon:_ne,TextSearch:wne,TextSearchIcon:wne,TextSelect:Wk,TextSelectIcon:Wk,TextSelection:Wk,TextSelectionIcon:Wk,Theater:Nne,TheaterIcon:Nne,Thermometer:ZL,ThermometerIcon:ZL,ThermometerSnowflake:kne,ThermometerSnowflakeIcon:kne,ThermometerSun:Sne,ThermometerSunIcon:Sne,ThumbsDown:YL,ThumbsDownIcon:YL,ThumbsUp:ah,ThumbsUpIcon:ah,Ticket:QL,TicketCheck:Cne,TicketCheckIcon:Cne,TicketIcon:QL,TicketMinus:Mne,TicketMinusIcon:Mne,TicketPercent:Tne,TicketPercentIcon:Tne,TicketPlus:Ane,TicketPlusIcon:Ane,TicketSlash:Ene,TicketSlashIcon:Ene,TicketX:Pne,TicketXIcon:Pne,Tickets:Lne,TicketsIcon:Lne,TicketsPlane:Ine,TicketsPlaneIcon:Ine,Timer:Rne,TimerIcon:Rne,TimerOff:Dne,TimerOffIcon:Dne,TimerReset:One,TimerResetIcon:One,ToggleLeft:Fne,ToggleLeftIcon:Fne,ToggleRight:zne,ToggleRightIcon:zne,Toilet:Bne,ToiletIcon:Bne,Tornado:$ne,TornadoIcon:$ne,Torus:qne,TorusIcon:qne,Touchpad:Vne,TouchpadIcon:Vne,TouchpadOff:Une,TouchpadOffIcon:Une,TowerControl:Hne,TowerControlIcon:Hne,ToyBrick:Gne,ToyBrickIcon:Gne,Tractor:Wne,TractorIcon:Wne,TrafficCone:Kne,TrafficConeIcon:Kne,Train:Kk,TrainFront:Yne,TrainFrontIcon:Yne,TrainFrontTunnel:Zne,TrainFrontTunnelIcon:Zne,TrainIcon:Kk,TrainTrack:Qne,TrainTrackIcon:Qne,TramFront:Kk,TramFrontIcon:Kk,Trash:Xne,Trash2:kr,Trash2Icon:kr,TrashIcon:Xne,TreeDeciduous:Jne,TreeDeciduousIcon:Jne,TreePalm:Zk,TreePalmIcon:Zk,TreePine:S0,TreePineIcon:S0,Trees:eae,TreesIcon:eae,Trello:tae,TrelloIcon:tae,TrendingDown:CS,TrendingDownIcon:CS,TrendingUp:Bo,TrendingUpDown:sae,TrendingUpDownIcon:sae,TrendingUpIcon:Bo,Triangle:nae,TriangleAlert:vd,TriangleAlertIcon:vd,TriangleIcon:nae,TriangleRight:rae,TriangleRightIcon:rae,Trophy:_o,TrophyIcon:_o,Truck:aT,TruckIcon:aT,Turtle:aae,TurtleIcon:aae,Tv:oae,Tv2:Yk,Tv2Icon:Yk,TvIcon:oae,TvMinimal:Yk,TvMinimalIcon:Yk,TvMinimalPlay:iae,TvMinimalPlayIcon:iae,Twitch:lae,TwitchIcon:lae,Twitter:cae,TwitterIcon:cae,Type:uae,TypeIcon:uae,TypeOutline:dae,TypeOutlineIcon:dae,Umbrella:mae,UmbrellaIcon:mae,UmbrellaOff:hae,UmbrellaOffIcon:hae,Underline:XL,UnderlineIcon:XL,Undo:MS,Undo2:pae,Undo2Icon:pae,UndoDot:fae,UndoDotIcon:fae,UndoIcon:MS,UnfoldHorizontal:xae,UnfoldHorizontalIcon:xae,UnfoldVertical:gae,UnfoldVerticalIcon:gae,Ungroup:yae,UngroupIcon:yae,University:Qk,UniversityIcon:Qk,Unlink:TS,Unlink2:vae,Unlink2Icon:vae,UnlinkIcon:TS,Unlock:CN,UnlockIcon:CN,UnlockKeyhole:SN,UnlockKeyholeIcon:SN,Unplug:bae,UnplugIcon:bae,Upload:ci,UploadCloud:eN,UploadCloudIcon:eN,UploadIcon:ci,Usb:_ae,UsbIcon:_ae,User:Zi,User2:r4,User2Icon:r4,UserCheck:ew,UserCheck2:Xk,UserCheck2Icon:Xk,UserCheckIcon:ew,UserCircle:Yj,UserCircle2:Zj,UserCircle2Icon:Zj,UserCircleIcon:Yj,UserCog:JL,UserCog2:Jk,UserCog2Icon:Jk,UserCogIcon:JL,UserIcon:Zi,UserMinus:e8,UserMinus2:e4,UserMinus2Icon:e4,UserMinusIcon:e8,UserPen:wae,UserPenIcon:wae,UserPlus:El,UserPlus2:t4,UserPlus2Icon:t4,UserPlusIcon:El,UserRound:r4,UserRoundCheck:Xk,UserRoundCheckIcon:Xk,UserRoundCog:Jk,UserRoundCogIcon:Jk,UserRoundIcon:r4,UserRoundMinus:e4,UserRoundMinusIcon:e4,UserRoundPen:jae,UserRoundPenIcon:jae,UserRoundPlus:t4,UserRoundPlusIcon:t4,UserRoundSearch:Nae,UserRoundSearchIcon:Nae,UserRoundX:s4,UserRoundXIcon:s4,UserSearch:kae,UserSearchIcon:kae,UserSquare:Vk,UserSquare2:Uk,UserSquare2Icon:Uk,UserSquareIcon:Vk,UserX:Sae,UserX2:s4,UserX2Icon:s4,UserXIcon:Sae,Users:ur,Users2:n4,Users2Icon:n4,UsersIcon:ur,UsersRound:n4,UsersRoundIcon:n4,Utensils:i4,UtensilsCrossed:a4,UtensilsCrossedIcon:a4,UtensilsIcon:i4,UtilityPole:Cae,UtilityPoleIcon:Cae,Variable:iT,VariableIcon:iT,Vault:Mae,VaultIcon:Mae,Vegan:Tae,VeganIcon:Tae,VenetianMask:Aae,VenetianMaskIcon:Aae,Verified:lj,VerifiedIcon:lj,Vibrate:Pae,VibrateIcon:Pae,VibrateOff:Eae,VibrateOffIcon:Eae,Video:An,VideoIcon:An,VideoOff:Iae,VideoOffIcon:Iae,Videotape:Lae,VideotapeIcon:Lae,View:Dae,ViewIcon:Dae,Voicemail:Oae,VoicemailIcon:Oae,Volleyball:Rae,VolleyballIcon:Rae,Volume:qae,Volume1:Fae,Volume1Icon:Fae,Volume2:zae,Volume2Icon:zae,VolumeIcon:qae,VolumeOff:Bae,VolumeOffIcon:Bae,VolumeX:$ae,VolumeXIcon:$ae,Vote:Uae,VoteIcon:Uae,Wallet:t8,Wallet2:o4,Wallet2Icon:o4,WalletCards:Vae,WalletCardsIcon:Vae,WalletIcon:t8,WalletMinimal:o4,WalletMinimalIcon:o4,Wallpaper:Hae,WallpaperIcon:Hae,Wand:Gae,Wand2:Kv,Wand2Icon:Kv,WandIcon:Gae,WandSparkles:Kv,WandSparklesIcon:Kv,Warehouse:Wae,WarehouseIcon:Wae,WashingMachine:Kae,WashingMachineIcon:Kae,Watch:Zae,WatchIcon:Zae,Waves:s8,WavesIcon:s8,Waypoints:Yae,WaypointsIcon:Yae,Webcam:Qae,WebcamIcon:Qae,Webhook:Jae,WebhookIcon:Jae,WebhookOff:Xae,WebhookOffIcon:Xae,Weight:eie,WeightIcon:eie,Wheat:sie,WheatIcon:sie,WheatOff:tie,WheatOffIcon:tie,WholeWord:rie,WholeWordIcon:rie,Wifi:lie,WifiHigh:nie,WifiHighIcon:nie,WifiIcon:lie,WifiLow:aie,WifiLowIcon:aie,WifiOff:iie,WifiOffIcon:iie,WifiZero:oie,WifiZeroIcon:oie,Wind:die,WindArrowDown:cie,WindArrowDownIcon:cie,WindIcon:die,Wine:hie,WineIcon:hie,WineOff:uie,WineOffIcon:uie,Workflow:mie,WorkflowIcon:mie,Worm:pie,WormIcon:pie,WrapText:fie,WrapTextIcon:fie,Wrench:ry,WrenchIcon:ry,X:Er,XCircle:Nc,XCircleIcon:Nc,XIcon:Er,XOctagon:EN,XOctagonIcon:EN,XSquare:Hk,XSquareIcon:Hk,Youtube:xie,YoutubeIcon:xie,Zap:Jh,ZapIcon:Jh,ZapOff:gie,ZapOffIcon:gie,ZoomIn:tw,ZoomInIcon:tw,ZoomOut:oT,ZoomOutIcon:oT,createLucideIcon:Z,icons:kgt},Symbol.toStringTag,{value:"Module"})),P2e="-",Sgt=t=>{const s=Mgt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(P2e);return i[0]===""&&i.length!==1&&i.shift(),Rqe(i,s)||Cgt(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},Rqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?Rqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(P2e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},QAe=/^\[(.+)\]$/,Cgt=t=>{if(QAe.test(t)){const s=QAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Mgt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Agt(Object.entries(t.classGroups),r).forEach(([o,l])=>{Z0e(l,n,o,s)}),n},Z0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:XAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Tgt(a)){Z0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Z0e(l,XAe(s,o),r,n)})})},XAe=(t,s)=>{let r=t;return s.split(P2e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Tgt=t=>t.isThemeGetter,Agt=(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,Egt=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)}}},Fqe="!",Pgt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const c=[];let u=0,m=0,f;for(let j=0;jm?f-m:void 0;return{modifiers:c,hasImportantModifier:y,baseClassName:_,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},Igt=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},Lgt=t=>({cache:Egt(t.cacheSize),parseClassName:Pgt(t),...Sgt(t)}),Dgt=/\s+/,Ogt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Dgt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:m,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:y}=r(u);let _=!!y,w=n(_?g.substring(0,y):g);if(!w){if(!_){i=u+(i.length>0?" "+i:i);continue}if(w=n(g),!w){i=u+(i.length>0?" "+i:i);continue}_=!1}const j=Igt(m).join(":"),N=f?j+Fqe:j,S=N+w;if(o.includes(S))continue;o.push(S);const M=a(w,_);for(let I=0;I0?" "+i:i)}return i};function Rgt(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(m),t());return r=Lgt(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 m=Ogt(c,r);return a(c,m),m}return function(){return o(Rgt.apply(null,arguments))}}const gc=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},Bqe=/^\[(?:([a-z-]+):)?(.+)\]$/i,zgt=/^\d+\/\d+$/,Bgt=new Set(["px","full","screen"]),$gt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qgt=/\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$/,Ugt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Vgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Hgt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Cv=t=>lT(t)||Bgt.has(t)||zgt.test(t),Fb=t=>tE(t,"length",Jgt),lT=t=>!!t&&!Number.isNaN(Number(t)),mxe=t=>tE(t,"number",lT),sI=t=>!!t&&Number.isInteger(Number(t)),Ggt=t=>t.endsWith("%")&&lT(t.slice(0,-1)),Xi=t=>Bqe.test(t),zb=t=>$gt.test(t),Wgt=new Set(["length","size","percentage"]),Kgt=t=>tE(t,Wgt,$qe),Zgt=t=>tE(t,"position",$qe),Ygt=new Set(["image","url"]),Qgt=t=>tE(t,Ygt,tyt),Xgt=t=>tE(t,"",eyt),rI=()=>!0,tE=(t,s,r)=>{const n=Bqe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Jgt=t=>qgt.test(t)&&!Ugt.test(t),$qe=()=>!1,eyt=t=>Vgt.test(t),tyt=t=>Hgt.test(t),syt=()=>{const t=gc("colors"),s=gc("spacing"),r=gc("blur"),n=gc("brightness"),a=gc("borderColor"),o=gc("borderRadius"),l=gc("borderSpacing"),i=gc("borderWidth"),c=gc("contrast"),u=gc("grayscale"),m=gc("hueRotate"),f=gc("invert"),g=gc("gap"),y=gc("gradientColorStops"),_=gc("gradientColorStopPositions"),w=gc("inset"),j=gc("margin"),N=gc("opacity"),S=gc("padding"),M=gc("saturate"),I=gc("scale"),P=gc("sepia"),O=gc("skew"),q=gc("space"),$=gc("translate"),z=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",Xi,s],Y=()=>[Xi,s],J=()=>["",Cv,Fb],Q=()=>["auto",lT,Xi],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>["start","end","center","between","around","evenly","stretch"],he=()=>["","0",Xi],xe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ue=()=>[lT,Xi];return{cacheSize:500,separator:":",theme:{colors:[rI],spacing:[Cv,Fb],blur:["none","",zb,Xi],brightness:ue(),borderColor:[t],borderRadius:["none","","full",zb,Xi],borderSpacing:Y(),borderWidth:J(),contrast:ue(),grayscale:he(),hueRotate:ue(),invert:he(),gap:Y(),gradientColorStops:[t],gradientColorStopPositions:[Ggt,Fb],inset:X(),margin:X(),opacity:ue(),padding:Y(),saturate:ue(),scale:ue(),sepia:he(),skew:ue(),space:Y(),translate:Y()},classGroups:{aspect:[{aspect:["auto","square","video",Xi]}],container:["container"],columns:[{columns:[zb]}],"break-after":[{"break-after":xe()}],"break-before":[{"break-before":xe()}],"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:[...ce(),Xi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",sI,Xi]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Xi]}],grow:[{grow:he()}],shrink:[{shrink:he()}],order:[{order:["first","last","none",sI,Xi]}],"grid-cols":[{"grid-cols":[rI]}],"col-start-end":[{col:["auto",{span:["full",sI,Xi]},Xi]}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":[rI]}],"row-start-end":[{row:["auto",{span:[sI,Xi]},Xi]}],"row-start":[{"row-start":Q()}],"row-end":[{"row-end":Q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Xi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Xi]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...oe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...oe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...oe(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[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",Xi,s]}],"min-w":[{"min-w":[Xi,s,"min","max","fit"]}],"max-w":[{"max-w":[Xi,s,"none","full","min","max","fit","prose",{screen:[zb]},zb]}],h:[{h:[Xi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Xi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Xi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Xi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",zb,Fb]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",mxe]}],"font-family":[{font:[rI]}],"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",Xi]}],"line-clamp":[{"line-clamp":["none",lT,mxe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Cv,Xi]}],"list-image":[{"list-image":["none",Xi]}],"list-style-type":[{list:["none","disc","decimal",Xi]}],"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:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Cv,Fb]}],"underline-offset":[{"underline-offset":["auto",Cv,Xi]}],"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:Y()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Xi]}],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",Xi]}],"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:[...ce(),Zgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Kgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Qgt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[y]}],"gradient-via":[{via:[y]}],"gradient-to":[{to:[y]}],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:[...ne(),"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:ne()}],"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:["",...ne()]}],"outline-offset":[{"outline-offset":[Cv,Xi]}],"outline-w":[{outline:[Cv,Fb]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[Cv,Fb]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",zb,Xgt]}],"shadow-color":[{shadow:[rI]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",zb,Xi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[m]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[P]}],"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":[m]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"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",Xi]}],duration:[{duration:ue()}],ease:[{ease:["linear","in","out","in-out",Xi]}],delay:[{delay:ue()}],animate:[{animate:["none","spin","ping","pulse","bounce",Xi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[sI,Xi]}],"translate-x":[{"translate-x":[$]}],"translate-y":[{"translate-y":[$]}],"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",Xi]}],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",Xi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Y()}],"scroll-mx":[{"scroll-mx":Y()}],"scroll-my":[{"scroll-my":Y()}],"scroll-ms":[{"scroll-ms":Y()}],"scroll-me":[{"scroll-me":Y()}],"scroll-mt":[{"scroll-mt":Y()}],"scroll-mr":[{"scroll-mr":Y()}],"scroll-mb":[{"scroll-mb":Y()}],"scroll-ml":[{"scroll-ml":Y()}],"scroll-p":[{"scroll-p":Y()}],"scroll-px":[{"scroll-px":Y()}],"scroll-py":[{"scroll-py":Y()}],"scroll-ps":[{"scroll-ps":Y()}],"scroll-pe":[{"scroll-pe":Y()}],"scroll-pt":[{"scroll-pt":Y()}],"scroll-pr":[{"scroll-pr":Y()}],"scroll-pb":[{"scroll-pb":Y()}],"scroll-pl":[{"scroll-pl":Y()}],"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",Xi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Cv,Fb,mxe]}],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"]}}},ryt=Fgt(syt);function Pt(...t){return ryt(Hi(t))}function ec(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 JAe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Ode(t){return t?t.replace(/<[^>]*>/g,""):""}const nyt=wgt,qqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Mqe,{ref:r,className:Pt("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));qqe.displayName=Mqe.displayName;const ayt=S3("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"}}),Uqe=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(Tqe,{ref:n,className:Pt(ayt({variant:s}),t),...r}));Uqe.displayName=Tqe.displayName;const iyt=k.forwardRef(({className:t,...s},r)=>e.jsx(Pqe,{ref:r,className:Pt("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));iyt.displayName=Pqe.displayName;const Vqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Iqe,{ref:r,className:Pt("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Er,{className:"h-4 w-4"})}));Vqe.displayName=Iqe.displayName;const Hqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Aqe,{ref:r,className:Pt("text-sm font-semibold",t),...s}));Hqe.displayName=Aqe.displayName;const Gqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Eqe,{ref:r,className:Pt("text-sm opacity-90",t),...s}));Gqe.displayName=Eqe.displayName;function oyt(){const{toasts:t}=Ra();return e.jsxs(nyt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(Uqe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(Hqe,{children:r}),n&&e.jsx(Gqe,{children:n})]}),a,e.jsx(Vqe,{})]},s)}),e.jsx(qqe,{})]})}var eEe=["light","dark"],lyt="(prefers-color-scheme: dark)",cyt=k.createContext(void 0),dyt={setTheme:t=>{},themes:[]},uyt=()=>{var t;return(t=k.useContext(cyt))!=null?t:dyt};k.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:c})=>{let u=o==="system",m=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?eEe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(_,w=!1,j=!0)=>{let N=l?l[_]:_,S=w?_+"|| ''":`'${N}'`,M="";return a&&j&&!w&&eEe.includes(_)&&(M+=`d.style.colorScheme = '${_}';`),r==="class"?w||N?M+=`c.add(${S})`:M+="null":N&&(M+=`d[s](n,${S})`),M},y=t?`!function(){${m}${g(t)}}()`:n?`!function(){try{${m}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${lyt}',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{${m}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:y}})});var hyt=t=>{switch(t){case"success":return fyt;case"info":return gyt;case"warning":return xyt;case"error":return yyt;default:return null}},myt=Array(12).fill(0),pyt=({visible:t,className:s})=>mt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},mt.createElement("div",{className:"sonner-spinner"},myt.map((r,n)=>mt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),fyt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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"})),xyt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},mt.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"})),gyt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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"})),yyt=mt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},mt.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"})),vyt=mt.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"},mt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),mt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),byt=()=>{let[t,s]=mt.useState(document.hidden);return mt.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Y0e=1,_yt=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:Y0e++,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],mt.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(jyt(u)&&!u.ok){o=!1;let m=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:m,description:f})}else if(r.success!==void 0){o=!1;let m=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:m,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let m=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:m,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),c=()=>new Promise((u,m)=>i.then(()=>l[0]==="reject"?m(l[1]):u(l[1])).catch(m));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)||Y0e++;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}},hp=new _yt,wyt=(t,s)=>{let r=(s==null?void 0:s.id)||Y0e++;return hp.addToast({title:t,...s,id:r}),r},jyt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Nyt=wyt,kyt=()=>hp.toasts,Syt=()=>hp.getActiveToasts(),me=Object.assign(Nyt,{success:hp.success,info:hp.info,warning:hp.warning,error:hp.error,custom:hp.custom,message:hp.message,promise:hp.promise,dismiss:hp.dismiss,loading:hp.loading},{getHistory:kyt,getToasts:Syt});function Cyt(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))}Cyt(`: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 tz(t){return t.label!==void 0}var Myt=3,Tyt="32px",Ayt="16px",tEe=4e3,Eyt=356,Pyt=14,Iyt=20,Lyt=200;function Cg(...t){return t.filter(Boolean).join(" ")}function Dyt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Oyt=t=>{var s,r,n,a,o,l,i,c,u,m,f;let{invert:g,toast:y,unstyled:_,interacting:w,setHeights:j,visibleToasts:N,heights:S,index:M,toasts:I,expanded:P,removeToast:O,defaultRichColors:q,closeButton:$,style:z,cancelButtonStyle:V,actionButtonStyle:X,className:Y="",descriptionClassName:J="",duration:Q,position:ce,gap:ne,loadingIcon:re,expandByDefault:oe,classNames:he,icons:xe,closeButtonAriaLabel:ue="Close toast",pauseWhenPageIsHidden:ge}=t,[_e,Be]=mt.useState(null),[Se,Ee]=mt.useState(null),[Ae,Me]=mt.useState(!1),[ke,Oe]=mt.useState(!1),[qe,ve]=mt.useState(!1),[dt,pe]=mt.useState(!1),[Ue,Xe]=mt.useState(!1),[et,Ce]=mt.useState(0),[Je,Ge]=mt.useState(0),lt=mt.useRef(y.duration||Q||tEe),He=mt.useRef(null),We=mt.useRef(null),tt=M===0,Ke=M+1<=N,rt=y.type,it=y.dismissible!==!1,It=y.className||"",Vt=y.descriptionClassName||"",hs=mt.useMemo(()=>S.findIndex(Sr=>Sr.toastId===y.id)||0,[S,y.id]),Es=mt.useMemo(()=>{var Sr;return(Sr=y.closeButton)!=null?Sr:$},[y.closeButton,$]),Ts=mt.useMemo(()=>y.duration||Q||tEe,[y.duration,Q]),cr=mt.useRef(0),zr=mt.useRef(0),Ft=mt.useRef(0),Ps=mt.useRef(null),[yr,Is]=ce.split("-"),Ar=mt.useMemo(()=>S.reduce((Sr,dn,Yr)=>Yr>=hs?Sr:Sr+dn.height,0),[S,hs]),tn=byt(),na=y.invert||g,Ln=rt==="loading";zr.current=mt.useMemo(()=>hs*ne+Ar,[hs,Ar]),mt.useEffect(()=>{lt.current=Ts},[Ts]),mt.useEffect(()=>{Me(!0)},[]),mt.useEffect(()=>{let Sr=We.current;if(Sr){let dn=Sr.getBoundingClientRect().height;return Ge(dn),j(Yr=>[{toastId:y.id,height:dn,position:y.position},...Yr]),()=>j(Yr=>Yr.filter(ui=>ui.toastId!==y.id))}},[j,y.id]),mt.useLayoutEffect(()=>{if(!Ae)return;let Sr=We.current,dn=Sr.style.height;Sr.style.height="auto";let Yr=Sr.getBoundingClientRect().height;Sr.style.height=dn,Ge(Yr),j(ui=>ui.find(ns=>ns.toastId===y.id)?ui.map(ns=>ns.toastId===y.id?{...ns,height:Yr}:ns):[{toastId:y.id,height:Yr,position:y.position},...ui])},[Ae,y.title,y.description,j,y.id]);let tr=mt.useCallback(()=>{Oe(!0),Ce(zr.current),j(Sr=>Sr.filter(dn=>dn.toastId!==y.id)),setTimeout(()=>{O(y)},Lyt)},[y,O,j,zr]);mt.useEffect(()=>{if(y.promise&&rt==="loading"||y.duration===1/0||y.type==="loading")return;let Sr;return P||w||ge&&tn?(()=>{if(Ft.current{var dn;(dn=y.onAutoClose)==null||dn.call(y,y),tr()},lt.current)),()=>clearTimeout(Sr)},[P,w,y,rt,ge,tn,tr]),mt.useEffect(()=>{y.delete&&tr()},[tr,y.delete]);function dr(){var Sr,dn,Yr;return xe!=null&&xe.loading?mt.createElement("div",{className:Cg(he==null?void 0:he.loader,(Sr=y==null?void 0:y.classNames)==null?void 0:Sr.loader,"sonner-loader"),"data-visible":rt==="loading"},xe.loading):re?mt.createElement("div",{className:Cg(he==null?void 0:he.loader,(dn=y==null?void 0:y.classNames)==null?void 0:dn.loader,"sonner-loader"),"data-visible":rt==="loading"},re):mt.createElement(pyt,{className:Cg(he==null?void 0:he.loader,(Yr=y==null?void 0:y.classNames)==null?void 0:Yr.loader),visible:rt==="loading"})}return mt.createElement("li",{tabIndex:0,ref:We,className:Cg(Y,It,he==null?void 0:he.toast,(s=y==null?void 0:y.classNames)==null?void 0:s.toast,he==null?void 0:he.default,he==null?void 0:he[rt],(r=y==null?void 0:y.classNames)==null?void 0:r[rt]),"data-sonner-toast":"","data-rich-colors":(n=y.richColors)!=null?n:q,"data-styled":!(y.jsx||y.unstyled||_),"data-mounted":Ae,"data-promise":!!y.promise,"data-swiped":Ue,"data-removed":ke,"data-visible":Ke,"data-y-position":yr,"data-x-position":Is,"data-index":M,"data-front":tt,"data-swiping":qe,"data-dismissible":it,"data-type":rt,"data-invert":na,"data-swipe-out":dt,"data-swipe-direction":Se,"data-expanded":!!(P||oe&&Ae),style:{"--index":M,"--toasts-before":M,"--z-index":I.length-M,"--offset":`${ke?et:zr.current}px`,"--initial-height":oe?"auto":`${Je}px`,...z,...y.style},onDragEnd:()=>{ve(!1),Be(null),Ps.current=null},onPointerDown:Sr=>{Ln||!it||(He.current=new Date,Ce(zr.current),Sr.target.setPointerCapture(Sr.pointerId),Sr.target.tagName!=="BUTTON"&&(ve(!0),Ps.current={x:Sr.clientX,y:Sr.clientY}))},onPointerUp:()=>{var Sr,dn,Yr,ui;if(dt||!it)return;Ps.current=null;let ns=Number(((Sr=We.current)==null?void 0:Sr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Wt=Number(((dn=We.current)==null?void 0:dn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Hr=new Date().getTime()-((Yr=He.current)==null?void 0:Yr.getTime()),Mr=_e==="x"?ns:Wt,xr=Math.abs(Mr)/Hr;if(Math.abs(Mr)>=Iyt||xr>.11){Ce(zr.current),(ui=y.onDismiss)==null||ui.call(y,y),Ee(_e==="x"?ns>0?"right":"left":Wt>0?"down":"up"),tr(),pe(!0),Xe(!1);return}ve(!1),Be(null)},onPointerMove:Sr=>{var dn,Yr,ui,ns;if(!Ps.current||!it||((dn=window.getSelection())==null?void 0:dn.toString().length)>0)return;let Wt=Sr.clientY-Ps.current.y,Hr=Sr.clientX-Ps.current.x,Mr=(Yr=t.swipeDirections)!=null?Yr:Dyt(ce);!_e&&(Math.abs(Hr)>1||Math.abs(Wt)>1)&&Be(Math.abs(Hr)>Math.abs(Wt)?"x":"y");let xr={x:0,y:0};_e==="y"?(Mr.includes("top")||Mr.includes("bottom"))&&(Mr.includes("top")&&Wt<0||Mr.includes("bottom")&&Wt>0)&&(xr.y=Wt):_e==="x"&&(Mr.includes("left")||Mr.includes("right"))&&(Mr.includes("left")&&Hr<0||Mr.includes("right")&&Hr>0)&&(xr.x=Hr),(Math.abs(xr.x)>0||Math.abs(xr.y)>0)&&Xe(!0),(ui=We.current)==null||ui.style.setProperty("--swipe-amount-x",`${xr.x}px`),(ns=We.current)==null||ns.style.setProperty("--swipe-amount-y",`${xr.y}px`)}},Es&&!y.jsx?mt.createElement("button",{"aria-label":ue,"data-disabled":Ln,"data-close-button":!0,onClick:Ln||!it?()=>{}:()=>{var Sr;tr(),(Sr=y.onDismiss)==null||Sr.call(y,y)},className:Cg(he==null?void 0:he.closeButton,(a=y==null?void 0:y.classNames)==null?void 0:a.closeButton)},(o=xe==null?void 0:xe.close)!=null?o:vyt):null,y.jsx||k.isValidElement(y.title)?y.jsx?y.jsx:typeof y.title=="function"?y.title():y.title:mt.createElement(mt.Fragment,null,rt||y.icon||y.promise?mt.createElement("div",{"data-icon":"",className:Cg(he==null?void 0:he.icon,(l=y==null?void 0:y.classNames)==null?void 0:l.icon)},y.promise||y.type==="loading"&&!y.icon?y.icon||dr():null,y.type!=="loading"?y.icon||(xe==null?void 0:xe[rt])||hyt(rt):null):null,mt.createElement("div",{"data-content":"",className:Cg(he==null?void 0:he.content,(i=y==null?void 0:y.classNames)==null?void 0:i.content)},mt.createElement("div",{"data-title":"",className:Cg(he==null?void 0:he.title,(c=y==null?void 0:y.classNames)==null?void 0:c.title)},typeof y.title=="function"?y.title():y.title),y.description?mt.createElement("div",{"data-description":"",className:Cg(J,Vt,he==null?void 0:he.description,(u=y==null?void 0:y.classNames)==null?void 0:u.description)},typeof y.description=="function"?y.description():y.description):null),k.isValidElement(y.cancel)?y.cancel:y.cancel&&tz(y.cancel)?mt.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||V,onClick:Sr=>{var dn,Yr;tz(y.cancel)&&it&&((Yr=(dn=y.cancel).onClick)==null||Yr.call(dn,Sr),tr())},className:Cg(he==null?void 0:he.cancelButton,(m=y==null?void 0:y.classNames)==null?void 0:m.cancelButton)},y.cancel.label):null,k.isValidElement(y.action)?y.action:y.action&&tz(y.action)?mt.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||X,onClick:Sr=>{var dn,Yr;tz(y.action)&&((Yr=(dn=y.action).onClick)==null||Yr.call(dn,Sr),!Sr.defaultPrevented&&tr())},className:Cg(he==null?void 0:he.actionButton,(f=y==null?void 0:y.classNames)==null?void 0:f.actionButton)},y.action.label):null))};function sEe(){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 Ryt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Ayt:Tyt;function c(u){["top","right","bottom","left"].forEach(m=>{r[`${l}-${m}`]=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 Fyt=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:m="light",richColors:f,duration:g,style:y,visibleToasts:_=Myt,toastOptions:w,dir:j=sEe(),gap:N=Pyt,loadingIcon:S,icons:M,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:P}=t,[O,q]=mt.useState([]),$=mt.useMemo(()=>Array.from(new Set([n].concat(O.filter(ge=>ge.position).map(ge=>ge.position)))),[O,n]),[z,V]=mt.useState([]),[X,Y]=mt.useState(!1),[J,Q]=mt.useState(!1),[ce,ne]=mt.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),re=mt.useRef(null),oe=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),he=mt.useRef(null),xe=mt.useRef(!1),ue=mt.useCallback(ge=>{q(_e=>{var Be;return(Be=_e.find(Se=>Se.id===ge.id))!=null&&Be.delete||hp.dismiss(ge.id),_e.filter(({id:Se})=>Se!==ge.id)})},[]);return mt.useEffect(()=>hp.subscribe(ge=>{if(ge.dismiss){q(_e=>_e.map(Be=>Be.id===ge.id?{...Be,delete:!0}:Be));return}setTimeout(()=>{k2e.flushSync(()=>{q(_e=>{let Be=_e.findIndex(Se=>Se.id===ge.id);return Be!==-1?[..._e.slice(0,Be),{..._e[Be],...ge},..._e.slice(Be+1)]:[ge,..._e]})})})}),[]),mt.useEffect(()=>{if(m!=="system"){ne(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ne("dark"):ne("light")),typeof window>"u")return;let ge=window.matchMedia("(prefers-color-scheme: dark)");try{ge.addEventListener("change",({matches:_e})=>{ne(_e?"dark":"light")})}catch{ge.addListener(({matches:Be})=>{try{ne(Be?"dark":"light")}catch(Se){console.error(Se)}})}},[m]),mt.useEffect(()=>{O.length<=1&&Y(!1)},[O]),mt.useEffect(()=>{let ge=_e=>{var Be,Se;a.every(Ee=>_e[Ee]||_e.code===Ee)&&(Y(!0),(Be=re.current)==null||Be.focus()),_e.code==="Escape"&&(document.activeElement===re.current||(Se=re.current)!=null&&Se.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)},[a]),mt.useEffect(()=>{if(re.current)return()=>{he.current&&(he.current.focus({preventScroll:!0}),he.current=null,xe.current=!1)}},[re.current]),mt.createElement("section",{ref:s,"aria-label":`${I} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},$.map((ge,_e)=>{var Be;let[Se,Ee]=ge.split("-");return O.length?mt.createElement("ol",{key:ge,dir:j==="auto"?sEe():j,tabIndex:-1,ref:re,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Se,"data-lifted":X&&O.length>1&&!o,"data-x-position":Ee,style:{"--front-toast-height":`${((Be=z[0])==null?void 0:Be.height)||0}px`,"--width":`${Eyt}px`,"--gap":`${N}px`,...y,...Ryt(c,u)},onBlur:Ae=>{xe.current&&!Ae.currentTarget.contains(Ae.relatedTarget)&&(xe.current=!1,he.current&&(he.current.focus({preventScroll:!0}),he.current=null))},onFocus:Ae=>{Ae.target instanceof HTMLElement&&Ae.target.dataset.dismissible==="false"||xe.current||(xe.current=!0,he.current=Ae.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{J||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:Ae=>{Ae.target instanceof HTMLElement&&Ae.target.dataset.dismissible==="false"||Q(!0)},onPointerUp:()=>Q(!1)},O.filter(Ae=>!Ae.position&&_e===0||Ae.position===ge).map((Ae,Me)=>{var ke,Oe;return mt.createElement(Oyt,{key:Ae.id,icons:M,index:Me,toast:Ae,defaultRichColors:f,duration:(ke=w==null?void 0:w.duration)!=null?ke:g,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Oe=w==null?void 0:w.closeButton)!=null?Oe:l,interacting:J,position:ge,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ue,toasts:O.filter(qe=>qe.position==Ae.position),heights:z.filter(qe=>qe.position==Ae.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:S,expanded:X,pauseWhenPageIsHidden:P,swipeDirections:t.swipeDirections})})):null}))});const zyt=({...t})=>{const{theme:s="system"}=uyt();return e.jsx(Fyt,{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 Byt=Lwe[" useId ".trim().toString()]||(()=>{}),$yt=0;function Iu(t){const[s,r]=k.useState(Byt());return kd(()=>{r(n=>n??String($yt++))},[t]),s?`radix-${s}`:""}const qyt=["top","right","bottom","left"],xw=Math.min,of=Math.max,voe=Math.round,sz=Math.floor,C0=t=>({x:t,y:t}),Uyt={left:"right",right:"left",bottom:"top",top:"bottom"},Vyt={start:"end",end:"start"};function Q0e(t,s,r){return of(t,xw(s,r))}function L1(t,s){return typeof t=="function"?t(s):t}function D1(t){return t.split("-")[0]}function sE(t){return t.split("-")[1]}function I2e(t){return t==="x"?"y":"x"}function L2e(t){return t==="y"?"height":"width"}const Hyt=new Set(["top","bottom"]);function c0(t){return Hyt.has(D1(t))?"y":"x"}function D2e(t){return I2e(c0(t))}function Gyt(t,s,r){r===void 0&&(r=!1);const n=sE(t),a=D2e(t),o=L2e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=boe(l)),[l,boe(l)]}function Wyt(t){const s=boe(t);return[X0e(t),s,X0e(s)]}function X0e(t){return t.replace(/start|end/g,s=>Vyt[s])}const rEe=["left","right"],nEe=["right","left"],Kyt=["top","bottom"],Zyt=["bottom","top"];function Yyt(t,s,r){switch(t){case"top":case"bottom":return r?s?nEe:rEe:s?rEe:nEe;case"left":case"right":return s?Kyt:Zyt;default:return[]}}function Qyt(t,s,r,n){const a=sE(t);let o=Yyt(D1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(X0e)))),o}function boe(t){return t.replace(/left|right|bottom|top/g,s=>Uyt[s])}function Xyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function Wqe(t){return typeof t!="number"?Xyt(t):{top:t,right:t,bottom:t,left:t}}function _oe(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 aEe(t,s,r){let{reference:n,floating:a}=t;const o=c0(s),l=D2e(s),i=L2e(l),c=D1(s),u=o==="y",m=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 y;switch(c){case"top":y={x:m,y:n.y-a.height};break;case"bottom":y={x:m,y:n.y+n.height};break;case"right":y={x:n.x+n.width,y:f};break;case"left":y={x:n.x-a.width,y:f};break;default:y={x:n.x,y:n.y}}switch(sE(s)){case"start":y[l]-=g*(r&&u?-1:1);break;case"end":y[l]+=g*(r&&u?-1:1);break}return y}const Jyt=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:m,y:f}=aEe(u,n,c),g=n,y={},_=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:c}=s,{element:u,padding:m=0}=L1(t,s)||{};if(u==null)return{};const f=Wqe(m),g={x:r,y:n},y=D2e(a),_=L2e(y),w=await l.getDimensions(u),j=y==="y",N=j?"top":"left",S=j?"bottom":"right",M=j?"clientHeight":"clientWidth",I=o.reference[_]+o.reference[y]-g[y]-o.floating[_],P=g[y]-o.reference[y],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 $=I/2-P/2,z=q/2-w[_]/2-1,V=xw(f[N],z),X=xw(f[S],z),Y=V,J=q-w[_]-X,Q=q/2-w[_]/2+$,ce=Q0e(Y,Q,J),ne=!c.arrow&&sE(a)!=null&&Q!==ce&&o.reference[_]/2-(QQ<=0)){var X,Y;const Q=(((X=o.flip)==null?void 0:X.index)||0)+1,ce=q[Q];if(ce&&(!(f==="alignment"?S!==c0(ce):!1)||V.every(oe=>oe.overflows[0]>0&&c0(oe.placement)===S)))return{data:{index:Q,overflows:V},reset:{placement:ce}};let ne=(Y=V.filter(re=>re.overflows[0]<=0).sort((re,oe)=>re.overflows[1]-oe.overflows[1])[0])==null?void 0:Y.placement;if(!ne)switch(y){case"bestFit":{var J;const re=(J=V.filter(oe=>{if(O){const he=c0(oe.placement);return he===S||he==="y"}return!0}).map(oe=>[oe.placement,oe.overflows.filter(he=>he>0).reduce((he,xe)=>he+xe,0)]).sort((oe,he)=>oe[1]-he[1])[0])==null?void 0:J[0];re&&(ne=re);break}case"initialPlacement":ne=i;break}if(a!==ne)return{reset:{placement:ne}}}return{}}}};function iEe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function oEe(t){return qyt.some(s=>t[s]>=0)}const s0t=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=L1(t,s);switch(n){case"referenceHidden":{const o=await nD(s,{...a,elementContext:"reference"}),l=iEe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:oEe(l)}}}case"escaped":{const o=await nD(s,{...a,altBoundary:!0}),l=iEe(o,r.floating);return{data:{escapedOffsets:l,escaped:oEe(l)}}}default:return{}}}}},Kqe=new Set(["left","top"]);async function r0t(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=D1(r),i=sE(r),c=c0(r)==="y",u=Kqe.has(l)?-1:1,m=o&&c?-1:1,f=L1(s,t);let{mainAxis:g,crossAxis:y,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"&&(y=i==="end"?_*-1:_),c?{x:y*m,y:g*u}:{x:g*u,y:y*m}}const n0t=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 r0t(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}}}}},a0t=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:j=>{let{x:N,y:S}=j;return{x:N,y:S}}},...c}=L1(t,s),u={x:r,y:n},m=await nD(s,c),f=c0(D1(a)),g=I2e(f);let y=u[g],_=u[f];if(o){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",S=y+m[j],M=y-m[N];y=Q0e(S,y,M)}if(l){const j=f==="y"?"top":"left",N=f==="y"?"bottom":"right",S=_+m[j],M=_-m[N];_=Q0e(S,_,M)}const w=i.fn({...s,[g]:y,[f]:_});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[g]:o,[f]:l}}}}}},i0t=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}=L1(t,s),m={x:r,y:n},f=c0(a),g=I2e(f);let y=m[g],_=m[f];const w=L1(i,s),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const M=g==="y"?"height":"width",I=o.reference[g]-o.floating[M]+j.mainAxis,P=o.reference[g]+o.reference[M]-j.mainAxis;yP&&(y=P)}if(u){var N,S;const M=g==="y"?"width":"height",I=Kqe.has(D1(a)),P=o.reference[f]-o.floating[M]+(I&&((N=l.offset)==null?void 0:N[f])||0)+(I?0:j.crossAxis),O=o.reference[f]+o.reference[M]+(I?0:((S=l.offset)==null?void 0:S[f])||0)-(I?j.crossAxis:0);_O&&(_=O)}return{[g]:y,[f]:_}}}},o0t=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}=L1(t,s),m=await nD(s,u),f=D1(a),g=sE(a),y=c0(a)==="y",{width:_,height:w}=o.floating;let j,N;f==="top"||f==="bottom"?(j=f,N=g===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=f,j=g==="end"?"top":"bottom");const S=w-m.top-m.bottom,M=_-m.left-m.right,I=xw(w-m[j],S),P=xw(_-m[N],M),O=!s.middlewareData.shift;let q=I,$=P;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&($=M),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(q=S),O&&!g){const V=of(m.left,0),X=of(m.right,0),Y=of(m.top,0),J=of(m.bottom,0);y?$=_-2*(V!==0||X!==0?V+X:of(m.left,m.right)):q=w-2*(Y!==0||J!==0?Y+J:of(m.top,m.bottom))}await c({...s,availableWidth:$,availableHeight:q});const z=await l.getDimensions(i.floating);return _!==z.width||w!==z.height?{reset:{rects:!0}}:{}}}};function Rde(){return typeof window<"u"}function rE(t){return Zqe(t)?(t.nodeName||"").toLowerCase():"#document"}function yf(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function U0(t){var s;return(s=(Zqe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function Zqe(t){return Rde()?t instanceof Node||t instanceof yf(t).Node:!1}function ly(t){return Rde()?t instanceof Element||t instanceof yf(t).Element:!1}function L0(t){return Rde()?t instanceof HTMLElement||t instanceof yf(t).HTMLElement:!1}function lEe(t){return!Rde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof yf(t).ShadowRoot}const l0t=new Set(["inline","contents"]);function OO(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=cy(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!l0t.has(a)}const c0t=new Set(["table","td","th"]);function d0t(t){return c0t.has(rE(t))}const u0t=[":popover-open",":modal"];function Fde(t){return u0t.some(s=>{try{return t.matches(s)}catch{return!1}})}const h0t=["transform","translate","scale","rotate","perspective"],m0t=["transform","translate","scale","rotate","perspective","filter"],p0t=["paint","layout","strict","content"];function O2e(t){const s=R2e(),r=ly(t)?cy(t):t;return h0t.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)||m0t.some(n=>(r.willChange||"").includes(n))||p0t.some(n=>(r.contain||"").includes(n))}function f0t(t){let s=gw(t);for(;L0(s)&&!WT(s);){if(O2e(s))return s;if(Fde(s))return null;s=gw(s)}return null}function R2e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const x0t=new Set(["html","body","#document"]);function WT(t){return x0t.has(rE(t))}function cy(t){return yf(t).getComputedStyle(t)}function zde(t){return ly(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function gw(t){if(rE(t)==="html")return t;const s=t.assignedSlot||t.parentNode||lEe(t)&&t.host||U0(t);return lEe(s)?s.host:s}function Yqe(t){const s=gw(t);return WT(s)?t.ownerDocument?t.ownerDocument.body:t.body:L0(s)&&OO(s)?s:Yqe(s)}function aD(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=Yqe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=yf(a);if(o){const i=J0e(l);return s.concat(l,l.visualViewport||[],OO(a)?a:[],i&&r?aD(i):[])}return s.concat(a,aD(a,[],r))}function J0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Qqe(t){const s=cy(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=L0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=voe(r)!==o||voe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function F2e(t){return ly(t)?t:t.contextElement}function cT(t){const s=F2e(t);if(!L0(s))return C0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=Qqe(s);let l=(o?voe(r.width):r.width)/n,i=(o?voe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const g0t=C0(0);function Xqe(t){const s=yf(t);return!R2e()||!s.visualViewport?g0t:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function y0t(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==yf(t)?!1:s}function ZS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=F2e(t);let l=C0(1);s&&(n?ly(n)&&(l=cT(n)):l=cT(t));const i=y0t(o,r,n)?Xqe(o):C0(0);let c=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,m=a.width/l.x,f=a.height/l.y;if(o){const g=yf(o),y=n&&ly(n)?yf(n):n;let _=g,w=J0e(_);for(;w&&n&&y!==_;){const j=cT(w),N=w.getBoundingClientRect(),S=cy(w),M=N.left+(w.clientLeft+parseFloat(S.paddingLeft))*j.x,I=N.top+(w.clientTop+parseFloat(S.paddingTop))*j.y;c*=j.x,u*=j.y,m*=j.x,f*=j.y,c+=M,u+=I,_=yf(w),w=J0e(_)}}return _oe({width:m,height:f,x:c,y:u})}function z2e(t,s){const r=zde(t).scrollLeft;return s?s.left+r:ZS(U0(t)).left+r}function Jqe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:z2e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function v0t(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=U0(n),i=s?Fde(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=C0(1);const m=C0(0),f=L0(n);if((f||!f&&!o)&&((rE(n)!=="body"||OO(l))&&(c=zde(n)),L0(n))){const y=ZS(n);u=cT(n),m.x=y.x+n.clientLeft,m.y=y.y+n.clientTop}const g=l&&!f&&!o?Jqe(l,c,!0):C0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+m.x+g.x,y:r.y*u.y-c.scrollTop*u.y+m.y+g.y}}function b0t(t){return Array.from(t.getClientRects())}function _0t(t){const s=U0(t),r=zde(t),n=t.ownerDocument.body,a=of(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=of(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+z2e(t);const i=-r.scrollTop;return cy(n).direction==="rtl"&&(l+=of(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function w0t(t,s){const r=yf(t),n=U0(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=R2e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const j0t=new Set(["absolute","fixed"]);function N0t(t,s){const r=ZS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=L0(t)?cT(t):C0(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 cEe(t,s,r){let n;if(s==="viewport")n=w0t(t,r);else if(s==="document")n=_0t(U0(t));else if(ly(s))n=N0t(s,r);else{const a=Xqe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return _oe(n)}function eUe(t,s){const r=gw(t);return r===s||!ly(r)||WT(r)?!1:cy(r).position==="fixed"||eUe(r,s)}function k0t(t,s){const r=s.get(t);if(r)return r;let n=aD(t,[],!1).filter(i=>ly(i)&&rE(i)!=="body"),a=null;const o=cy(t).position==="fixed";let l=o?gw(t):t;for(;ly(l)&&!WT(l);){const i=cy(l),c=O2e(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&j0t.has(a.position)||OO(l)&&!c&&eUe(t,l))?n=n.filter(m=>m!==l):a=i,l=gw(l)}return s.set(t,n),n}function S0t(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Fde(s)?[]:k0t(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,m)=>{const f=cEe(s,m,a);return u.top=of(f.top,u.top),u.right=xw(f.right,u.right),u.bottom=xw(f.bottom,u.bottom),u.left=of(f.left,u.left),u},cEe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function C0t(t){const{width:s,height:r}=Qqe(t);return{width:s,height:r}}function M0t(t,s,r){const n=L0(s),a=U0(s),o=r==="fixed",l=ZS(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=C0(0);function u(){c.x=z2e(a)}if(n||!n&&!o)if((rE(s)!=="body"||OO(a))&&(i=zde(s)),n){const y=ZS(s,!0,o,s);c.x=y.x+s.clientLeft,c.y=y.y+s.clientTop}else a&&u();o&&!n&&a&&u();const m=a&&!n&&!o?Jqe(a,i):C0(0),f=l.left+i.scrollLeft-c.x-m.x,g=l.top+i.scrollTop-c.y-m.y;return{x:f,y:g,width:l.width,height:l.height}}function pxe(t){return cy(t).position==="static"}function dEe(t,s){if(!L0(t)||cy(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return U0(t)===r&&(r=r.ownerDocument.body),r}function tUe(t,s){const r=yf(t);if(Fde(t))return r;if(!L0(t)){let a=gw(t);for(;a&&!WT(a);){if(ly(a)&&!pxe(a))return a;a=gw(a)}return r}let n=dEe(t,s);for(;n&&d0t(n)&&pxe(n);)n=dEe(n,s);return n&&WT(n)&&pxe(n)&&!O2e(n)?r:n||f0t(t)||r}const T0t=async function(t){const s=this.getOffsetParent||tUe,r=this.getDimensions,n=await r(t.floating);return{reference:M0t(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function A0t(t){return cy(t).direction==="rtl"}const E0t={convertOffsetParentRelativeRectToViewportRelativeRect:v0t,getDocumentElement:U0,getClippingRect:S0t,getOffsetParent:tUe,getElementRects:T0t,getClientRects:b0t,getDimensions:C0t,getScale:cT,isElement:ly,isRTL:A0t};function sUe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function P0t(t,s){let r=null,n;const a=U0(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:m,top:f,width:g,height:y}=u;if(i||s(),!g||!y)return;const _=sz(f),w=sz(a.clientWidth-(m+g)),j=sz(a.clientHeight-(f+y)),N=sz(m),M={rootMargin:-_+"px "+-w+"px "+-j+"px "+-N+"px",threshold:of(0,xw(1,c))||1};let I=!0;function P(O){const q=O[0].intersectionRatio;if(q!==c){if(!I)return l();q?l(!1,q):n=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!sUe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(P,{...M,root:a.ownerDocument})}catch{r=new IntersectionObserver(P,M)}r.observe(t)}return l(!0),o}function I0t(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=F2e(t),m=a||o?[...u?aD(u):[],...aD(s)]:[];m.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const f=u&&i?P0t(u,r):null;let g=-1,y=null;l&&(y=new ResizeObserver(N=>{let[S]=N;S&&S.target===u&&y&&(y.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=y)==null||M.observe(s)})),r()}),u&&!c&&y.observe(u),y.observe(s));let _,w=c?ZS(t):null;c&&j();function j(){const N=ZS(t);w&&!sUe(w,N)&&r(),w=N,_=requestAnimationFrame(j)}return r(),()=>{var N;m.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(N=y)==null||N.disconnect(),y=null,c&&cancelAnimationFrame(_)}}const L0t=n0t,D0t=a0t,O0t=t0t,R0t=o0t,F0t=s0t,uEe=e0t,z0t=i0t,B0t=(t,s,r)=>{const n=new Map,a={platform:E0t,...r},o={...a.platform,_c:n};return Jyt(t,s,{...a,platform:o})};var $0t=typeof document<"u",q0t=function(){},yie=$0t?k.useLayoutEffect:q0t;function woe(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(!woe(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)&&!woe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function rUe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function hEe(t,s){const r=rUe(t);return Math.round(s*r)/r}function fxe(t){const s=k.useRef(t);return yie(()=>{s.current=t}),s}function U0t(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,[m,f]=k.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,y]=k.useState(n);woe(g,n)||y(n);const[_,w]=k.useState(null),[j,N]=k.useState(null),S=k.useCallback(oe=>{oe!==O.current&&(O.current=oe,w(oe))},[]),M=k.useCallback(oe=>{oe!==q.current&&(q.current=oe,N(oe))},[]),I=o||_,P=l||j,O=k.useRef(null),q=k.useRef(null),$=k.useRef(m),z=c!=null,V=fxe(c),X=fxe(a),Y=fxe(u),J=k.useCallback(()=>{if(!O.current||!q.current)return;const oe={placement:s,strategy:r,middleware:g};X.current&&(oe.platform=X.current),B0t(O.current,q.current,oe).then(he=>{const xe={...he,isPositioned:Y.current!==!1};Q.current&&!woe($.current,xe)&&($.current=xe,vp.flushSync(()=>{f(xe)}))})},[g,s,r,X,Y]);yie(()=>{u===!1&&$.current.isPositioned&&($.current.isPositioned=!1,f(oe=>({...oe,isPositioned:!1})))},[u]);const Q=k.useRef(!1);yie(()=>(Q.current=!0,()=>{Q.current=!1}),[]),yie(()=>{if(I&&(O.current=I),P&&(q.current=P),I&&P){if(V.current)return V.current(I,P,J);J()}},[I,P,J,V,z]);const ce=k.useMemo(()=>({reference:O,floating:q,setReference:S,setFloating:M}),[S,M]),ne=k.useMemo(()=>({reference:I,floating:P}),[I,P]),re=k.useMemo(()=>{const oe={position:r,left:0,top:0};if(!ne.floating)return oe;const he=hEe(ne.floating,m.x),xe=hEe(ne.floating,m.y);return i?{...oe,transform:"translate("+he+"px, "+xe+"px)",...rUe(ne.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:he,top:xe}},[r,i,ne.floating,m.x,m.y]);return k.useMemo(()=>({...m,update:J,refs:ce,elements:ne,floatingStyles:re}),[m,J,ce,ne,re])}const V0t=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?uEe({element:n.current,padding:a}).fn(r):{}:n?uEe({element:n,padding:a}).fn(r):{}}}},H0t=(t,s)=>({...L0t(t),options:[t,s]}),G0t=(t,s)=>({...D0t(t),options:[t,s]}),W0t=(t,s)=>({...z0t(t),options:[t,s]}),K0t=(t,s)=>({...O0t(t),options:[t,s]}),Z0t=(t,s)=>({...R0t(t),options:[t,s]}),Y0t=(t,s)=>({...F0t(t),options:[t,s]}),Q0t=(t,s)=>({...V0t(t),options:[t,s]});var X0t="Arrow",nUe=k.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(cn.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"})})});nUe.displayName=X0t;var J0t=nUe;function RO(t){const[s,r]=k.useState(void 0);return kd(()=>{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 B2e="Popper",[aUe,V0]=od(B2e),[evt,iUe]=aUe(B2e),oUe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=k.useState(null);return e.jsx(evt,{scope:s,anchor:n,onAnchorChange:a,children:r})};oUe.displayName=B2e;var lUe="PopperAnchor",cUe=k.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=iUe(lUe,r),l=k.useRef(null),i=Ka(s,l);return k.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(cn.div,{...a,ref:i})});cUe.displayName=lUe;var $2e="PopperContent",[tvt,svt]=aUe($2e),dUe=k.forwardRef((t,s)=>{var Ae,Me,ke,Oe,qe,ve;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:f="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:_,...w}=t,j=iUe($2e,r),[N,S]=k.useState(null),M=Ka(s,dt=>S(dt)),[I,P]=k.useState(null),O=RO(I),q=(O==null?void 0:O.width)??0,$=(O==null?void 0:O.height)??0,z=n+(o!=="center"?"-"+o:""),V=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},X=Array.isArray(u)?u:[u],Y=X.length>0,J={padding:V,boundary:X.filter(nvt),altBoundary:Y},{refs:Q,floatingStyles:ce,placement:ne,isPositioned:re,middlewareData:oe}=U0t({strategy:"fixed",placement:z,whileElementsMounted:(...dt)=>I0t(...dt,{animationFrame:y==="always"}),elements:{reference:j.anchor},middleware:[H0t({mainAxis:a+$,alignmentAxis:l}),c&&G0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?W0t():void 0,...J}),c&&K0t({...J}),Z0t({...J,apply:({elements:dt,rects:pe,availableWidth:Ue,availableHeight:Xe})=>{const{width:et,height:Ce}=pe.reference,Je=dt.floating.style;Je.setProperty("--radix-popper-available-width",`${Ue}px`),Je.setProperty("--radix-popper-available-height",`${Xe}px`),Je.setProperty("--radix-popper-anchor-width",`${et}px`),Je.setProperty("--radix-popper-anchor-height",`${Ce}px`)}}),I&&Q0t({element:I,padding:i}),avt({arrowWidth:q,arrowHeight:$}),g&&Y0t({strategy:"referenceHidden",...J})]}),[he,xe]=mUe(ne),ue=_d(_);kd(()=>{re&&(ue==null||ue())},[re,ue]);const ge=(Ae=oe.arrow)==null?void 0:Ae.x,_e=(Me=oe.arrow)==null?void 0:Me.y,Be=((ke=oe.arrow)==null?void 0:ke.centerOffset)!==0,[Se,Ee]=k.useState();return kd(()=>{N&&Ee(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:re?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(Oe=oe.transformOrigin)==null?void 0:Oe.x,(qe=oe.transformOrigin)==null?void 0:qe.y].join(" "),...((ve=oe.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(tvt,{scope:r,placedSide:he,onArrowChange:P,arrowX:ge,arrowY:_e,shouldHideArrow:Be,children:e.jsx(cn.div,{"data-side":he,"data-align":xe,...w,ref:M,style:{...w.style,animation:re?void 0:"none"}})})})});dUe.displayName=$2e;var uUe="PopperArrow",rvt={top:"bottom",right:"left",bottom:"top",left:"right"},hUe=k.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=svt(uUe,n),l=rvt[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(J0t,{...a,ref:r,style:{...a.style,display:"block"}})})});hUe.displayName=uUe;function nvt(t){return t!==null}var avt=t=>({name:"transformOrigin",options:t,fn(s){var j,N,S;const{placement:r,rects:n,middlewareData:a}=s,l=((j=a.arrow)==null?void 0:j.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,m]=mUe(r),f={start:"0%",center:"50%",end:"100%"}[m],g=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,y=(((S=a.arrow)==null?void 0:S.y)??0)+c/2;let _="",w="";return u==="bottom"?(_=l?f:`${g}px`,w=`${-c}px`):u==="top"?(_=l?f:`${g}px`,w=`${n.floating.height+c}px`):u==="right"?(_=`${-c}px`,w=l?f:`${y}px`):u==="left"&&(_=`${n.floating.width+c}px`,w=l?f:`${y}px`),{data:{x:_,y:w}}}});function mUe(t){const[s,r="center"]=t.split("-");return[s,r]}var FO=oUe,nE=cUe,zO=dUe,BO=hUe,[Bde]=od("Tooltip",[V0]),$de=V0(),pUe="TooltipProvider",ivt=700,eve="tooltip.open",[ovt,q2e]=Bde(pUe),fUe=t=>{const{__scopeTooltip:s,delayDuration:r=ivt,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(ovt,{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})};fUe.displayName=pUe;var iD="Tooltip",[lvt,qde]=Bde(iD),xUe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=q2e(iD,t.__scopeTooltip),u=$de(s),[m,f]=k.useState(null),g=Iu(),y=k.useRef(0),_=l??c.disableHoverableContent,w=i??c.delayDuration,j=k.useRef(!1),[N,S]=lh({prop:n,defaultProp:a??!1,onChange:q=>{q?(c.onOpen(),document.dispatchEvent(new CustomEvent(eve))):c.onClose(),o==null||o(q)},caller:iD}),M=k.useMemo(()=>N?j.current?"delayed-open":"instant-open":"closed",[N]),I=k.useCallback(()=>{window.clearTimeout(y.current),y.current=0,j.current=!1,S(!0)},[S]),P=k.useCallback(()=>{window.clearTimeout(y.current),y.current=0,S(!1)},[S]),O=k.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{j.current=!0,S(!0),y.current=0},w)},[w,S]);return k.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),e.jsx(FO,{...u,children:e.jsx(lvt,{scope:s,contentId:g,open:N,stateAttribute:M,trigger:m,onTriggerChange:f,onTriggerEnter:k.useCallback(()=>{c.isOpenDelayedRef.current?O():I()},[c.isOpenDelayedRef,O,I]),onTriggerLeave:k.useCallback(()=>{_?P():(window.clearTimeout(y.current),y.current=0)},[P,_]),onOpen:I,onClose:P,disableHoverableContent:_,children:r})})};xUe.displayName=iD;var tve="TooltipTrigger",gUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=qde(tve,r),o=q2e(tve,r),l=$de(r),i=k.useRef(null),c=Ka(s,i,a.onTriggerChange),u=k.useRef(!1),m=k.useRef(!1),f=k.useCallback(()=>u.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(nE,{asChild:!0,...l,children:e.jsx(cn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Or(t.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Or(t.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Or(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Or(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Or(t.onBlur,a.onClose),onClick:Or(t.onClick,a.onClose)})})});gUe.displayName=tve;var cvt="TooltipPortal",[HAs,dvt]=Bde(cvt,{forceMount:void 0}),KT="TooltipContent",yUe=k.forwardRef((t,s)=>{const r=dvt(KT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=qde(KT,t.__scopeTooltip);return e.jsx(qd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(vUe,{side:a,...o,ref:s}):e.jsx(uvt,{side:a,...o,ref:s})})}),uvt=k.forwardRef((t,s)=>{const r=qde(KT,t.__scopeTooltip),n=q2e(KT,t.__scopeTooltip),a=k.useRef(null),o=Ka(s,a),[l,i]=k.useState(null),{trigger:c,onClose:u}=r,m=a.current,{onPointerInTransitChange:f}=n,g=k.useCallback(()=>{i(null),f(!1)},[f]),y=k.useCallback((_,w)=>{const j=_.currentTarget,N={x:_.clientX,y:_.clientY},S=xvt(N,j.getBoundingClientRect()),M=gvt(N,S),I=yvt(w.getBoundingClientRect()),P=bvt([...M,...I]);i(P),f(!0)},[f]);return k.useEffect(()=>()=>g(),[g]),k.useEffect(()=>{if(c&&m){const _=j=>y(j,m),w=j=>y(j,c);return c.addEventListener("pointerleave",_),m.addEventListener("pointerleave",w),()=>{c.removeEventListener("pointerleave",_),m.removeEventListener("pointerleave",w)}}},[c,m,y,g]),k.useEffect(()=>{if(l){const _=w=>{const j=w.target,N={x:w.clientX,y:w.clientY},S=(c==null?void 0:c.contains(j))||(m==null?void 0:m.contains(j)),M=!vvt(N,l);S?g():M&&(g(),u())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[c,m,l,u,g]),e.jsx(vUe,{...t,ref:o})}),[hvt,mvt]=Bde(iD,{isInside:!1}),pvt=dqe("TooltipContent"),vUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=qde(KT,r),u=$de(r),{onClose:m}=c;return k.useEffect(()=>(document.addEventListener(eve,m),()=>document.removeEventListener(eve,m)),[m]),k.useEffect(()=>{if(c.trigger){const f=g=>{const y=g.target;y!=null&&y.contains(c.trigger)&&m()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,m]),e.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:m,children:e.jsxs(zO,{"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(pvt,{children:n}),e.jsx(hvt,{scope:r,isInside:!0,children:e.jsx(ngt,{id:c.contentId,role:"tooltip",children:a||n})})]})})});yUe.displayName=KT;var bUe="TooltipArrow",fvt=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=$de(r);return mvt(bUe,r).isInside?null:e.jsx(BO,{...a,...n,ref:s})});fvt.displayName=bUe;function xvt(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 gvt(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 yvt(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 vvt(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-m)/(g-m)+u&&(a=!a)}return a}function bvt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),_vt(s)}function _vt(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 wvt=fUe,jvt=xUe,Nvt=gUe,_Ue=yUe;const W1=wvt,kc=jvt,Sc=Nvt,sc=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(_Ue,{ref:n,sideOffset:s,className:Pt("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));sc.displayName=_Ue.displayName;var aE=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(){}},YS=typeof window>"u"||"Deno"in globalThis;function Sm(){}function kvt(t,s){return typeof t=="function"?t(s):t}function sve(t){return typeof t=="number"&&t>=0&&t!==1/0}function wUe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function sw(t,s){return typeof t=="function"?t(s):t}function mx(t,s){return typeof t=="function"?t(s):t}function mEe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==U2e(l,s.options))return!1}else if(!oD(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 pEe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(QS(s.options.mutationKey)!==QS(o))return!1}else if(!oD(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function U2e(t,s){return((s==null?void 0:s.queryKeyHashFn)||QS)(t)}function QS(t){return JSON.stringify(t,(s,r)=>rve(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function oD(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>oD(t[r],s[r])):!1}function jUe(t,s){if(t===s)return t;const r=fEe(t)&&fEe(s);if(r||rve(t)&&rve(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 m=0;m{setTimeout(s,t)})}function nve(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?jUe(t,s):s}function Cvt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function Mvt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var V2e=Symbol();function NUe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===V2e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function kUe(t,s){return typeof t=="function"?t(...s):!!t}var z4,v_,MT,F9e,Tvt=(F9e=class extends aE{constructor(){super();ri(this,z4);ri(this,v_);ri(this,MT);Xn(this,MT,s=>{if(!YS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ls(this,v_)||this.setEventListener(ls(this,MT))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,v_))==null||s.call(this),Xn(this,v_,void 0))}setEventListener(s){var r;Xn(this,MT,s),(r=ls(this,v_))==null||r.call(this),Xn(this,v_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ls(this,z4)!==s&&(Xn(this,z4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ls(this,z4)=="boolean"?ls(this,z4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},z4=new WeakMap,v_=new WeakMap,MT=new WeakMap,F9e),H2e=new Tvt,TT,b_,AT,z9e,Avt=(z9e=class extends aE{constructor(){super();ri(this,TT,!0);ri(this,b_);ri(this,AT);Xn(this,AT,s=>{if(!YS&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){ls(this,b_)||this.setEventListener(ls(this,AT))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,b_))==null||s.call(this),Xn(this,b_,void 0))}setEventListener(s){var r;Xn(this,AT,s),(r=ls(this,b_))==null||r.call(this),Xn(this,b_,s(this.setOnline.bind(this)))}setOnline(s){ls(this,TT)!==s&&(Xn(this,TT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ls(this,TT)}},TT=new WeakMap,b_=new WeakMap,AT=new WeakMap,z9e),Noe=new Avt;function ave(){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 Evt(t){return Math.min(1e3*2**t,3e4)}function SUe(t){return(t??"online")==="online"?Noe.isOnline():!0}var CUe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function xxe(t){return t instanceof CUe}function MUe(t){let s=!1,r=0,n=!1,a;const o=ave(),l=w=>{var j;n||(g(new CUe(w)),(j=t.abort)==null||j.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>H2e.isFocused()&&(t.networkMode==="always"||Noe.isOnline())&&t.canRun(),m=()=>SUe(t.networkMode)&&t.canRun(),f=w=>{var j;n||(n=!0,(j=t.onSuccess)==null||j.call(t,w),a==null||a(),o.resolve(w))},g=w=>{var j;n||(n=!0,(j=t.onError)==null||j.call(t,w),a==null||a(),o.reject(w))},y=()=>new Promise(w=>{var j;a=N=>{(n||u())&&w(N)},(j=t.onPause)==null||j.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),_=()=>{if(n)return;let w;const j=r===0?t.initialPromise:void 0;try{w=j??t.fn()}catch(N){w=Promise.reject(N)}Promise.resolve(w).then(f).catch(N=>{var O;if(n)return;const S=t.retry??(YS?0:3),M=t.retryDelay??Evt,I=typeof M=="function"?M(r,N):M,P=S===!0||typeof S=="number"&&ru()?void 0:y()).then(()=>{s?g(N):_()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:m,start:()=>(m()?_():y().then(_),o)}}var Pvt=t=>setTimeout(t,0);function Ivt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=Pvt;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 ju=Ivt(),B4,B9e,TUe=(B9e=class{constructor(){ri(this,B4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sve(this.gcTime)&&Xn(this,B4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(YS?1/0:5*60*1e3))}clearGcTimeout(){ls(this,B4)&&(clearTimeout(ls(this,B4)),Xn(this,B4,void 0))}},B4=new WeakMap,B9e),ET,$4,hx,q4,Uh,kO,U4,Rg,Dv,$9e,Lvt=($9e=class extends TUe{constructor(s){super();ri(this,Rg);ri(this,ET);ri(this,$4);ri(this,hx);ri(this,q4);ri(this,Uh);ri(this,kO);ri(this,U4);Xn(this,U4,!1),Xn(this,kO,s.defaultOptions),this.setOptions(s.options),this.observers=[],Xn(this,q4,s.client),Xn(this,hx,ls(this,q4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Xn(this,ET,Dvt(this.options)),this.state=s.state??ls(this,ET),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ls(this,Uh))==null?void 0:s.promise}setOptions(s){this.options={...ls(this,kO),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ls(this,hx).remove(this)}setData(s,r){const n=nve(this.state.data,s,this.options);return to(this,Rg,Dv).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){to(this,Rg,Dv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ls(this,Uh))==null?void 0:n.promise;return(a=ls(this,Uh))==null||a.cancel(s),r?r.then(Sm).catch(Sm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ls(this,ET))}isActive(){return this.observers.some(s=>mx(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===V2e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>sw(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:!wUe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Uh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Uh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ls(this,hx).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ls(this,Uh)&&(ls(this,U4)?ls(this,Uh).cancel({revert:!0}):ls(this,Uh).cancelRetry()),this.scheduleGc()),ls(this,hx).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||to(this,Rg,Dv).call(this,{type:"invalidate"})}fetch(s,r){var u,m,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ls(this,Uh))return ls(this,Uh).continueRetry(),ls(this,Uh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const g=this.observers.find(y=>y.options.queryFn);g&&this.setOptions(g.options)}const n=new AbortController,a=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Xn(this,U4,!0),n.signal)})},o=()=>{const g=NUe(this.options,r),_=(()=>{const w={client:ls(this,q4),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return Xn(this,U4,!1),this.options.persister?this.options.persister(g,_,this):g(_)},i=(()=>{const g={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ls(this,q4),state:this.state,fetchFn:o};return a(g),g})();(u=this.options.behavior)==null||u.onFetch(i,this),Xn(this,$4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((m=i.fetchOptions)==null?void 0:m.meta))&&to(this,Rg,Dv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=g=>{var y,_,w,j;xxe(g)&&g.silent||to(this,Rg,Dv).call(this,{type:"error",error:g}),xxe(g)||((_=(y=ls(this,hx).config).onError)==null||_.call(y,g,this),(j=(w=ls(this,hx).config).onSettled)==null||j.call(w,this.state.data,g,this)),this.scheduleGc()};return Xn(this,Uh,MUe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:g=>{var y,_,w,j;if(g===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(N){c(N);return}(_=(y=ls(this,hx).config).onSuccess)==null||_.call(y,g,this),(j=(w=ls(this,hx).config).onSettled)==null||j.call(w,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,y)=>{to(this,Rg,Dv).call(this,{type:"failed",failureCount:g,error:y})},onPause:()=>{to(this,Rg,Dv).call(this,{type:"pause"})},onContinue:()=>{to(this,Rg,Dv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ls(this,Uh).start()}},ET=new WeakMap,$4=new WeakMap,hx=new WeakMap,q4=new WeakMap,Uh=new WeakMap,kO=new WeakMap,U4=new WeakMap,Rg=new WeakSet,Dv=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,...AUe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Xn(this,$4,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 xxe(a)&&a.revert&&ls(this,$4)?{...ls(this,$4),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),ju.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ls(this,hx).notify({query:this,type:"updated",action:s})})},$9e);function AUe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:SUe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Dvt(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 e0,q9e,Ovt=(q9e=class extends aE{constructor(s={}){super();ri(this,e0);this.config=s,Xn(this,e0,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??U2e(a,r);let l=this.get(o);return l||(l=new Lvt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ls(this,e0).has(s.queryHash)||(ls(this,e0).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ls(this,e0).get(s.queryHash);r&&(s.destroy(),r===s&&ls(this,e0).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){ju.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ls(this,e0).get(s)}getAll(){return[...ls(this,e0).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>mEe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>mEe(s,n)):r}notify(s){ju.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){ju.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){ju.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},e0=new WeakMap,q9e),t0,jm,V4,s0,Wb,U9e,Rvt=(U9e=class extends TUe{constructor(s){super();ri(this,s0);ri(this,t0);ri(this,jm);ri(this,V4);this.mutationId=s.mutationId,Xn(this,jm,s.mutationCache),Xn(this,t0,[]),this.state=s.state||EUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ls(this,t0).includes(s)||(ls(this,t0).push(s),this.clearGcTimeout(),ls(this,jm).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Xn(this,t0,ls(this,t0).filter(r=>r!==s)),this.scheduleGc(),ls(this,jm).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ls(this,t0).length||(this.state.status==="pending"?this.scheduleGc():ls(this,jm).remove(this))}continue(){var s;return((s=ls(this,V4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,m,f,g,y,_,w,j,N,S,M,I,P,O,q,$;const r=()=>{to(this,s0,Wb).call(this,{type:"continue"})};Xn(this,V4,MUe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(z,V)=>{to(this,s0,Wb).call(this,{type:"failed",failureCount:z,error:V})},onPause:()=>{to(this,s0,Wb).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ls(this,jm).canRun(this)}));const n=this.state.status==="pending",a=!ls(this,V4).canStart();try{if(n)r();else{to(this,s0,Wb).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ls(this,jm).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&&to(this,s0,Wb).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const z=await ls(this,V4).start();return await((m=(u=ls(this,jm).config).onSuccess)==null?void 0:m.call(u,z,s,this.state.context,this)),await((g=(f=this.options).onSuccess)==null?void 0:g.call(f,z,s,this.state.context)),await((_=(y=ls(this,jm).config).onSettled)==null?void 0:_.call(y,z,null,this.state.variables,this.state.context,this)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,z,null,s,this.state.context)),to(this,s0,Wb).call(this,{type:"success",data:z}),z}catch(z){try{throw await((S=(N=ls(this,jm).config).onError)==null?void 0:S.call(N,z,s,this.state.context,this)),await((I=(M=this.options).onError)==null?void 0:I.call(M,z,s,this.state.context)),await((O=(P=ls(this,jm).config).onSettled)==null?void 0:O.call(P,void 0,z,this.state.variables,this.state.context,this)),await(($=(q=this.options).onSettled)==null?void 0:$.call(q,void 0,z,s,this.state.context)),z}finally{to(this,s0,Wb).call(this,{type:"error",error:z})}}finally{ls(this,jm).runNext(this)}}},t0=new WeakMap,jm=new WeakMap,V4=new WeakMap,s0=new WeakSet,Wb=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),ju.batch(()=>{ls(this,t0).forEach(n=>{n.onMutationUpdate(s)}),ls(this,jm).notify({mutation:this,type:"updated",action:s})})},U9e);function EUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Zv,Fg,SO,V9e,Fvt=(V9e=class extends aE{constructor(s={}){super();ri(this,Zv);ri(this,Fg);ri(this,SO);this.config=s,Xn(this,Zv,new Set),Xn(this,Fg,new Map),Xn(this,SO,0)}build(s,r,n){const a=new Rvt({mutationCache:this,mutationId:++D7(this,SO)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ls(this,Zv).add(s);const r=rz(s);if(typeof r=="string"){const n=ls(this,Fg).get(r);n?n.push(s):ls(this,Fg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ls(this,Zv).delete(s)){const r=rz(s);if(typeof r=="string"){const n=ls(this,Fg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ls(this,Fg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=rz(s);if(typeof r=="string"){const n=ls(this,Fg).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=rz(s);if(typeof r=="string"){const a=(n=ls(this,Fg).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(){ju.batch(()=>{ls(this,Zv).forEach(s=>{this.notify({type:"removed",mutation:s})}),ls(this,Zv).clear(),ls(this,Fg).clear()})}getAll(){return Array.from(ls(this,Zv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>pEe(r,n))}findAll(s={}){return this.getAll().filter(r=>pEe(s,r))}notify(s){ju.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return ju.batch(()=>Promise.all(s.map(r=>r.continue().catch(Sm))))}},Zv=new WeakMap,Fg=new WeakMap,SO=new WeakMap,V9e);function rz(t){var s;return(s=t.options.scope)==null?void 0:s.id}function koe(t){return{onFetch:(s,r)=>{var m,f,g,y,_;const n=s.options,a=(g=(f=(m=s.fetchOptions)==null?void 0:m.meta)==null?void 0:f.fetchMore)==null?void 0:g.direction,o=((y=s.state.data)==null?void 0:y.pages)||[],l=((_=s.state.data)==null?void 0:_.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const j=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},N=NUe(s.options,s.fetchOptions),S=async(M,I,P)=>{if(w)return Promise.reject();if(I==null&&M.pages.length)return Promise.resolve(M);const q=(()=>{const X={client:s.client,queryKey:s.queryKey,pageParam:I,direction:P?"backward":"forward",meta:s.options.meta};return j(X),X})(),$=await N(q),{maxPages:z}=s.options,V=P?Mvt:Cvt;return{pages:V(M.pages,$,z),pageParams:V(M.pageParams,I,z)}};if(a&&o.length){const M=a==="backward",I=M?PUe:ive,P={pages:o,pageParams:l},O=I(n,P);i=await S(P,O,M)}else{const M=t??o.length;do{const I=c===0?l[0]??n.initialPageParam:ive(n,i);if(c>0&&I==null)break;i=await S(i,I),c++}while(c{var w,j;return(j=(w=s.options).persister)==null?void 0:j.call(w,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function ive(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 PUe(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 zvt(t,s){return s?ive(t,s)!=null:!1}function Bvt(t,s){return!s||!t.getPreviousPageParam?!1:PUe(t,s)!=null}var hd,__,w_,PT,IT,j_,LT,DT,H9e,$vt=(H9e=class{constructor(t={}){ri(this,hd);ri(this,__);ri(this,w_);ri(this,PT);ri(this,IT);ri(this,j_);ri(this,LT);ri(this,DT);Xn(this,hd,t.queryCache||new Ovt),Xn(this,__,t.mutationCache||new Fvt),Xn(this,w_,t.defaultOptions||{}),Xn(this,PT,new Map),Xn(this,IT,new Map),Xn(this,j_,0)}mount(){D7(this,j_)._++,ls(this,j_)===1&&(Xn(this,LT,H2e.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,hd).onFocus())})),Xn(this,DT,Noe.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,hd).onOnline())})))}unmount(){var t,s;D7(this,j_)._--,ls(this,j_)===0&&((t=ls(this,LT))==null||t.call(this),Xn(this,LT,void 0),(s=ls(this,DT))==null||s.call(this),Xn(this,DT,void 0))}isFetching(t){return ls(this,hd).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ls(this,__).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,hd).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ls(this,hd).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(sw(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ls(this,hd).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=ls(this,hd).get(n.queryHash),o=a==null?void 0:a.state.data,l=kvt(s,o);if(l!==void 0)return ls(this,hd).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return ju.batch(()=>ls(this,hd).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,hd).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ls(this,hd);ju.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ls(this,hd);return ju.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=ju.batch(()=>ls(this,hd).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(Sm).catch(Sm)}invalidateQueries(t,s={}){return ju.batch(()=>(ls(this,hd).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=ju.batch(()=>ls(this,hd).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Sm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Sm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ls(this,hd).build(this,s);return r.isStaleByTime(sw(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Sm).catch(Sm)}fetchInfiniteQuery(t){return t.behavior=koe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Sm).catch(Sm)}ensureInfiniteQueryData(t){return t.behavior=koe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Noe.isOnline()?ls(this,__).resumePausedMutations():Promise.resolve()}getQueryCache(){return ls(this,hd)}getMutationCache(){return ls(this,__)}getDefaultOptions(){return ls(this,w_)}setDefaultOptions(t){Xn(this,w_,t)}setQueryDefaults(t,s){ls(this,PT).set(QS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ls(this,PT).values()],r={};return s.forEach(n=>{oD(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ls(this,IT).set(QS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ls(this,IT).values()],r={};return s.forEach(n=>{oD(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ls(this,w_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=U2e(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===V2e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ls(this,w_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ls(this,hd).clear(),ls(this,__).clear()}},hd=new WeakMap,__=new WeakMap,w_=new WeakMap,PT=new WeakMap,IT=new WeakMap,j_=new WeakMap,LT=new WeakMap,DT=new WeakMap,H9e),cp,Eo,CO,Nm,H4,OT,N_,k_,MO,RT,FT,G4,W4,S_,zT,hl,FI,ove,lve,cve,dve,uve,hve,mve,LUe,G9e,IUe=(G9e=class extends aE{constructor(s,r){super();ri(this,hl);ri(this,cp);ri(this,Eo);ri(this,CO);ri(this,Nm);ri(this,H4);ri(this,OT);ri(this,N_);ri(this,k_);ri(this,MO);ri(this,RT);ri(this,FT);ri(this,G4);ri(this,W4);ri(this,S_);ri(this,zT,new Set);this.options=r,Xn(this,cp,s),Xn(this,k_,null),Xn(this,N_,ave()),this.options.experimental_prefetchInRender||ls(this,N_).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ls(this,Eo).addObserver(this),gEe(ls(this,Eo),this.options)?to(this,hl,FI).call(this):this.updateResult(),to(this,hl,dve).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pve(ls(this,Eo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pve(ls(this,Eo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,to(this,hl,uve).call(this),to(this,hl,hve).call(this),ls(this,Eo).removeObserver(this)}setOptions(s){const r=this.options,n=ls(this,Eo);if(this.options=ls(this,cp).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof mx(this.options.enabled,ls(this,Eo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");to(this,hl,mve).call(this),ls(this,Eo).setOptions(this.options),r._defaulted&&!joe(this.options,r)&&ls(this,cp).getQueryCache().notify({type:"observerOptionsUpdated",query:ls(this,Eo),observer:this});const a=this.hasListeners();a&&yEe(ls(this,Eo),n,this.options,r)&&to(this,hl,FI).call(this),this.updateResult(),a&&(ls(this,Eo)!==n||mx(this.options.enabled,ls(this,Eo))!==mx(r.enabled,ls(this,Eo))||sw(this.options.staleTime,ls(this,Eo))!==sw(r.staleTime,ls(this,Eo)))&&to(this,hl,ove).call(this);const o=to(this,hl,lve).call(this);a&&(ls(this,Eo)!==n||mx(this.options.enabled,ls(this,Eo))!==mx(r.enabled,ls(this,Eo))||o!==ls(this,S_))&&to(this,hl,cve).call(this,o)}getOptimisticResult(s){const r=ls(this,cp).getQueryCache().build(ls(this,cp),s),n=this.createResult(r,s);return Uvt(this,n)&&(Xn(this,Nm,n),Xn(this,OT,this.options),Xn(this,H4,ls(this,Eo).state)),n}getCurrentResult(){return ls(this,Nm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ls(this,zT).add(s)}getCurrentQuery(){return ls(this,Eo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ls(this,cp).defaultQueryOptions(s),n=ls(this,cp).getQueryCache().build(ls(this,cp),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return to(this,hl,FI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ls(this,Nm)))}createResult(s,r){var z;const n=ls(this,Eo),a=this.options,o=ls(this,Nm),l=ls(this,H4),i=ls(this,OT),u=s!==n?s.state:ls(this,CO),{state:m}=s;let f={...m},g=!1,y;if(r._optimisticResults){const V=this.hasListeners(),X=!V&&gEe(s,r),Y=V&&yEe(s,n,r,a);(X||Y)&&(f={...f,...AUe(m.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:_,errorUpdatedAt:w,status:j}=f;y=f.data;let N=!1;if(r.placeholderData!==void 0&&y===void 0&&j==="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((z=ls(this,FT))==null?void 0:z.state.data,ls(this,FT)):r.placeholderData,V!==void 0&&(j="success",y=nve(o==null?void 0:o.data,V,r),g=!0)}if(r.select&&y!==void 0&&!N)if(o&&y===(l==null?void 0:l.data)&&r.select===ls(this,MO))y=ls(this,RT);else try{Xn(this,MO,r.select),y=r.select(y),y=nve(o==null?void 0:o.data,y,r),Xn(this,RT,y),Xn(this,k_,null)}catch(V){Xn(this,k_,V)}ls(this,k_)&&(_=ls(this,k_),y=ls(this,RT),w=Date.now(),j="error");const S=f.fetchStatus==="fetching",M=j==="pending",I=j==="error",P=M&&S,O=y!==void 0,$={status:j,fetchStatus:f.fetchStatus,isPending:M,isSuccess:j==="success",isError:I,isInitialLoading:P,isLoading:P,data:y,dataUpdatedAt:f.dataUpdatedAt,error:_,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!M,isLoadingError:I&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:I&&O,isStale:G2e(s,r),refetch:this.refetch,promise:ls(this,N_),isEnabled:mx(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=J=>{$.status==="error"?J.reject($.error):$.data!==void 0&&J.resolve($.data)},X=()=>{const J=Xn(this,N_,$.promise=ave());V(J)},Y=ls(this,N_);switch(Y.status){case"pending":s.queryHash===n.queryHash&&V(Y);break;case"fulfilled":($.status==="error"||$.data!==Y.value)&&X();break;case"rejected":($.status!=="error"||$.error!==Y.reason)&&X();break}}return $}updateResult(){const s=ls(this,Nm),r=this.createResult(ls(this,Eo),this.options);if(Xn(this,H4,ls(this,Eo).state),Xn(this,OT,this.options),ls(this,H4).data!==void 0&&Xn(this,FT,ls(this,Eo)),joe(r,s))return;Xn(this,Nm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ls(this,zT).size)return!0;const l=new Set(o??ls(this,zT));return this.options.throwOnError&&l.add("error"),Object.keys(ls(this,Nm)).some(i=>{const c=i;return ls(this,Nm)[c]!==s[c]&&l.has(c)})};to(this,hl,LUe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&to(this,hl,dve).call(this)}},cp=new WeakMap,Eo=new WeakMap,CO=new WeakMap,Nm=new WeakMap,H4=new WeakMap,OT=new WeakMap,N_=new WeakMap,k_=new WeakMap,MO=new WeakMap,RT=new WeakMap,FT=new WeakMap,G4=new WeakMap,W4=new WeakMap,S_=new WeakMap,zT=new WeakMap,hl=new WeakSet,FI=function(s){to(this,hl,mve).call(this);let r=ls(this,Eo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(Sm)),r},ove=function(){to(this,hl,uve).call(this);const s=sw(this.options.staleTime,ls(this,Eo));if(YS||ls(this,Nm).isStale||!sve(s))return;const n=wUe(ls(this,Nm).dataUpdatedAt,s)+1;Xn(this,G4,setTimeout(()=>{ls(this,Nm).isStale||this.updateResult()},n))},lve=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ls(this,Eo)):this.options.refetchInterval)??!1},cve=function(s){to(this,hl,hve).call(this),Xn(this,S_,s),!(YS||mx(this.options.enabled,ls(this,Eo))===!1||!sve(ls(this,S_))||ls(this,S_)===0)&&Xn(this,W4,setInterval(()=>{(this.options.refetchIntervalInBackground||H2e.isFocused())&&to(this,hl,FI).call(this)},ls(this,S_)))},dve=function(){to(this,hl,ove).call(this),to(this,hl,cve).call(this,to(this,hl,lve).call(this))},uve=function(){ls(this,G4)&&(clearTimeout(ls(this,G4)),Xn(this,G4,void 0))},hve=function(){ls(this,W4)&&(clearInterval(ls(this,W4)),Xn(this,W4,void 0))},mve=function(){const s=ls(this,cp).getQueryCache().build(ls(this,cp),this.options);if(s===ls(this,Eo))return;const r=ls(this,Eo);Xn(this,Eo,s),Xn(this,CO,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},LUe=function(s){ju.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ls(this,Nm))}),ls(this,cp).getQueryCache().notify({query:ls(this,Eo),type:"observerResultsUpdated"})})},G9e);function qvt(t,s){return mx(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function gEe(t,s){return qvt(t,s)||t.state.data!==void 0&&pve(t,s,s.refetchOnMount)}function pve(t,s,r){if(mx(s.enabled,t)!==!1&&sw(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&G2e(t,s)}return!1}function yEe(t,s,r,n){return(t!==s||mx(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&G2e(t,r)}function G2e(t,s){return mx(s.enabled,t)!==!1&&t.isStaleByTime(sw(s.staleTime,t))}function Uvt(t,s){return!joe(t.getCurrentResult(),s)}var Vvt=class extends IUe{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:koe()})}getOptimisticResult(t){return t.behavior=koe(),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 _,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(w=(_=r.fetchMeta)==null?void 0:_.fetchMore)==null?void 0:w.direction,u=l&&c==="forward",m=a&&c==="forward",f=l&&c==="backward",g=a&&c==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:zvt(s,r.data),hasPreviousPage:Bvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:m,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:i&&!u&&!f,isRefetching:o&&!m&&!g}}},C_,M_,dp,Yv,M1,vie,fve,W9e,Hvt=(W9e=class extends aE{constructor(r,n){super();ri(this,M1);ri(this,C_);ri(this,M_);ri(this,dp);ri(this,Yv);Xn(this,C_,r),this.setOptions(n),this.bindMethods(),to(this,M1,vie).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=ls(this,C_).defaultMutationOptions(r),joe(this.options,n)||ls(this,C_).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ls(this,dp),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&QS(n.mutationKey)!==QS(this.options.mutationKey)?this.reset():((a=ls(this,dp))==null?void 0:a.state.status)==="pending"&&ls(this,dp).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ls(this,dp))==null||r.removeObserver(this)}onMutationUpdate(r){to(this,M1,vie).call(this),to(this,M1,fve).call(this,r)}getCurrentResult(){return ls(this,M_)}reset(){var r;(r=ls(this,dp))==null||r.removeObserver(this),Xn(this,dp,void 0),to(this,M1,vie).call(this),to(this,M1,fve).call(this)}mutate(r,n){var a;return Xn(this,Yv,n),(a=ls(this,dp))==null||a.removeObserver(this),Xn(this,dp,ls(this,C_).getMutationCache().build(ls(this,C_),this.options)),ls(this,dp).addObserver(this),ls(this,dp).execute(r)}},C_=new WeakMap,M_=new WeakMap,dp=new WeakMap,Yv=new WeakMap,M1=new WeakSet,vie=function(){var n;const r=((n=ls(this,dp))==null?void 0:n.state)??EUe();Xn(this,M_,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},fve=function(r){ju.batch(()=>{var n,a,o,l,i,c,u,m;if(ls(this,Yv)&&this.hasListeners()){const f=ls(this,M_).variables,g=ls(this,M_).context;(r==null?void 0:r.type)==="success"?((a=(n=ls(this,Yv)).onSuccess)==null||a.call(n,r.data,f,g),(l=(o=ls(this,Yv)).onSettled)==null||l.call(o,r.data,null,f,g)):(r==null?void 0:r.type)==="error"&&((c=(i=ls(this,Yv)).onError)==null||c.call(i,r.error,f,g),(m=(u=ls(this,Yv)).onSettled)==null||m.call(u,void 0,r.error,f,g))}this.listeners.forEach(f=>{f(ls(this,M_))})})},W9e),DUe=k.createContext(void 0),Qt=t=>{const s=k.useContext(DUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Gvt=({client:t,children:s})=>(k.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(DUe.Provider,{value:t,children:s})),OUe=k.createContext(!1),Wvt=()=>k.useContext(OUe);OUe.Provider;function Kvt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Zvt=k.createContext(Kvt()),Yvt=()=>k.useContext(Zvt),Qvt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Xvt=t=>{k.useEffect(()=>{t.clearReset()},[t])},Jvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||kUe(r,[t.error,n])),e1t=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))}},t1t=(t,s)=>t.isLoading&&t.isFetching&&!s,s1t=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,vEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function RUe(t,s,r){var f,g,y,_,w;const n=Wvt(),a=Yvt(),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",e1t(l),Qvt(l,a),Xvt(a);const i=!o.getQueryCache().get(l.queryHash),[c]=k.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),m=!n&&t.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(j=>{const N=m?c.subscribe(ju.batchCalls(j)):Sm;return c.updateResult(),N},[c,m]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setOptions(l)},[l,c]),s1t(l,u))throw vEe(l,c,a);if(Jvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((_=(y=o.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||_.call(y,l,u),l.experimental_prefetchInRender&&!YS&&t1t(u,n)){const j=i?vEe(l,c,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;j==null||j.catch(Sm).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function pt(t,s){return RUe(t,IUe)}function Tt(t,s){const r=Qt(),[n]=k.useState(()=>new Hvt(r,t));k.useEffect(()=>{n.setOptions(t)},[n,t]);const a=k.useSyncExternalStore(k.useCallback(l=>n.subscribe(ju.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((l,i)=>{n.mutate(l,i).catch(Sm)},[n]);if(a.error&&kUe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function W2e(t,s){return RUe(t,Vvt)}/** * @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 lD(){return lD=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function FUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function n1t(){return Math.random().toString(36).substr(2,8)}function _Ee(t,s){return{usr:t.state,key:t.key,idx:s}}function xve(t,s,r,n){return r===void 0&&(r=null),lD({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?iE(s):s,{state:r,key:s&&s.key||n||n1t()})}function Soe(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 iE(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 a1t(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=E_.Pop,c=null,u=m();u==null&&(u=0,l.replaceState(lD({},l.state,{idx:u}),""));function m(){return(l.state||{idx:null}).idx}function f(){i=E_.Pop;let j=m(),N=j==null?null:j-u;u=j,c&&c({action:i,location:w.location,delta:N})}function g(j,N){i=E_.Push;let S=xve(w.location,j,N);u=m()+1;let M=_Ee(S,u),I=w.createHref(S);try{l.pushState(M,"",I)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(I)}o&&c&&c({action:i,location:w.location,delta:1})}function y(j,N){i=E_.Replace;let S=xve(w.location,j,N);u=m();let M=_Ee(S,u),I=w.createHref(S);l.replaceState(M,"",I),o&&c&&c({action:i,location:w.location,delta:0})}function _(j){let N=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof j=="string"?j:Soe(j);return S=S.replace(/ $/,"%20"),Bd(N,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,N)}let w={get action(){return i},get location(){return t(a,l)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(bEe,f),c=j,()=>{a.removeEventListener(bEe,f),c=null}},createHref(j){return s(a,j)},createURL:_,encodeLocation(j){let N=_(j);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:g,replace:y,go(j){return l.go(j)}};return w}var wEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(wEe||(wEe={}));function i1t(t,s,r){return r===void 0&&(r="/"),o1t(t,s,r)}function o1t(t,s,r,n){let a=typeof s=="string"?iE(s):s,o=K2e(a.pathname||"/",r);if(o==null)return null;let l=zUe(t);l1t(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("/")&&(Bd(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=rw([n,c.relativePath]),m=r.concat(c);o.children&&o.children.length>0&&(Bd(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),zUe(o.children,s,m,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:f1t(u,o.index),routesMeta:m})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let c of BUe(o.path))a(o,l,c)}),s}function BUe(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=BUe(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 l1t(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:x1t(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const c1t=/^:[\w-]+$/,d1t=3,u1t=2,h1t=1,m1t=10,p1t=-2,jEe=t=>t==="*";function f1t(t,s){let r=t.split("/"),n=r.length;return r.some(jEe)&&(n+=p1t),s&&(n+=u1t),r.filter(a=>!jEe(a)).reduce((a,o)=>a+(c1t.test(o)?d1t:o===""?h1t:m1t),n)}function x1t(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 g1t(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:g,isOptional:y}=m;if(g==="*"){let w=i[f]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const _=i[f];return y&&!_?u[g]=void 0:u[g]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function v1t(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),FUe(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 b1t(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return FUe(!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 K2e(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 _1t(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?iE(t):t;return{pathname:r?r.startsWith("/")?r:w1t(r,s):s,search:k1t(n),hash:S1t(a)}}function w1t(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 gxe(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 j1t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function Z2e(t,s){let r=j1t(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Y2e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=iE(t):(a=lD({},t),Bd(!a.pathname||!a.pathname.includes("?"),gxe("?","pathname","search",a)),Bd(!a.pathname||!a.pathname.includes("#"),gxe("#","pathname","hash",a)),Bd(!a.search||!a.search.includes("#"),gxe("#","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=_1t(a,i),u=l&&l!=="/"&&l.endsWith("/"),m=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||m)&&(c.pathname+="/"),c}const rw=t=>t.join("/").replace(/\/\/+/g,"/"),N1t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),k1t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,S1t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function C1t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const $Ue=["post","put","patch","delete"];new Set($Ue);const M1t=["get",...$Ue];new Set(M1t);/** * 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 cD(){return cD=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),k.useCallback(function(u,m){if(m===void 0&&(m={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=Y2e(u,JSON.parse(l),o,m.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:rw([s,f.pathname])),(m.replace?n.replace:n.push)(f,m.state,m)},[s,n,l,o,t])}const P1t=k.createContext(null);function I1t(t){let s=k.useContext(H0).outlet;return s&&k.createElement(P1t.Provider,{value:t},s)}function ao(){let{matches:t}=k.useContext(H0),s=t[t.length-1];return s?s.params:{}}function VUe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=k.useContext(Pw),{matches:a}=k.useContext(H0),{pathname:o}=hc(),l=JSON.stringify(Z2e(a,n.v7_relativeSplatPath));return k.useMemo(()=>Y2e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function L1t(t,s){return D1t(t,s)}function D1t(t,s,r,n){oE()||Bd(!1);let{navigator:a}=k.useContext(Pw),{matches:o}=k.useContext(H0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=hc(),m;if(s){var f;let j=typeof s=="string"?iE(s):s;c==="/"||(f=j.pathname)!=null&&f.startsWith(c)||Bd(!1),m=j}else m=u;let g=m.pathname||"/",y=g;if(c!=="/"){let j=c.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let _=i1t(t,{pathname:y}),w=B1t(_&&_.map(j=>Object.assign({},j,{params:Object.assign({},i,j.params),pathname:rw([c,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?c:rw([c,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),o,r,n);return s&&w?k.createElement(Ude.Provider,{value:{location:cD({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:E_.Pop}},w):w}function O1t(){let t=V1t(),s=C1t(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 R1t=k.createElement(O1t,null);class F1t 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(H0.Provider,{value:this.props.routeContext},k.createElement(qUe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function z1t(t){let{routeContext:s,match:r,children:n}=t,a=k.useContext(Q2e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),k.createElement(H0.Provider,{value:s},n)}function B1t(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 m=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);m>=0||Bd(!1),l=l.slice(0,Math.min(l.length,m+1))}let c=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let m=0;m=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((m,f,g)=>{let y,_=!1,w=null,j=null;r&&(y=i&&f.route.id?i[f.route.id]:void 0,w=f.route.errorElement||R1t,c&&(u<0&&g===0?(G1t("route-fallback"),_=!0,j=null):u===g&&(_=!0,j=f.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,g+1)),S=()=>{let M;return y?M=w:_?M=j:f.route.Component?M=k.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=m,k.createElement(z1t,{match:f,routeContext:{outlet:m,matches:N,isDataRoute:r!=null},children:M})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?k.createElement(F1t,{location:r.location,revalidation:r.revalidation,component:w,error:y,children:S(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):S()},null)}var HUe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(HUe||{}),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 $1t(t){let s=k.useContext(Q2e);return s||Bd(!1),s}function q1t(t){let s=k.useContext(T1t);return s||Bd(!1),s}function U1t(t){let s=k.useContext(H0);return s||Bd(!1),s}function WUe(t){let s=U1t(),r=s.matches[s.matches.length-1];return r.route.id||Bd(!1),r.route.id}function V1t(){var t;let s=k.useContext(qUe),r=q1t(),n=WUe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function H1t(){let{router:t}=$1t(HUe.UseNavigateStable),s=WUe(GUe.UseNavigateStable),r=k.useRef(!1);return UUe(()=>{r.current=!0}),k.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,cD({fromRouteId:s},o)))},[t,s])}const NEe={};function G1t(t,s,r){NEe[t]||(NEe[t]=!0)}function W1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function yxe(t){let{to:s,replace:r,state:n,relative:a}=t;oE()||Bd(!1);let{future:o,static:l}=k.useContext(Pw),{matches:i}=k.useContext(H0),{pathname:c}=hc(),u=ar(),m=Y2e(s,Z2e(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(m);return k.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function K1t(t){return I1t(t.context)}function xs(t){Bd(!1)}function Z1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=E_.Pop,navigator:o,static:l=!1,future:i}=t;oE()&&Bd(!1);let c=s.replace(/^\/*/,"/"),u=k.useMemo(()=>({basename:c,navigator:o,static:l,future:cD({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=iE(n));let{pathname:m="/",search:f="",hash:g="",state:y=null,key:_="default"}=n,w=k.useMemo(()=>{let j=K2e(m,c);return j==null?null:{location:{pathname:j,search:f,hash:g,state:y,key:_},navigationType:a}},[c,m,f,g,y,_,a]);return w==null?null:k.createElement(Pw.Provider,{value:u},k.createElement(Ude.Provider,{children:r,value:w}))}function Coe(t){let{children:s,location:r}=t;return L1t(gve(s),r)}new Promise(()=>{});function gve(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,gve(n.props.children,o));return}n.type!==xs&&Bd(!1),!n.props.index||!n.props.children||Bd(!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=gve(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 yve(){return yve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function Q1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function X1t(t,s){return t.button===0&&(!s||s==="_self")&&!Q1t(t)}function vve(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 J1t(t,s){let r=vve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const ebt=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],tbt="6";try{window.__reactRouterVersion=tbt}catch{}const sbt="startTransition",kEe=Lwe[sbt];function rbt(t){let{basename:s,children:r,future:n,window:a}=t,o=k.useRef();o.current==null&&(o.current=r1t({window:a,v5Compat:!0}));let l=o.current,[i,c]=k.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},m=k.useCallback(f=>{u&&kEe?kEe(()=>c(f)):c(f)},[c,u]);return k.useLayoutEffect(()=>l.listen(m),[l,m]),k.useEffect(()=>W1t(n),[n]),k.createElement(Z1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const nbt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",abt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,la=k.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:c,to:u,preventScrollReset:m,viewTransition:f}=s,g=Y1t(s,ebt),{basename:y}=k.useContext(Pw),_,w=!1;if(typeof u=="string"&&abt.test(u)&&(_=u,nbt))try{let M=new URL(window.location.href),I=u.startsWith("//")?new URL(M.protocol+u):new URL(u),P=K2e(I.pathname,y);I.origin===M.origin&&P!=null?u=P+I.search+I.hash:w=!0}catch{}let j=A1t(u,{relative:a}),N=ibt(u,{replace:l,state:i,target:c,preventScrollReset:m,relative:a,viewTransition:f});function S(M){n&&n(M),M.defaultPrevented||N(M)}return k.createElement("a",yve({},g,{href:_||j,onClick:w||o?n:S,ref:r,target:c}))});var SEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(SEe||(SEe={}));var CEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(CEe||(CEe={}));function ibt(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=ar(),u=hc(),m=VUe(t,{relative:l});return k.useCallback(f=>{if(X1t(f,r)){f.preventDefault();let g=n!==void 0?n:Soe(u)===Soe(m);c(t,{replace:g,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,m,n,a,r,t,o,l,i])}function Ul(t){let s=k.useRef(vve(t)),r=k.useRef(!1),n=hc(),a=k.useMemo(()=>J1t(n.search,r.current?null:s.current),[n.search]),o=ar(),l=k.useCallback((i,c)=>{const u=vve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var obt=typeof Element<"u",lbt=typeof Map=="function",cbt=typeof Set=="function",dbt=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function bie(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(!bie(t[n],s[n]))return!1;return!0}var o;if(lbt&&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(!bie(n.value[1],s.get(n.value[0])))return!1;return!0}if(cbt&&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(dbt&&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(obt&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!bie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var ubt=function(s,r){try{return bie(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 hbt=Do(ubt);var mbt=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],m=0;c=new Error(s.replace(/%s/g,function(){return u[m++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},pbt=mbt;const MEe=Do(pbt);var fbt=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))(KUe||{}),vxe={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"]}},TEe=Object.values(KUe),X2e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},gbt=Object.entries(X2e).reduce((t,[s,r])=>(t[r]=s,t),{}),Yg="data-rh",dT={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},uT=(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},ybt=t=>{let s=uT(t,"title");const r=uT(t,dT.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=uT(t,dT.DEFAULT_TITLE);return s||n||void 0},vbt=t=>uT(t,dT.ON_CHANGE_CLIENT_STATE)||(()=>{}),bxe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),bbt=(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),nI=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&_bt(`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 m=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:bbt(["href"],t),bodyAttributes:bxe("bodyAttributes",t),defer:uT(t,dT.DEFER),encode:uT(t,dT.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:bxe("htmlAttributes",t),linkTags:nI("link",["rel","href"],t),metaTags:nI("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:nI("noscript",["innerHTML"],t),onChangeClientState:vbt(t),scriptTags:nI("script",["src","innerHTML"],t),styleTags:nI("style",["cssText"],t),title:ybt(t),titleAttributes:bxe("titleAttributes",t),prioritizeSeoTags:wbt(t,dT.PRIORITIZE_SEO_TAGS)}),ZUe=t=>Array.isArray(t)?t.join(""):t,Nbt=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(Nbt(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},AEe=(t,s)=>({...t,[s]:void 0}),kbt=["noscript","script","style"],bve=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),YUe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),Sbt=(t,s,r,n)=>{const a=YUe(r),o=ZUe(s);return a?`<${t} ${Yg}="true" ${a}>${bve(o,n)}`:`<${t} ${Yg}="true">${bve(o,n)}`},Cbt=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,m)=>{const f=typeof o[m]>"u"?m:`${m}="${bve(o[m],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=kbt.indexOf(t)===-1;return`${n}<${t} ${Yg}="true" ${l}${c?"/>":`>${i}`}`},""),QUe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=X2e[n];return r[a||n]=t[n],r},s),Mbt=(t,s,r)=>{const n={key:s,[Yg]:!0},a=QUe(r,n);return[mt.createElement("title",a,s)]},_ie=(t,s)=>s.map((r,n)=>{const a={key:n,[Yg]:!0};return Object.keys(r).forEach(o=>{const i=X2e[o]||o;if(i==="innerHTML"||i==="cssText"){const c=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:c}}else a[i]=r[o]}),mt.createElement(t,a)}),ux=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>Mbt(t,s.title,s.titleAttributes),toString:()=>Sbt(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>QUe(s),toString:()=>YUe(s)};default:return{toComponent:()=>_ie(t,s),toString:()=>Cbt(t,s,r)}}},Tbt=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=_xe(t,vxe.meta),o=_xe(s,vxe.link),l=_xe(r,vxe.script);return{priorityMethods:{toComponent:()=>[..._ie("meta",a.priority),..._ie("link",o.priority),..._ie("script",l.priority)],toString:()=>`${ux("meta",a.priority,n)} ${ux("link",o.priority,n)} ${ux("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},Abt=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:c,prioritizeSeoTags:u}=t;let{linkTags:m,metaTags:f,scriptTags:g}=t,y={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:y,linkTags:m,metaTags:f,scriptTags:g}=Tbt(t)),{priority:y,base:ux("base",s,n),bodyAttributes:ux("bodyAttributes",r,n),htmlAttributes:ux("htmlAttributes",a,n),link:ux("link",m,n),meta:ux("meta",f,n),noscript:ux("noscript",o,n),script:ux("script",g,n),style:ux("style",l,n),title:ux("title",{title:i,titleAttributes:c},n)}},_ve=Abt,nz=[],XUe=!!(typeof window<"u"&&window.document&&window.document.createElement),wve=class{constructor(t,s){Pn(this,"instances",[]);Pn(this,"canUseDOM",XUe);Pn(this,"context");Pn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?nz:this.instances,add:t=>{(this.canUseDOM?nz:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?nz:this.instances).indexOf(t);(this.canUseDOM?nz:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=_ve({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},Ebt={},JUe=mt.createContext(Ebt),K4,eVe=(K4=class extends k.Component{constructor(r){super(r);Pn(this,"helmetData");this.helmetData=new wve(this.props.context||{},K4.canUseDOM)}render(){return mt.createElement(JUe.Provider,{value:this.helmetData.value},this.props.children)}},Pn(K4,"canUseDOM",XUe),K4),k5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Yg}]`),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 m=u,f=typeof i[m]>"u"?"":i[m];c.setAttribute(u,f)}c.setAttribute(Yg,"true"),a.some((u,m)=>(l=m,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}},jve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Yg),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(Yg):r.getAttribute(Yg)!==l.join(",")&&r.setAttribute(Yg,l.join(","))},Pbt=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=ZUe(t)),jve("title",s)},EEe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:c,scriptTags:u,styleTags:m,title:f,titleAttributes:g}=t;jve("body",n),jve("html",a),Pbt(f,g);const y={baseTag:k5("base",r),linkTags:k5("link",o),metaTags:k5("meta",l),noscriptTags:k5("noscript",i),scriptTags:k5("script",u),styleTags:k5("style",m)},_={},w={};Object.keys(y).forEach(j=>{const{newTags:N,oldTags:S}=y[j];N.length&&(_[j]=N),S.length&&(w[j]=y[j].oldTags)}),s&&s(),c(t,_,w)},aI=null,Ibt=t=>{aI&&cancelAnimationFrame(aI),t.defer?aI=requestAnimationFrame(()=>{EEe(t,()=>{aI=null})}):(EEe(t),aI=null)},Lbt=Ibt,PEe=class extends k.Component{constructor(){super(...arguments);Pn(this,"rendered",!1)}shouldComponentUpdate(s){return!xbt(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=jbt(s.get().map(o=>{const l={...o.props};return delete l.context,l}));eVe.canUseDOM?Lbt(a):_ve&&(n=_ve(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}},Xye,Pl=(Xye=class extends k.Component{shouldComponentUpdate(t){return!hbt(AEe(this.props,"helmetData"),AEe(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 MEe(TEe.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 ${TEe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),MEe(!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 mt.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((c,u)=>(c[gbt[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 wve)){const a=n;n=new wve(a.context,!0),delete r.helmetData}return n?mt.createElement(PEe,{...r,context:n.value}):mt.createElement(JUe.Consumer,null,a=>mt.createElement(PEe,{...r,context:a}))}},Pn(Xye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Xye),Nve=function(t,s){return Nve=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])},Nve(t,s)};function tVe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");Nve(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var _x=function(){return _x=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 rVe(t,s){return function(r,n){s(r,n,t)}}function nVe(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,m=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,g=!1,y=r.length-1;y>=0;y--){var _={};for(var w in n)_[w]=w==="access"?{}:n[w];for(var w in n.access)_.access[w]=n.access[w];_.addInitializer=function(N){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var j=(0,r[y])(i==="accessor"?{get:m.get,set:m.set}:m[c],_);if(i==="accessor"){if(j===void 0)continue;if(j===null||typeof j!="object")throw new TypeError("Object expected");(f=l(j.get))&&(m.get=f),(f=l(j.set))&&(m.set=f),(f=l(j.init))&&a.unshift(f)}else(f=l(j))&&(i==="field"?a.unshift(f):m[c]=f)}u&&Object.defineProperty(u,n.name,m),g=!0}function aVe(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 J2e(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 uVe(){for(var t=[],s=0;s1||c(y,w)})},_&&(a[y]=_(a[y])))}function c(y,_){try{u(n[y](_))}catch(w){g(o[0][3],w)}}function u(y){y.value instanceof ZT?Promise.resolve(y.value.v).then(m,f):g(o[0][2],y)}function m(y){c("next",y)}function f(y){c("throw",y)}function g(y,_){y(_),o.shift(),o.length&&c(o[0][0],o[0][1])}}function pVe(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:ZT(t[a](l)),done:!1}:o?o(l):l}:o}}function fVe(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 Moe=="function"?Moe(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 xVe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var Dbt=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},kve=function(t){return kve=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},kve(t)};function gVe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=kve(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Lo(async()=>{const{default:n}=await Promise.resolve().then(()=>C3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class tje extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class IEe extends tje{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class LEe extends tje{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class DEe extends tje{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var Sve;(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"})(Sve||(Sve={}));class Bbt{constructor(s,{headers:r={},customFetch:n,region:a=Sve.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=zbt(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return Na(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:c}=n;let u={},{region:m}=n;m||(m=this.region);const f=new URL(`${this.url}/${r}`);m&&m!=="any"&&(u["x-region"]=m,f.searchParams.set("forceFunctionRegion",m));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 y=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 IEe(N)}),_=y.headers.get("x-relay-error");if(_&&_==="true")throw new LEe(y);if(!y.ok)throw new DEe(y);let w=((a=y.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),j;return w==="application/json"?j=yield y.json():w==="application/octet-stream"||w==="application/pdf"?j=yield y.blob():w==="text/event-stream"?j=y:w==="multipart/form-data"?j=yield y.formData():j=yield y.text(),{data:j,error:null,response:y}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new IEe(o)}:{data:null,error:o,response:o instanceof DEe||o instanceof LEe?o.context:void 0}}})}}var xp={};const lE=Z9e(Fbt);var az={},iz={},oz={},lz={},cz={},$bt=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")},YT=$bt();const qbt=YT.fetch,kVe=YT.fetch.bind(YT),SVe=YT.Headers,Ubt=YT.Request,Vbt=YT.Response,C3=Object.freeze(Object.defineProperty({__proto__:null,Headers:SVe,Request:Ubt,Response:Vbt,default:kVe,fetch:qbt},Symbol.toStringTag,{value:"Module"})),Hbt=Z9e(C3);var dz={},OEe;function CVe(){if(OEe)return dz;OEe=1,Object.defineProperty(dz,"__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 dz.default=t,dz}var REe;function MVe(){if(REe)return cz;REe=1,Object.defineProperty(cz,"__esModule",{value:!0});const t=lE,s=t.__importDefault(Hbt),r=t.__importDefault(CVe());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 m,f,g,y;let _=null,w=null,j=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")&&(!((m=this.headers.get("Accept"))===null||m===void 0)&&m.includes("application/vnd.pgrst.plan+text"))?w=O:w=JSON.parse(O))}const I=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),P=(g=u.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");I&&P&&P.length>1&&(j=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(_={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,j=null,N=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const I=await u.text();try{_=JSON.parse(I),Array.isArray(_)&&u.status===404&&(w=[],_=null,N=200,S="OK")}catch{u.status===404&&I===""?(N=204,S="No Content"):_={message:I}}if(_&&this.isMaybeSingle&&(!((y=_==null?void 0:_.details)===null||y===void 0)&&y.includes("0 rows"))&&(_=null,N=200,S="OK"),_&&this.shouldThrowOnError)throw new r.default(_)}return{error:_,data:w,count:j,status:N,statusText:S}});return this.shouldThrowOnError||(c=c.catch(u=>{var m,f,g;return{error:{message:`${(m=u==null?void 0:u.name)!==null&&m!==void 0?m:"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 cz.default=n,cz}var FEe;function TVe(){if(FEe)return lz;FEe=1,Object.defineProperty(lz,"__esModule",{value:!0});const s=lE.__importDefault(MVe());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",m=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${m?`${m},`:""}${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 m;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),g=(m=this.headers.get("Accept"))!==null&&m!==void 0?m:"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 lz.default=r,lz}var zEe;function sje(){if(zEe)return oz;zEe=1,Object.defineProperty(oz,"__esModule",{value:!0});const s=lE.__importDefault(TVe()),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 m=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${m}.${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 oz.default=n,oz}var BEe;function AVe(){if(BEe)return iz;BEe=1,Object.defineProperty(iz,"__esModule",{value:!0});const s=lE.__importDefault(sje());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 m=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",m),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((m,f)=>m.concat(Object.keys(f)),[]);if(u.length>0){const m=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.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 m="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,y)=>g.concat(Object.keys(y)),[]);if(f.length>0){const g=[...new Set(f)].map(y=>`"${y}"`);this.url.searchParams.set("columns",g.join(","))}}return new s.default({method:m,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 iz.default=r,iz}var $Ee;function Gbt(){if($Ee)return az;$Ee=1,Object.defineProperty(az,"__esModule",{value:!0});const t=lE,s=t.__importDefault(AVe()),r=t.__importDefault(sje());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 m;let f;const g=new URL(`${this.url}/rpc/${o}`);let y;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([w,j])=>j!==void 0).map(([w,j])=>[w,Array.isArray(j)?`{${j.join(",")}}`:`${j}`]).forEach(([w,j])=>{g.searchParams.append(w,j)})):(f="POST",y=l);const _=new Headers(this.headers);return u&&_.set("Prefer",`count=${u}`),new r.default({method:f,url:g,headers:_,schema:this.schemaName,body:y,fetch:(m=this.fetch)!==null&&m!==void 0?m:fetch})}}return az.default=n,az}Object.defineProperty(xp,"__esModule",{value:!0});var EVe=xp.PostgrestError=$Ve=xp.PostgrestBuilder=zVe=xp.PostgrestTransformBuilder=RVe=xp.PostgrestFilterBuilder=DVe=xp.PostgrestQueryBuilder=IVe=xp.PostgrestClient=void 0;const cE=lE,PVe=cE.__importDefault(Gbt());var IVe=xp.PostgrestClient=PVe.default;const LVe=cE.__importDefault(AVe());var DVe=xp.PostgrestQueryBuilder=LVe.default;const OVe=cE.__importDefault(sje());var RVe=xp.PostgrestFilterBuilder=OVe.default;const FVe=cE.__importDefault(TVe());var zVe=xp.PostgrestTransformBuilder=FVe.default;const BVe=cE.__importDefault(MVe());var $Ve=xp.PostgrestBuilder=BVe.default;const qVe=cE.__importDefault(CVe());EVe=xp.PostgrestError=qVe.default;var UVe=xp.default={PostgrestClient:PVe.default,PostgrestQueryBuilder:LVe.default,PostgrestFilterBuilder:OVe.default,PostgrestTransformBuilder:FVe.default,PostgrestBuilder:BVe.default,PostgrestError:qVe.default};const Wbt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return $Ve},get PostgrestClient(){return IVe},get PostgrestError(){return EVe},get PostgrestFilterBuilder(){return RVe},get PostgrestQueryBuilder(){return DVe},get PostgrestTransformBuilder(){return zVe},default:UVe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:Kbt,PostgrestQueryBuilder:WAs,PostgrestFilterBuilder:KAs,PostgrestTransformBuilder:ZAs,PostgrestBuilder:YAs,PostgrestError:QAs}=UVe||Wbt;class Zbt{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 Ybt="2.78.0",Qbt=`realtime-js/${Ybt}`,Xbt="1.0.0",Cve=1e4,Jbt=1e3,e_t=100;var r8;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(r8||(r8={}));var gu;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(gu||(gu={}));var Bg;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Bg||(Bg={}));var Mve;(function(t){t.websocket="websocket"})(Mve||(Mve={}));var p4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(p4||(p4={}));class t_t{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 VVe{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 Ql;(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"})(Ql||(Ql={}));const qEe=(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]=s_t(l,t,s,a),o),{}):{}},s_t=(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)?HVe(o,l):Tve(l)},HVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return i_t(s,r)}switch(t){case Ql.bool:return r_t(s);case Ql.float4:case Ql.float8:case Ql.int2:case Ql.int4:case Ql.int8:case Ql.numeric:case Ql.oid:return n_t(s);case Ql.json:case Ql.jsonb:return a_t(s);case Ql.timestamp:return o_t(s);case Ql.abstime:case Ql.date:case Ql.daterange:case Ql.int4range:case Ql.int8range:case Ql.money:case Ql.reltime:case Ql.text:case Ql.time:case Ql.timestamptz:case Ql.timetz:case Ql.tsrange:case Ql.tstzrange:return Tve(s);default:return Tve(s)}},Tve=t=>t,r_t=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},n_t=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},a_t=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},i_t=(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=>HVe(s,i))}return t},o_t=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 wxe{constructor(s,r,n={},a=Cve){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 UEe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(UEe||(UEe={}));class n8{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=n8.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=n8.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=n8.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,m)=>{l[u]||(c[u]=m)}),this.map(l,(u,m)=>{const f=o[u];if(f){const g=m.map(j=>j.presence_ref),y=f.map(j=>j.presence_ref),_=m.filter(j=>y.indexOf(j.presence_ref)<0),w=f.filter(j=>g.indexOf(j.presence_ref)<0);_.length>0&&(i[u]=_),w.length>0&&(c[u]=w)}else i[u]=m}),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 m=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(c),m.length>0){const f=s[i].map(y=>y.presence_ref),g=m.filter(y=>f.indexOf(y.presence_ref)<0);s[i].unshift(...g)}n(i,m,c)}),this.map(l,(i,c)=>{let u=s[i];if(!u)return;const m=c.map(f=>f.presence_ref);u=u.filter(f=>m.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 VEe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(VEe||(VEe={}));var a8;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(a8||(a8={}));var zv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(zv||(zv={}));class rje{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=gu.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 wxe(this,Bg.join,this.params,this.timeout),this.rejoinTimer=new VVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=gu.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=gu.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=gu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=gu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=gu.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Bg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new n8(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==gu.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(y=>y.filter))!==null&&a!==void 0?a:[],m=!!this.bindings[a8.PRESENCE]&&this.bindings[a8.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:m}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(y=>s==null?void 0:s(zv.CHANNEL_ERROR,y)),this._onClose(()=>s==null?void 0:s(zv.CLOSED)),this.updateJoinPayload(Object.assign({config:g},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:y})=>{var _;if(this.socket.setAuth(),y===void 0){s==null||s(zv.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,j=(_=w==null?void 0:w.length)!==null&&_!==void 0?_:0,N=[];for(let S=0;S{this.state=gu.errored,s==null||s(zv.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(y).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(zv.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===gu.joined&&s===a8.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=gu.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Bg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new wxe(this,Bg.leave,{},s),n.receive("ok",()=>{r(),a("ok")}).receive("timeout",()=>{r(),a("timed out")}).receive("error",()=>{a("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=gu.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 wxe(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>e_t){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:m}=Bg;if(n&&[i,c,u,m].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(y=>{var _,w,j;return((_=y.filter)===null||_===void 0?void 0:_.event)==="*"||((j=(w=y.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===l}).map(y=>y.callback(g,n)):(o=this.bindings[l])===null||o===void 0||o.filter(y=>{var _,w,j,N,S,M;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in y){const I=y.id,P=(_=y.filter)===null||_===void 0?void 0:_.event;return I&&((w=r.ids)===null||w===void 0?void 0:w.includes(I))&&(P==="*"||(P==null?void 0:P.toLocaleLowerCase())===((j=r.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{const I=(S=(N=y==null?void 0:y.filter)===null||N===void 0?void 0:N.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return I==="*"||I===((M=r==null?void 0:r.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return y.type.toLocaleLowerCase()===l}).map(y=>{if(typeof g=="object"&&"ids"in g){const _=g.data,{schema:w,table:j,commit_timestamp:N,type:S,errors:M}=_;g=Object.assign(Object.assign({},{schema:w,table:j,commit_timestamp:N,eventType:S,new:{},old:{},errors:M}),this._getPayloadRecords(_))}y.callback(g,n)})}_isClosed(){return this.state===gu.closed}_isJoined(){return this.state===gu.joined}_isJoining(){return this.state===gu.joining}_isLeaving(){return this.state===gu.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&&rje.isEqual(a.filter,r))})),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(Bg.close,{},s)}_onError(s){this._on(Bg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=gu.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=qEe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=qEe(s.columns,s.old_record)),r}}const jxe=()=>{},uz={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},l_t=[1e3,2e3,5e3,1e4],c_t=1e4,d_t=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class u_t{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=Cve,this.transport=null,this.heartbeatIntervalMs=uz.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=jxe,this.ref=0,this.reconnectTimer=null,this.logger=jxe,this.conn=null,this.sendBuffer=[],this.serializer=new t_t,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)=>Lo(async()=>{const{default:i}=await Promise.resolve().then(()=>C3);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}/${Mve.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=Zbt.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:Xbt}))}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 r8.connecting:return p4.Connecting;case r8.open:return p4.Open;case r8.closing:return p4.Closing;default:return p4.Closed}}isConnected(){return this.connectionState()===p4.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 rje(`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(Jbt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},uz.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(Bg.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([d_t],{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:Qbt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Bg.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(s="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${s}`,r)})}_triggerStateCallbacks(s,r){try{this.stateChangeCallbacks[s].forEach(n=>{try{n(r)}catch(a){this.log("error",`error in ${s} callback`,a)}})}catch(n){this.log("error",`error triggering ${s} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new VVe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},uz.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,c,u,m;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:Cve,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:uz.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:jxe,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=>l_t[f-1]||c_t,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,g)=>g(JSON.stringify(f)),this.decode=(m=s==null?void 0:s.decode)!==null&&m!==void 0?m: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 nje extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Qc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class h_t extends nje{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 Ave extends nje{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const aje=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Lo(async()=>{const{default:n}=await Promise.resolve().then(()=>C3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},m_t=()=>Na(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Lo(()=>Promise.resolve().then(()=>C3),void 0)).Response:Response}),Eve=t=>{if(Array.isArray(t))return t.map(r=>Eve(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]=Eve(n)}),s},p_t=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)},Nxe=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)},f_t=(t,s,r)=>Na(void 0,void 0,void 0,function*(){const n=yield m_t();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 h_t(Nxe(a),o,l))}).catch(a=>{s(new Ave(Nxe(a),a))}):s(new Ave(Nxe(t),t))}),x_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(p_t(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 $O(t,s,r,n,a,o){return Na(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,x_t(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=>f_t(c,i,n))})})}function dD(t,s,r,n){return Na(this,void 0,void 0,function*(){return $O(t,"GET",s,r,n)})}function Og(t,s,r,n,a){return Na(this,void 0,void 0,function*(){return $O(t,"POST",s,n,a,r)})}function Pve(t,s,r,n,a){return Na(this,void 0,void 0,function*(){return $O(t,"PUT",s,n,a,r)})}function g_t(t,s,r,n){return Na(this,void 0,void 0,function*(){return $O(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function ije(t,s,r,n,a){return Na(this,void 0,void 0,function*(){return $O(t,"DELETE",s,n,a,r)})}class y_t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return Na(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Qc(s))return{data:null,error:s};throw s}})}}var WVe;class v_t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[WVe]="BlobDownloadBuilder",this.promise=null}asStream(){return new y_t(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 Na(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Qc(s))return{data:null,error:s};throw s}})}}WVe=Symbol.toStringTag;const b_t={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},HEe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class __t{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=aje(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return Na(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},HEe),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),m=this._getFinalPath(u),f=yield(s=="PUT"?Pve:Og)(this.fetch,`${this.url}/object/${m}`,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(Qc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return Na(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return Na(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:HEe.upsert},a),m=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,m["cache-control"]=`max-age=${u.cacheControl}`,m["content-type"]=u.contentType);const f=yield Pve(this.fetch,i.toString(),c,{headers:m});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Qc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return Na(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 Og(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 nje("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}update(s,r,n){return Na(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return Na(this,void 0,void 0,function*(){try{return{data:yield Og(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(Qc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return Na(this,void 0,void 0,function*(){try{return{data:{path:(yield Og(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(Qc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return Na(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Og(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(Qc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return Na(this,void 0,void 0,function*(){try{const a=yield Og(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(Qc(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=()=>dD(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new v_t(c,this.shouldThrowOnError)}info(s){return Na(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield dD(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:Eve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}exists(s){return Na(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield g_t(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n)&&n instanceof Ave){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 Na(this,void 0,void 0,function*(){try{return{data:yield ije(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}list(s,r,n){return Na(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},b_t),r),{prefix:s||""});return{data:yield Og(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}listV2(s,r){return Na(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Og(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(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 KVe="2.78.0",ZVe={"X-Client-Info":`storage-js/${KVe}`};class w_t{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({},ZVe),r),this.fetch=aje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return Na(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield dD(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}getBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield dD(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}createBucket(s){return Na(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Og(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(Qc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return Na(this,void 0,void 0,function*(){try{return{data:yield Pve(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(Qc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield Og(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield ije(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(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 j_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},ZVe),r),this.fetch=aje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield Og(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}listBuckets(s){return Na(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 dD(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield ije(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}}const oje={"X-Client-Info":`storage-js/${KVe}`,"Content-Type":"application/json"};class YVe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function cf(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class kxe extends YVe{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 N_t extends YVe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var GEe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(GEe||(GEe={}));const lje=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Lo(async()=>{const{default:n}=await Promise.resolve().then(()=>C3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},k_t=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)},WEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),S_t=(t,s,r)=>Na(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 kxe(WEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new kxe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new kxe(i,a,l))}}else s(new N_t(WEe(t),t))}),C_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(k_t(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 M_t(t,s,r,n,a,o){return Na(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,C_t(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=>S_t(c,i,n))})})}function df(t,s,r,n,a){return Na(this,void 0,void 0,function*(){return M_t(t,"POST",s,n,a,r)})}class T_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},oje),r),this.fetch=lje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return Na(this,void 0,void 0,function*(){try{return{data:(yield df(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}getIndex(s,r){return Na(this,void 0,void 0,function*(){try{return{data:yield df(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(cf(n))return{data:null,error:n};throw n}})}listIndexes(s){return Na(this,void 0,void 0,function*(){try{return{data:yield df(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return Na(this,void 0,void 0,function*(){try{return{data:(yield df(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(cf(n))return{data:null,error:n};throw n}})}}class A_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},oje),r),this.fetch=lje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return Na(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 df(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}getVectors(s){return Na(this,void 0,void 0,function*(){try{return{data:yield df(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}listVectors(s){return Na(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 df(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}queryVectors(s){return Na(this,void 0,void 0,function*(){try{return{data:yield df(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}deleteVectors(s){return Na(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 df(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}}class E_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},oje),r),this.fetch=lje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:(yield df(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}getBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:yield df(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}listBuckets(){return Na(this,arguments,void 0,function*(s={}){try{return{data:yield df(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}deleteBucket(s){return Na(this,void 0,void 0,function*(){try{return{data:(yield df(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(cf(r))return{data:null,error:r};throw r}})}}class P_t extends E_t{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new I_t(this.url,this.headers,s,this.fetch)}}class I_t extends T_t{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return Na(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 Na(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 Na(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 Na(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new L_t(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class L_t extends A_t{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 Na(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 Na(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 Na(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 Na(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 Na(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class D_t extends w_t{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new __t(this.url,this.headers,s,this.fetch)}get vectors(){return new P_t(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new j_t(this.url+"/iceberg",this.headers,this.fetch)}}const O_t="2.78.0";let zI="";typeof Deno<"u"?zI="deno":typeof document<"u"?zI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?zI="react-native":zI="node";const R_t={"X-Client-Info":`supabase-js-${zI}/${O_t}`},F_t={headers:R_t},z_t={schema:"public"},B_t={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},$_t={},q_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=kVe:s=fetch,(...r)=>s(...r)},U_t=()=>typeof Headers>"u"?SVe:Headers,V_t=(t,s,r)=>{const n=q_t(r),a=U_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 H_t(t){return t.endsWith("/")?t:t+"/"}function G_t(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:c,auth:u,realtime:m,global:f}=s,g={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},m),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 W_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(H_t(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const QVe="2.78.0",Q5=30*1e3,Ive=3,Sxe=Ive*Q5,K_t="http://localhost:9999",Z_t="supabase.auth.token",Y_t={"X-Client-Info":`gotrue-js/${QVe}`},Lve="X-Supabase-Api-Version",XVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Q_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,X_t=10*60*1e3;class uD extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ha(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class J_t extends uD{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function ewt(t){return Ha(t)&&t.name==="AuthApiError"}class f4 extends uD{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class Lw extends uD{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class Ag extends Lw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function twt(t){return Ha(t)&&t.name==="AuthSessionMissingError"}class S5 extends Lw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class hz extends Lw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class mz extends Lw{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 swt(t){return Ha(t)&&t.name==="AuthImplicitGrantRedirectError"}class KEe extends Lw{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 Dve extends Lw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function Cxe(t){return Ha(t)&&t.name==="AuthRetryableFetchError"}class ZEe extends Lw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Ove extends Lw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const Toe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),YEe=` \r=`.split(""),rwt=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(Toe[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(Toe[n]),s.queuedBits-=6}}function JVe(t,s,r){const n=rwt[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 XEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{iwt(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 awt(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}nwt(n,s)}}function iwt(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 hT(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function w4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>QEe(a,r,n)),QEe(null,r,n),s.join("")}function lwt(t){return Math.round(Date.now()/1e3)+t}function cwt(){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 wm=()=>typeof window<"u"&&typeof document<"u",$2={tested:!1,writable:!1},eHe=()=>{if(!wm())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if($2.tested)return $2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),$2.tested=!0,$2.writable=!0}catch{$2.tested=!0,$2.writable=!1}return $2.writable};function dwt(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 tHe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Lo(async()=>{const{default:n}=await Promise.resolve().then(()=>C3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},uwt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",X5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},q2=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Bb=async(t,s)=>{await t.removeItem(s)};class Hde{constructor(){this.promise=new Hde.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Hde.promiseConstructor=Promise;function Mxe(t){const s=t.split(".");if(s.length!==3)throw new Ove("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function mwt(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 pwt(t){return("0"+t.toString(16)).substr(-2)}function fwt(){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,pwt).join("")}async function xwt(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 gwt(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 xwt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function C5(t,s,r=!1){const n=fwt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await X5(t,`${s}-code-verifier`,a);const o=await gwt(n);return[o,n===o?"plain":"s256"]}const ywt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function vwt(t){const s=t.headers.get(Lve);if(!s||!s.match(ywt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function bwt(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 _wt(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 wwt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function M5(t){if(!wwt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Txe(){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 jwt(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 JEe(t){return JSON.parse(JSON.stringify(t))}const l4=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Nwt=[502,503,504];async function e6e(t){var s;if(!uwt(t))throw new Dve(l4(t),0);if(Nwt.includes(t.status))throw new Dve(l4(t),t.status);let r;try{r=await t.json()}catch(o){throw new f4(l4(o),o)}let n;const a=vwt(t);if(a&&a.getTime()>=XVe["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 ZEe(l4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new Ag}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 ZEe(l4(r),t.status,r.weak_password.reasons);throw new J_t(l4(r),t.status||500,n)}const kwt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function Si(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[Lve]||(o[Lve]=XVe["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 Swt(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 Swt(t,s,r,n,a,o){const l=kwt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new Dve(l4(c),0)}if(i.ok||await e6e(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await e6e(c)}}function Eg(t){var s;let r=null;Twt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=lwt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function t6e(t){const s=Eg(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 m_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function Cwt(t){return{data:t,error:null}}function Mwt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Iw(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 s6e(t){return t}function Twt(t){return t.access_token&&t.refresh_token&&t.expires_in}const Axe=["global","local","others"];class Awt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=tHe(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=Axe[0]){if(Axe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Axe.join(", ")}`);try{return await Si(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ha(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await Si(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:m_})}catch(n){if(Ha(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=Iw(s,["options"]),a=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await Si(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:Mwt,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ha(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await Si(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:m_})}catch(r){if(Ha(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},m=await Si(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:s6e});if(m.error)throw m.error;const f=await m.json(),g=(l=m.headers.get("x-total-count"))!==null&&l!==void 0?l:0,y=(c=(i=m.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return y.length>0&&(y.forEach(_=>{const w=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(_.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ha(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){M5(s);try{return await Si(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:m_})}catch(r){if(Ha(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){M5(s);try{return await Si(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:m_})}catch(n){if(Ha(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){M5(s);try{return await Si(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:m_})}catch(n){if(Ha(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){M5(s.userId);try{const{data:r,error:n}=await Si(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:n}}catch(r){if(Ha(r))return{data:null,error:r};throw r}}async _deleteFactor(s){M5(s.userId),M5(s.id);try{return{data:await Si(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ha(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},m=await Si(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:s6e});if(m.error)throw m.error;const f=await m.json(),g=(l=m.headers.get("x-total-count"))!==null&&l!==void 0?l:0,y=(c=(i=m.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return y.length>0&&(y.forEach(_=>{const w=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(_.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ha(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await Si(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ha(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await Si(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ha(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await Si(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ha(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await Si(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ha(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await Si(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ha(r))return{data:null,error:r};throw r}}}function r6e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const T5={debug:!!(globalThis&&eHe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class sHe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class Ewt extends sHe{}async function Pwt(t,s,r){T5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),T5.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){T5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{T5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw T5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Ewt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(T5.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 Iwt(){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 rHe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Lwt(t){return parseInt(t,16)}function Dwt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function Owt(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:c,resources:u,scheme:m,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 y=rHe(t.address),_=m?`${m}://${n}`:n,w=t.statement?`${t.statement} `:"",j=`${_} wants you to sign in with your Ethereum account: ${y} ${w}`;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`${j} ${N}`}class Xd 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 Aoe extends Xd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Rwt({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 Xd({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 Xd({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 Xd({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 Xd({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 Xd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Xd({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 Xd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Xd({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(nHe(l)){if(o.rp.id!==l)return new Xd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Xd({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 Xd({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 Xd({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 Xd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Fwt({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 Xd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Xd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(nHe(n)){if(r.rpId!==n)return new Xd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Xd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Xd({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 Xd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class zwt{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 Bwt=new zwt;function $wt(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=Iw(t,["challenge","user","excludeCredentials"]),o=hT(s).buffer,l=Object.assign(Object.assign({},r),{id:hT(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]=Eoe(i,l):n[o]=Eoe(l)}else n[o]=l}return n}function Zwt(t,s){return Eoe(Wwt,t,s||{})}function Ywt(t,s){return Eoe(Kwt,t,s||{})}class Qwt{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??Bwt.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=Zwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:m,error:f}=await Hwt({publicKey:u,signal:c});return m?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:m}},error:null}:{data:null,error:f}}case"request":{const u=Ywt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:m,error:f}=await Gwt(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:c}));return m?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:m}},error:null}:{data:null,error:f}}}}catch(l){return Ha(l)?{data:null,error:l}:{data:null,error:new f4("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 uD("rpId is required for WebAuthn authentication")};try{if(!n6e())return{data:null,error:new f4("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 Ha(l)?{data:null,error:l}:{data:null,error:new f4("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 uD("rpId is required for WebAuthn registration")};try{if(!n6e())return{data:null,error:new f4("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(m=>{var f;return(f=m.data)===null||f===void 0?void 0:f.all.find(g=>g.factor_type==="webauthn"&&g.friendly_name===s&&g.status!=="unverified")}).then(m=>m?this.client.mfa.unenroll({factorId:m==null?void 0:m.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 Ha(l)?{data:null,error:l}:{data:null,error:new f4("Unexpected error in register",l)}}}}Iwt();const Xwt={url:K_t,storageKey:Z_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Y_t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function a6e(t,s,r){return await r()}const A5={};class hD{get jwks(){var s,r;return(r=(s=A5[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){A5[this.storageKey]=Object.assign(Object.assign({},A5[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=A5[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){A5[this.storageKey]=Object.assign(Object.assign({},A5[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=hD.nextInstanceID,hD.nextInstanceID+=1,this.instanceID>0&&wm()&&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({},Xwt),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 Awt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=tHe(a.fetch),this.lock=a.lock||a6e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:wm()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=Pwt:this.lock=a6e,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 Qwt(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:eHe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=r6e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=r6e(this.memoryStorage)),wm()&&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} (${QVe}) ${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=dwt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),wm()&&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),swt(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 Ha(r)?{error:r}:{error:new f4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await Si(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.captchaToken}},xform:Eg}),{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(Ha(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:m,password:f,options:g}=s;let y=null,_=null;this.flowType==="pkce"&&([y,_]=await C5(this.storage,this.storageKey)),o=await Si(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:g==null?void 0:g.emailRedirectTo,body:{email:m,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:y,code_challenge_method:_},xform:Eg})}else if("phone"in s){const{phone:m,password:f,options:g}=s;o=await Si(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:m,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:Eg})}else throw new hz("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(Ha(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(s){try{let r;if("email"in s){const{email:o,password:l,options:i}=s;r=await Si(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:t6e})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await Si(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:t6e})}else throw new hz("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 S5}:(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(Ha(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,m,f,g;let y,_;if("message"in s)y=s.message,_=s.signature;else{const{chain:w,wallet:j,statement:N,options:S}=s;let M;if(wm())if(typeof j=="object")M=j;else{const z=window;if("ethereum"in z&&typeof z.ethereum=="object"&&"request"in z.ethereum&&typeof z.ethereum.request=="function")M=z.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof j!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=j}const I=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),P=await M.request({method:"eth_requestAccounts"}).then(z=>z).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!P||P.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const O=rHe(P[0]);let q=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!q){const z=await M.request({method:"eth_chainId"});q=Lwt(z)}const $={domain:I.host,address:O,statement:N,uri:I.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:(m=S==null?void 0:S.signInWithEthereum)===null||m===void 0?void 0:m.resources};y=Owt($),_=await M.request({method:"personal_sign",params:[Dwt(y),O]})}try{const{data:w,error:j}=await Si(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:y,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:Eg});if(j)throw j;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new S5}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:j})}catch(w){if(Ha(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,m,f,g,y;let _,w;if("message"in s)_=s.message,w=s.signature;else{const{chain:j,wallet:N,statement:S,options:M}=s;let I;if(wm())if(typeof N=="object")I=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"))I=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.");I=N}const P=new URL((r=M==null?void 0:M.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in I&&I.signIn){const O=await I.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},M==null?void 0:M.signInWithSolana),{version:"1",domain:P.host,uri:P.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),w=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in I)||typeof I.signMessage!="function"||!("publicKey"in I)||typeof I!="object"||!I.publicKey||!("toBase58"in I.publicKey)||typeof I.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${P.host} wants you to sign in with your Solana account:`,I.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${P.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=(m=M==null?void 0:M.signInWithSolana)===null||m===void 0?void 0:m.resources)===null||f===void 0)&&f.length?["Resources",...M.signInWithSolana.resources.map(q=>`- ${q}`)]:[]].join(` `);const O=await I.signMessage(new TextEncoder().encode(_),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=O}}try{const{data:j,error:N}=await Si(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:w4(w)},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(y=s.options)===null||y===void 0?void 0:y.captchaToken}}:null),xform:Eg});if(N)throw N;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new S5}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:N})}catch(j){if(Ha(j))return{data:{user:null,session:null},error:j};throw j}}async _exchangeCodeForSession(s){const r=await q2(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await Si(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:Eg});if(await Bb(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new S5}:(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(Ha(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(s){try{const{options:r,provider:n,token:a,access_token:o,nonce:l}=s,i=await Si(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:a,access_token:o,nonce:l,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Eg}),{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 S5}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Ha(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,m=null;this.flowType==="pkce"&&([u,m]=await C5(this.storage,this.storageKey));const{error:f}=await Si(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:m},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:m}=await Si(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:m}}throw new hz("You must provide either an email or phone number.")}catch(i){if(Ha(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(s){var r,n;try{let a,o;"options"in s&&(a=(r=s.options)===null||r===void 0?void 0:r.redirectTo,o=(n=s.options)===null||n===void 0?void 0:n.captchaToken);const{data:l,error:i}=await Si(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Eg});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(Ha(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 C5(this.storage,this.storageKey)),await Si(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:(n=(r=s.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:Cwt})}catch(o){if(Ha(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 Ag;const{error:a}=await Si(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ha(s))return{data:{user:null,session:null},error:s};throw s}}async resend(s){try{const r=`${this.url}/resend`;if("email"in s){const{email:n,type:a,options:o}=s,{error:l}=await Si(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return{data:{user:null,session:null},error:l}}else if("phone"in s){const{phone:n,type:a,options:o}=s,{data:l,error:i}=await Si(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return{data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:i}}throw new hz("You must provide either an email or phone number and a type")}catch(r){if(Ha(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 q2(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(s){try{return s?await Si(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:m_}):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 Ag}:await Si(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(a=l.session)===null||a===void 0?void 0:a.access_token)!==null&&o!==void 0?o:void 0,xform:m_})})}catch(r){if(Ha(r))return twt(r)&&(await this._removeSession(),await Bb(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 Ag;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await C5(this.storage,this.storageKey));const{data:u,error:m}=await Si(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:c}),jwt:l.access_token,xform:m_});if(m)throw m;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(Ha(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 Ag;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(Ha(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 Ag;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(Ha(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!wm())throw new mz("No browser detected.");if(s.error||s.error_description||s.error_code)throw new mz(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 KEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new mz("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 KEe("No code detected.");const{data:S,error:M}=await this._exchangeCodeForSession(s.code);if(M)throw M;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:c,token_type:u}=s;if(!o||!i||!l||!u)throw new mz("No session defined in URL");const m=Math.round(Date.now()/1e3),f=parseInt(i);let g=m+f;c&&(g=parseInt(c));const y=g-m;y*1e3<=Q5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${f}s`);const _=g-f;m-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,g,m):m-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,g,m);const{data:w,error:j}=await this._getUser(o);if(j)throw j;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:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Ha(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 q2(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&&!(ewt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Bb(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=cwt(),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 C5(this.storage,this.storageKey,!0));try{return await Si(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(Ha(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(Ha(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,m;const{data:f,error:g}=o;if(g)throw g;const y=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 Si(this.fetch,"GET",y,{headers:this.headers,jwt:(m=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&m!==void 0?m:void 0})});if(a)throw a;return wm()&&!(!((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(Ha(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:m}=s,f=await Si(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=o==null?void 0:o.access_token)!==null&&n!==void 0?n:void 0,body:{provider:i,id_token:c,access_token:u,nonce:m,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:Eg}),{data:g,error:y}=f;return y?{data:{user:null,session:null},error:y}:!g||!g.session||!g.user?{data:{user:null,session:null},error:new S5}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("USER_UPDATED",g.session)),{data:g,error:y})}catch(a){if(Ha(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)throw l;return await Si(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(a=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(Ha(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 mwt(async a=>(a>0&&await hwt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await Si(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:Eg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&Cxe(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(),Q5);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)/Q5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${Q5}ms, refresh threshold is ${Ive} ticks`),a<=Ive&&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 sHe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!wm()||!(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 C5(this.storage,this.storageKey),i=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(l)}`});a.push(i.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);a.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&a.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${s}?${a.join("&")}`}async _unenroll(s){try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;return o?{data:null,error:o}:await Si(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Ha(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 Si(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return 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(Ha(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"?Uwt(s.webauthn.credential_response):Vwt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await Si(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return 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(Ha(r))return{data:null,error:r};throw r}})}async _challenge(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=await Si(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:s,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});if(l.error)return l;const{data:i}=l;if(i.type!=="webauthn")return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:$wt(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:qwt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ha(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(m=>m.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 Si(this.fetch,"GET",`${this.url}/oauth/authorizations/${s}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):{data:null,error:new Ag}})}catch(r){if(Ha(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 Ag};const l=await Si(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&wm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ha(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 Ag};const l=await Si(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&wm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ha(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+X_t>a)return n;const{data:o,error:l}=await Si(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:y,error:_}=await this.getSession();if(_||!y.session)return{data:null,error:_};n=y.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=Mxe(n);r!=null&&r.allowExpired||bwt(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:y}=await this.getUser(n);if(y)throw y;return{data:{claims:o,header:a,signature:l},error:null}}const m=_wt(a.alg),f=await crypto.subtle.importKey("jwk",u,m,!0,["verify"]);if(!await crypto.subtle.verify(m,f,l,owt(`${i}.${c}`)))throw new Ove("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ha(n))return{data:null,error:n};throw n}}}hD.nextInstanceID=0;const Jwt=hD;class e2t extends Jwt{constructor(s){super(s)}}class t2t{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=W_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:z_t,realtime:$_t,auth:Object.assign(Object.assign({},B_t),{storageKey:c}),global:F_t},m=G_t(n??{},u);this.storageKey=(a=m.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=m.global.headers)!==null&&o!==void 0?o:{},m.accessToken?(this.accessToken=m.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=m.auth)!==null&&l!==void 0?l:{},this.headers,m.global.fetch),this.fetch=V_t(r,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.rest=new Kbt(new URL("rest/v1",i).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch}),this.storage=new D_t(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new Bbt(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},m,f){const g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new e2t({url:this.authUrl.href,headers:Object.assign(Object.assign({},g),m),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(y=>y.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new u_t(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 s2t=(t,s,r)=>new t2t(t,s,r);function r2t(){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}r2t()&&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 n2t="https://relzejiswnotikjgvjhz.supabase.co",a2t="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",H=s2t(n2t,a2t,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),aHe=k.createContext(void 0),i2t=({children:t})=>{const[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState(null),[w,j]=k.useState([]),[N,S]=k.useState(null),M=k.useRef(null),I=k.useRef(!1),P=k.useRef(!1),O=ar(),q=()=>{m(!1),g(!1),_(null),j([]),S(null),M.current=null,I.current=!1},$=async Y=>{if(!(I.current&&M.current===Y)&&!P.current){P.current=!0,c(!0);try{console.log("Checking roles via RPC for user:",Y);const[{data:J,error:Q},{data:ce,error:ne}]=await Promise.all([H.rpc("has_role",{_user_id:Y,_role:"admin"}),H.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(Q||ne)console.error("Role RPC errors:",{isAdminError:Q,isBrokerError:ne}),m(!1),g(!1);else{const he=!!J,xe=!!ce;console.log("RPC roles result:",{adminValue:he,brokerValue:xe}),m(he),g(xe)}const{data:re,error:oe}=await H.from("profiles").select("brokerage_id").eq("id",Y).single();if(_(!oe&&re?re.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Y);const{data:he,error:xe}=await H.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:he,assignmentsError:xe}),xe||!he){console.error("Error fetching managed brokerage assignments:",xe),j([]);return}const ue=Array.from(new Set(he.map(Se=>Se.brokerage_id).filter(Boolean)));if(ue.length===0){j([]);return}const{data:ge,error:_e}=await H.from("brokerages").select("id, name").in("id",ue);if(console.log("Managed brokerages details result:",{brokeragesData:ge,brokeragesError:_e}),_e||!ge){console.error("Error fetching managed brokerages details:",_e),j([]);return}const Be=ge.map(Se=>({id:Se.id,name:Se.name})).sort((Se,Ee)=>ue.indexOf(Se.id)-ue.indexOf(Ee.id));console.log("Parsed managed brokerages:",Be),j(Be),Be.length>0&&S(Se=>Se??Be[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),j([]);M.current=Y,I.current=!0}catch(J){console.error("Unexpected error in checkRoles:",J),q()}finally{P.current=!1,c(!1)}}};k.useEffect(()=>{let Y=!0,J=!1;const Q=()=>{!Y||J||(J=!0,l(!1))},{data:{subscription:ce}}=H.auth.onAuthStateChange((oe,he)=>{console.log("Auth event:",oe),Y&&(a(he),r((he==null?void 0:he.user)??null),Q(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{O("/profile?reset=true")},100)),he!=null&&he.user?(!I.current||M.current!==he.user.id)&&setTimeout(()=>{$(he.user.id)},0):(q(),c(!1)))}),ne=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),Q()},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 $(oe.user.id):q()}catch(oe){console.error("Error restoring auth session:",oe),Y&&(a(null),r(null),q())}finally{Q()}})(),()=>{Y=!1,window.clearTimeout(ne),ce.unsubscribe()}},[]);const z=async(Y,J)=>{const{error:Q}=await H.auth.signInWithPassword({email:Y,password:J});if(Q)throw me.error(Q.message),Q;me.success("Welcome back!");const ce=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),O(ce)},V=async(Y,J,Q)=>{const ce=`${window.location.origin}/dashboard`,{error:ne}=await H.auth.signUp({email:Y,password:J,options:{emailRedirectTo:ce,data:{name:Q}}});if(ne)throw me.error(ne.message),ne;me.success("Account created! Welcome to LevelUp."),O("/dashboard")},X=async()=>{try{const{data:{session:Y}}=await H.auth.getSession();if(Y){const{error:J}=await H.auth.signOut();J?J.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",J.message):(console.error("Sign out error:",J),me.error(J.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),m(!1),g(!1),_(null),j([]),S(null),O("/auth")}catch(Y){console.error("Unexpected sign out error:",Y),O("/auth")}};return e.jsx(aHe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:z,signUp:V,signOut:X,isAdmin:u,isBrokerageManager:f,brokerageId:y,managedBrokerages:w,selectedBrokerageId:N,setSelectedBrokerageId:S},children:t})},Fs=()=>{const t=k.useContext(aHe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},iHe=k.createContext(void 0),U2="levelup_admin_session",$b="levelup_impersonation",Exe="levelup_impersonation_return",o2t=({children:t})=>{const[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1);k.useEffect(()=>{const u=sessionStorage.getItem($b);if(u)try{const m=JSON.parse(u);r(!0),a(m)}catch{sessionStorage.removeItem($b)}},[]);const i=async(u,m)=>{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(U2,JSON.stringify(g)),m&&sessionStorage.setItem(Exe,m);const y=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 y.json();if(!y.ok)throw new Error(_.error||"Failed to impersonate user");const w={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem($b,JSON.stringify(w)),_.method==="session"){const{error:j}=await H.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(j)throw console.error("Set session error:",j),sessionStorage.removeItem(U2),sessionStorage.removeItem($b),new Error("Failed to establish impersonation session")}else{const j=_.type||"recovery",{error:N}=await H.auth.verifyOtp({token_hash:_.token_hash,type:j});if(N)throw console.error("Verify OTP error:",N),sessionStorage.removeItem(U2),sessionStorage.removeItem($b),new Error("Failed to establish impersonation session")}return r(!0),a(w),me.success(`Now viewing as ${w.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),me.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(U2),sessionStorage.removeItem($b),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(U2);if(!u){await H.auth.signOut(),window.location.href="/auth";return}const m=JSON.parse(u);await H.auth.signOut();const{error:f}=await H.auth.setSession({access_token:m.access_token,refresh_token:m.refresh_token});if(sessionStorage.removeItem(U2),sessionStorage.removeItem($b),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(Exe)||"/admin/members";sessionStorage.removeItem(Exe),window.location.href=g}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(U2),sessionStorage.removeItem($b),window.location.href="/auth"}finally{l(!1)}};return e.jsx(iHe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},Gde=()=>{const t=k.useContext(iHe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},mD=S3("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"}}),G=k.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?S2e:"button";return e.jsx(l,{className:Pt(mD({variant:s,size:r,className:t})),ref:o,...a})});G.displayName="Button";const l2t=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Gde();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(vd,{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(G,{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(ys,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Er,{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"})]})})]})})},oHe=k.createContext(void 0),E5="levelup_acting_as",pz="levelup_acting_as_self",c2t=({children:t})=>{const{user:s}=Fs(),[r,n]=k.useState(!1),[a,o]=k.useState([]),[l,i]=k.useState(null),[c,u]=k.useState({}),[m,f]=k.useState(!0),[g,y]=k.useState(()=>sessionStorage.getItem(pz)==="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:I,error:P}=await H.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(P||!I||I.length===0){o([]),f(!1);return}const O=I.map(z=>z.agent_id),{data:q}=await H.from("profiles").select("id, name, email, avatar_url").in("id",O),$=(q||[]).map(z=>({id:z.id,name:z.name||z.email||"Unknown",email:z.email||"",avatar_url:z.avatar_url}));if(o($),sessionStorage.getItem(pz)==="true")y(!0),i(null),u({});else{const z=sessionStorage.getItem(E5);if(z){const V=$.find(X=>X.id===z);if(V){i(V);const X=I.find(Y=>Y.agent_id===z);u((X==null?void 0:X.permissions)||{})}else if($.length>0){i($[0]);const X=I.find(Y=>Y.agent_id===$[0].id);u((X==null?void 0:X.permissions)||{}),sessionStorage.setItem(E5,$[0].id)}}else if($.length>0){i($[0]);const V=I.find(X=>X.agent_id===$[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(E5,$[0].id)}}}catch(M){console.error("Error loading assistant data:",M)}finally{f(!1)}})()},[s==null?void 0:s.id]);const _=S=>{i(S),y(!1),sessionStorage.removeItem(pz),S?(sessionStorage.setItem(E5,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(E5),u({}))},w=()=>{y(!0),i(null),u({}),sessionStorage.setItem(pz,"true"),sessionStorage.removeItem(E5)},j=S=>!r||g?!0:c[S]===!0,N=r&&l&&!g?l.id:(s==null?void 0:s.id)||null;return e.jsx(oHe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:_,effectiveUserId:N,permissions:c,hasPermission:j,isLoading:m,isActingAsSelf:g,setActingAsSelf:w},children:t})},cje=()=>{const t=k.useContext(oHe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},Fa=()=>{const{effectiveUserId:t}=cje();return t};var lHe={exports:{}},cHe={};/** * @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 QT=k;function d2t(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var u2t=typeof Object.is=="function"?Object.is:d2t,h2t=QT.useState,m2t=QT.useEffect,p2t=QT.useLayoutEffect,f2t=QT.useDebugValue;function x2t(t,s){var r=s(),n=h2t({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return p2t(function(){a.value=r,a.getSnapshot=s,Pxe(a)&&o({inst:a})},[t,r,s]),m2t(function(){return Pxe(a)&&o({inst:a}),t(function(){Pxe(a)&&o({inst:a})})},[t]),f2t(r),r}function Pxe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!u2t(t,r)}catch{return!0}}function g2t(t,s){return s()}var y2t=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g2t:x2t;cHe.useSyncExternalStore=QT.useSyncExternalStore!==void 0?QT.useSyncExternalStore:y2t;lHe.exports=cHe;var v2t=lHe.exports;function b2t(){return v2t.useSyncExternalStore(_2t,()=>!0,()=>!1)}function _2t(){return()=>{}}var dje="Avatar",[w2t]=od(dje),[j2t,dHe]=w2t(dje),uHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=k.useState("idle");return e.jsx(j2t,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(cn.span,{...n,ref:s})})});uHe.displayName=dje;var hHe="AvatarImage",mHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=dHe(hHe,r),i=N2t(n,o),c=_d(u=>{a(u),l.onImageLoadingStatusChange(u)});return kd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(cn.img,{...o,ref:s,src:n}):null});mHe.displayName=hHe;var pHe="AvatarFallback",fHe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=dHe(pHe,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(cn.span,{...a,ref:s}):null});fHe.displayName=pHe;function i6e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function N2t(t,{referrerPolicy:s,crossOrigin:r}){const n=b2t(),a=k.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=k.useState(()=>i6e(o,t));return kd(()=>{i(i6e(o,t))},[o,t]),kd(()=>{const c=f=>()=>{i(f)};if(!o)return;const u=c("loaded"),m=c("error");return o.addEventListener("load",u),o.addEventListener("error",m),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",m)}},[o,r,s]),l}var xHe=uHe,gHe=mHe,yHe=fHe;const Cn=k.forwardRef(({className:t,...s},r)=>e.jsx(xHe,{ref:r,className:Pt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));Cn.displayName=xHe.displayName;const Wa=k.forwardRef(({className:t,...s},r)=>e.jsx(gHe,{ref:r,className:Pt("aspect-square h-full w-full",t),...s}));Wa.displayName=gHe.displayName;const Mn=k.forwardRef(({className:t,...s},r)=>e.jsx(yHe,{ref:r,className:Pt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));Mn.displayName=yHe.displayName;const k2t=S3("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 Ye({className:t,variant:s,...r}){return e.jsx("div",{className:Pt(k2t({variant:s}),t),...r})}var S2t=k.createContext(void 0);function Dw(t){const s=k.useContext(S2t);return t||s||"ltr"}var Ixe=0;function Wde(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??o6e()),document.body.insertAdjacentElement("beforeend",t[1]??o6e()),Ixe++,()=>{Ixe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Ixe--}},[])}function o6e(){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 Lxe="focusScope.autoFocusOnMount",Dxe="focusScope.autoFocusOnUnmount",l6e={bubbles:!1,cancelable:!0},C2t="FocusScope",qO=k.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=k.useState(null),u=_d(a),m=_d(o),f=k.useRef(null),g=Ka(s,w=>c(w)),y=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let w=function(M){if(y.paused||!i)return;const I=M.target;i.contains(I)?f.current=I:Kb(f.current,{select:!0})},j=function(M){if(y.paused||!i)return;const I=M.relatedTarget;I!==null&&(i.contains(I)||Kb(f.current,{select:!0}))},N=function(M){if(document.activeElement===document.body)for(const P of M)P.removedNodes.length>0&&Kb(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const S=new MutationObserver(N);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),S.disconnect()}}},[n,i,y.paused]),k.useEffect(()=>{if(i){d6e.add(y);const w=document.activeElement;if(!i.contains(w)){const N=new CustomEvent(Lxe,l6e);i.addEventListener(Lxe,u),i.dispatchEvent(N),N.defaultPrevented||(M2t(I2t(vHe(i)),{select:!0}),document.activeElement===w&&Kb(i))}return()=>{i.removeEventListener(Lxe,u),setTimeout(()=>{const N=new CustomEvent(Dxe,l6e);i.addEventListener(Dxe,m),i.dispatchEvent(N),N.defaultPrevented||Kb(w??document.body,{select:!0}),i.removeEventListener(Dxe,m),d6e.remove(y)},0)}}},[i,u,m,y]);const _=k.useCallback(w=>{if(!r&&!n||y.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,N=document.activeElement;if(j&&N){const S=w.currentTarget,[M,I]=T2t(S);M&&I?!w.shiftKey&&N===I?(w.preventDefault(),r&&Kb(M,{select:!0})):w.shiftKey&&N===M&&(w.preventDefault(),r&&Kb(I,{select:!0})):N===S&&w.preventDefault()}},[r,n,y.paused]);return e.jsx(cn.div,{tabIndex:-1,...l,ref:g,onKeyDown:_})});qO.displayName=C2t;function M2t(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Kb(n,{select:s}),document.activeElement!==r)return}function T2t(t){const s=vHe(t),r=c6e(s,t),n=c6e(s.reverse(),t);return[r,n]}function vHe(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 c6e(t,s){for(const r of t)if(!A2t(r,{upTo:s}))return r}function A2t(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 E2t(t){return t instanceof HTMLInputElement&&"select"in t}function Kb(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&E2t(t)&&s&&t.select()}}var d6e=P2t();function P2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=u6e(t,s),t.unshift(s)},remove(s){var r;t=u6e(t,s),(r=t[0])==null||r.resume()}}}function u6e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function I2t(t){return t.filter(s=>s.tagName!=="A")}var Oxe="rovingFocusGroup.onEntryFocus",L2t={bubbles:!1,cancelable:!0},UO="RovingFocusGroup",[Rve,bHe,D2t]=LO(UO),[O2t,Ow]=od(UO,[D2t]),[R2t,F2t]=O2t(UO),_He=k.forwardRef((t,s)=>e.jsx(Rve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Rve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(z2t,{...t,ref:s})})}));_He.displayName=UO;var z2t=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...f}=t,g=k.useRef(null),y=Ka(s,g),_=Dw(o),[w,j]=lh({prop:l,defaultProp:i??null,onChange:c,caller:UO}),[N,S]=k.useState(!1),M=_d(u),I=bHe(r),P=k.useRef(!1),[O,q]=k.useState(0);return k.useEffect(()=>{const $=g.current;if($)return $.addEventListener(Oxe,M),()=>$.removeEventListener(Oxe,M)},[M]),e.jsx(R2t,{scope:r,orientation:n,dir:_,loop:a,currentTabStopId:w,onItemFocus:k.useCallback($=>j($),[j]),onItemShiftTab:k.useCallback(()=>S(!0),[]),onFocusableItemAdd:k.useCallback(()=>q($=>$+1),[]),onFocusableItemRemove:k.useCallback(()=>q($=>$-1),[]),children:e.jsx(cn.div,{tabIndex:N||O===0?-1:0,"data-orientation":n,...f,ref:y,style:{outline:"none",...t.style},onMouseDown:Or(t.onMouseDown,()=>{P.current=!0}),onFocus:Or(t.onFocus,$=>{const z=!P.current;if($.target===$.currentTarget&&z&&!N){const V=new CustomEvent(Oxe,L2t);if($.currentTarget.dispatchEvent(V),!V.defaultPrevented){const X=I().filter(ne=>ne.focusable),Y=X.find(ne=>ne.active),J=X.find(ne=>ne.id===w),ce=[Y,J,...X].filter(Boolean).map(ne=>ne.ref.current);NHe(ce,m)}}P.current=!1}),onBlur:Or(t.onBlur,()=>S(!1))})})}),wHe="RovingFocusGroupItem",jHe=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=Iu(),u=o||c,m=F2t(wHe,r),f=m.currentTabStopId===u,g=bHe(r),{onFocusableItemAdd:y,onFocusableItemRemove:_,currentTabStopId:w}=m;return k.useEffect(()=>{if(n)return y(),()=>_()},[n,y,_]),e.jsx(Rve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(cn.span,{tabIndex:f?0:-1,"data-orientation":m.orientation,...i,ref:s,onMouseDown:Or(t.onMouseDown,j=>{n?m.onItemFocus(u):j.preventDefault()}),onFocus:Or(t.onFocus,()=>m.onItemFocus(u)),onKeyDown:Or(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){m.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const N=q2t(j,m.orientation,m.dir);if(N!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let M=g().filter(I=>I.focusable).map(I=>I.ref.current);if(N==="last")M.reverse();else if(N==="prev"||N==="next"){N==="prev"&&M.reverse();const I=M.indexOf(j.currentTarget);M=m.loop?U2t(M,I+1):M.slice(I+1)}setTimeout(()=>NHe(M))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:w!=null}):l})})});jHe.displayName=wHe;var B2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function $2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function q2t(t,s,r){const n=$2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return B2t[n]}function NHe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function U2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Kde=_He,Zde=jHe,V2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},P5=new WeakMap,fz=new WeakMap,xz={},Rxe=0,kHe=function(t){return t&&(t.host||kHe(t.parentNode))},H2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=kHe(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})},G2t=function(t,s,r,n){var a=H2t(s,Array.isArray(t)?t:[t]);xz[r]||(xz[r]=new WeakMap);var o=xz[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 m=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(g){if(i.has(g))m(g);else try{var y=g.getAttribute(n),_=y!==null&&y!=="false",w=(P5.get(g)||0)+1,j=(o.get(g)||0)+1;P5.set(g,w),o.set(g,j),l.push(g),w===1&&_&&fz.set(g,!0),j===1&&g.setAttribute(r,"true"),_||g.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return m(s),i.clear(),Rxe++,function(){l.forEach(function(f){var g=P5.get(f)-1,y=o.get(f)-1;P5.set(f,g),o.set(f,y),g||(fz.has(f)||f.removeAttribute(n),fz.delete(f)),y||f.removeAttribute(r)}),Rxe--,Rxe||(P5=new WeakMap,P5=new WeakMap,fz=new WeakMap,xz={})}},Yde=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=V2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),G2t(n,a,r,"aria-hidden")):function(){return null}},wie="right-scroll-bar-position",jie="width-before-scroll-bar",W2t="with-scroll-bars-hidden",K2t="--removed-body-scroll-bar-size";function Fxe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function Z2t(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 Y2t=typeof window<"u"?k.useLayoutEffect:k.useEffect,h6e=new WeakMap;function Q2t(t,s){var r=Z2t(null,function(n){return t.forEach(function(a){return Fxe(a,n)})});return Y2t(function(){var n=h6e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Fxe(i,null)}),o.forEach(function(i){a.has(i)||Fxe(i,l)})}h6e.set(r,t)},[t]),r}function X2t(t){return t}function J2t(t,s){s===void 0&&(s=X2t);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 m=l;l=[],m.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(m){l.push(m),u()},filter:function(m){return l=l.filter(m),r}}}};return a}function ejt(t){t===void 0&&(t={});var s=J2t(null);return s.options=_x({async:!0,ssr:!1},t),s}var SHe=function(t){var s=t.sideCar,r=Iw(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,_x({},r))};SHe.isSideCarExport=!0;function tjt(t,s){return t.useMedium(s),SHe}var CHe=ejt(),zxe=function(){},Qde=k.forwardRef(function(t,s){var r=k.useRef(null),n=k.useState({onScrollCapture:zxe,onWheelCapture:zxe,onTouchMoveCapture:zxe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,c=t.className,u=t.removeScrollBar,m=t.enabled,f=t.shards,g=t.sideCar,y=t.noRelative,_=t.noIsolation,w=t.inert,j=t.allowPinchZoom,N=t.as,S=N===void 0?"div":N,M=t.gapMode,I=Iw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=g,O=Q2t([r,s]),q=_x(_x({},I),a);return k.createElement(k.Fragment,null,m&&k.createElement(P,{sideCar:CHe,removeScrollBar:u,shards:f,noRelative:y,noIsolation:_,inert:w,setCallbacks:o,allowPinchZoom:!!j,lockRef:r,gapMode:M}),l?k.cloneElement(k.Children.only(i),_x(_x({},q),{ref:O})):k.createElement(S,_x({},q,{className:c,ref:O}),i))});Qde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Qde.classNames={fullWidth:jie,zeroRight:wie};var sjt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function rjt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=sjt();return s&&t.setAttribute("nonce",s),t}function njt(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function ajt(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var ijt=function(){var t=0,s=null;return{add:function(r){t==0&&(s=rjt())&&(njt(s,r),ajt(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},ojt=function(){var t=ijt();return function(s,r){k.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},MHe=function(){var t=ojt(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},ljt={left:0,top:0,right:0,gap:0},Bxe=function(t){return parseInt(t||"",10)||0},cjt=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[Bxe(r),Bxe(n),Bxe(a)]},djt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ljt;var s=cjt(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])}},ujt=MHe(),mT="data-scroll-locked",hjt=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(W2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(mT,`] { 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(wie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(jie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(wie," .").concat(wie,` { right: 0 `).concat(n,`; } .`).concat(jie," .").concat(jie,` { margin-right: 0 `).concat(n,`; } body[`).concat(mT,`] { `).concat(K2t,": ").concat(i,`px; } `)},m6e=function(){var t=parseInt(document.body.getAttribute(mT)||"0",10);return isFinite(t)?t:0},mjt=function(){k.useEffect(function(){return document.body.setAttribute(mT,(m6e()+1).toString()),function(){var t=m6e()-1;t<=0?document.body.removeAttribute(mT):document.body.setAttribute(mT,t.toString())}},[])},pjt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;mjt();var o=k.useMemo(function(){return djt(a)},[a]);return k.createElement(ujt,{styles:hjt(o,!s,a,r?"":"!important")})},Fve=!1;if(typeof window<"u")try{var gz=Object.defineProperty({},"passive",{get:function(){return Fve=!0,!0}});window.addEventListener("test",gz,gz),window.removeEventListener("test",gz,gz)}catch{Fve=!1}var I5=Fve?{passive:!1}:!1,fjt=function(t){return t.tagName==="TEXTAREA"},THe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!fjt(t)&&r[s]==="visible")},xjt=function(t){return THe(t,"overflowY")},gjt=function(t){return THe(t,"overflowX")},p6e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=AHe(t,n);if(a){var o=EHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},yjt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},vjt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},AHe=function(t,s){return t==="v"?xjt(s):gjt(s)},EHe=function(t,s){return t==="v"?yjt(s):vjt(s)},bjt=function(t,s){return t==="h"&&s==="rtl"?-1:1},_jt=function(t,s,r,n,a){var o=bjt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,c=s.contains(i),u=!1,m=l>0,f=0,g=0;do{if(!i)break;var y=EHe(t,i),_=y[0],w=y[1],j=y[2],N=w-j-o*_;(_||N)&&AHe(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(m&&Math.abs(f)<1||!m&&Math.abs(g)<1)&&(u=!0),u},yz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},f6e=function(t){return[t.deltaX,t.deltaY]},x6e=function(t){return t&&"current"in t?t.current:t},wjt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},jjt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Njt=0,L5=[];function kjt(t){var s=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),a=k.useState(Njt++)[0],o=k.useState(MHe)[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 w=eje([t.lockRef.current],(t.shards||[]).map(x6e),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=k.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var N=yz(w),S=r.current,M="deltaX"in w?w.deltaX:S[0]-N[0],I="deltaY"in w?w.deltaY:S[1]-N[1],P,O=w.target,q=Math.abs(M)>Math.abs(I)?"h":"v";if("touches"in w&&q==="h"&&O.type==="range")return!1;var $=p6e(q,O);if(!$)return!0;if($?P=q:(P=q==="v"?"h":"v",$=p6e(q,O)),!$)return!1;if(!n.current&&"changedTouches"in w&&(M||I)&&(n.current=P),!P)return!0;var z=n.current||P;return _jt(z,j,w,z==="h"?M:I)},[]),c=k.useCallback(function(w){var j=w;if(!(!L5.length||L5[L5.length-1]!==o)){var N="deltaY"in j?f6e(j):yz(j),S=s.current.filter(function(P){return P.name===j.type&&(P.target===j.target||j.target===P.shadowParent)&&wjt(P.delta,N)})[0];if(S&&S.should){j.cancelable&&j.preventDefault();return}if(!S){var M=(l.current.shards||[]).map(x6e).filter(Boolean).filter(function(P){return P.contains(j.target)}),I=M.length>0?i(j,M[0]):!l.current.noIsolation;I&&j.cancelable&&j.preventDefault()}}},[]),u=k.useCallback(function(w,j,N,S){var M={name:w,delta:j,target:N,should:S,shadowParent:Sjt(N)};s.current.push(M),setTimeout(function(){s.current=s.current.filter(function(I){return I!==M})},1)},[]),m=k.useCallback(function(w){r.current=yz(w),n.current=void 0},[]),f=k.useCallback(function(w){u(w.type,f6e(w),w.target,i(w,t.lockRef.current))},[]),g=k.useCallback(function(w){u(w.type,yz(w),w.target,i(w,t.lockRef.current))},[]);k.useEffect(function(){return L5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",c,I5),document.addEventListener("touchmove",c,I5),document.addEventListener("touchstart",m,I5),function(){L5=L5.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,I5),document.removeEventListener("touchmove",c,I5),document.removeEventListener("touchstart",m,I5)}},[]);var y=t.removeScrollBar,_=t.inert;return k.createElement(k.Fragment,null,_?k.createElement(o,{styles:jjt(a)}):null,y?k.createElement(pjt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Sjt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const Cjt=tjt(CHe,kjt);var VO=k.forwardRef(function(t,s){return k.createElement(Qde,_x({},t,{ref:s,sideCar:Cjt}))});VO.classNames=Qde.classNames;var zve=["Enter"," "],Mjt=["ArrowDown","PageUp","Home"],PHe=["ArrowUp","PageDown","End"],Tjt=[...Mjt,...PHe],Ajt={ltr:[...zve,"ArrowRight"],rtl:[...zve,"ArrowLeft"]},Ejt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},HO="Menu",[pD,Pjt,Ijt]=LO(HO),[M3,IHe]=od(HO,[Ijt,V0,Ow]),Xde=V0(),LHe=Ow(),[Ljt,T3]=M3(HO),[Djt,GO]=M3(HO),DHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Xde(s),[c,u]=k.useState(null),m=k.useRef(!1),f=_d(o),g=Dw(a);return k.useEffect(()=>{const y=()=>{m.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>m.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),e.jsx(FO,{...i,children:e.jsx(Ljt,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(Djt,{scope:s,onClose:k.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:m,dir:g,modal:l,children:n})})})};DHe.displayName=HO;var Ojt="MenuAnchor",uje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Xde(r);return e.jsx(nE,{...a,...n,ref:s})});uje.displayName=Ojt;var hje="MenuPortal",[Rjt,OHe]=M3(hje,{forceMount:void 0}),RHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=T3(hje,s);return e.jsx(Rjt,{scope:s,forceMount:r,children:e.jsx(qd,{present:r||o.open,children:e.jsx(eE,{asChild:!0,container:a,children:n})})})};RHe.displayName=hje;var Lx="MenuContent",[Fjt,mje]=M3(Lx),FHe=k.forwardRef((t,s)=>{const r=OHe(Lx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=T3(Lx,t.__scopeMenu),l=GO(Lx,t.__scopeMenu);return e.jsx(pD.Provider,{scope:t.__scopeMenu,children:e.jsx(qd,{present:n||o.open,children:e.jsx(pD.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(zjt,{...a,ref:s}):e.jsx(Bjt,{...a,ref:s})})})})}),zjt=k.forwardRef((t,s)=>{const r=T3(Lx,t.__scopeMenu),n=k.useRef(null),a=Ka(s,n);return k.useEffect(()=>{const o=n.current;if(o)return Yde(o)},[]),e.jsx(pje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Or(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Bjt=k.forwardRef((t,s)=>{const r=T3(Lx,t.__scopeMenu);return e.jsx(pje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),$jt=fw("MenuContent.ScrollLock"),pje=k.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:g,onDismiss:y,disableOutsideScroll:_,...w}=t,j=T3(Lx,r),N=GO(Lx,r),S=Xde(r),M=LHe(r),I=Pjt(r),[P,O]=k.useState(null),q=k.useRef(null),$=Ka(s,q,j.onContentChange),z=k.useRef(0),V=k.useRef(""),X=k.useRef(0),Y=k.useRef(null),J=k.useRef("right"),Q=k.useRef(0),ce=_?VO:k.Fragment,ne=_?{as:$jt,allowPinchZoom:!0}:void 0,re=he=>{var Ae,Me;const xe=V.current+he,ue=I().filter(ke=>!ke.disabled),ge=document.activeElement,_e=(Ae=ue.find(ke=>ke.ref.current===ge))==null?void 0:Ae.textValue,Be=ue.map(ke=>ke.textValue),Se=Jjt(Be,xe,_e),Ee=(Me=ue.find(ke=>ke.textValue===Se))==null?void 0:Me.ref.current;(function ke(Oe){V.current=Oe,window.clearTimeout(z.current),Oe!==""&&(z.current=window.setTimeout(()=>ke(""),1e3))})(xe),Ee&&setTimeout(()=>Ee.focus())};k.useEffect(()=>()=>window.clearTimeout(z.current),[]),Wde();const oe=k.useCallback(he=>{var ue,ge;return J.current===((ue=Y.current)==null?void 0:ue.side)&&tNt(he,(ge=Y.current)==null?void 0:ge.area)},[]);return e.jsx(Fjt,{scope:r,searchRef:V,onItemEnter:k.useCallback(he=>{oe(he)&&he.preventDefault()},[oe]),onItemLeave:k.useCallback(he=>{var xe;oe(he)||((xe=q.current)==null||xe.focus(),O(null))},[oe]),onTriggerLeave:k.useCallback(he=>{oe(he)&&he.preventDefault()},[oe]),pointerGraceTimerRef:X,onPointerGraceIntentChange:k.useCallback(he=>{Y.current=he},[]),children:e.jsx(ce,{...ne,children:e.jsx(qO,{asChild:!0,trapped:a,onMountAutoFocus:Or(o,he=>{var xe;he.preventDefault(),(xe=q.current)==null||xe.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:f,onInteractOutside:g,onDismiss:y,children:e.jsx(Kde,{asChild:!0,...M,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:P,onCurrentTabStopIdChange:O,onEntryFocus:Or(c,he=>{N.isUsingKeyboardRef.current||he.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(zO,{role:"menu","aria-orientation":"vertical","data-state":eGe(j.open),"data-radix-menu-content":"",dir:N.dir,...S,...w,ref:$,style:{outline:"none",...w.style},onKeyDown:Or(w.onKeyDown,he=>{const ue=he.target.closest("[data-radix-menu-content]")===he.currentTarget,ge=he.ctrlKey||he.altKey||he.metaKey,_e=he.key.length===1;ue&&(he.key==="Tab"&&he.preventDefault(),!ge&&_e&&re(he.key));const Be=q.current;if(he.target!==Be||!Tjt.includes(he.key))return;he.preventDefault();const Ee=I().filter(Ae=>!Ae.disabled).map(Ae=>Ae.ref.current);PHe.includes(he.key)&&Ee.reverse(),Qjt(Ee)}),onBlur:Or(t.onBlur,he=>{he.currentTarget.contains(he.target)||(window.clearTimeout(z.current),V.current="")}),onPointerMove:Or(t.onPointerMove,fD(he=>{const xe=he.target,ue=Q.current!==he.clientX;if(he.currentTarget.contains(xe)&&ue){const ge=he.clientX>Q.current?"right":"left";J.current=ge,Q.current=he.clientX}}))})})})})})})});FHe.displayName=Lx;var qjt="MenuGroup",fje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(cn.div,{role:"group",...n,ref:s})});fje.displayName=qjt;var Ujt="MenuLabel",zHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(cn.div,{...n,ref:s})});zHe.displayName=Ujt;var Poe="MenuItem",g6e="menu.itemSelect",Jde=k.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=k.useRef(null),l=GO(Poe,t.__scopeMenu),i=mje(Poe,t.__scopeMenu),c=Ka(s,o),u=k.useRef(!1),m=()=>{const f=o.current;if(!r&&f){const g=new CustomEvent(g6e,{bubbles:!0,cancelable:!0});f.addEventListener(g6e,y=>n==null?void 0:n(y),{once:!0}),C2e(f,g),g.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(BHe,{...a,ref:c,disabled:r,onClick:Or(t.onClick,m),onPointerDown:f=>{var g;(g=t.onPointerDown)==null||g.call(t,f),u.current=!0},onPointerUp:Or(t.onPointerUp,f=>{var g;u.current||(g=f.currentTarget)==null||g.click()}),onKeyDown:Or(t.onKeyDown,f=>{const g=i.searchRef.current!=="";r||g&&f.key===" "||zve.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Jde.displayName=Poe;var BHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=mje(Poe,r),i=LHe(r),c=k.useRef(null),u=Ka(s,c),[m,f]=k.useState(!1),[g,y]=k.useState("");return k.useEffect(()=>{const _=c.current;_&&y((_.textContent??"").trim())},[o.children]),e.jsx(pD.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:e.jsx(Zde,{asChild:!0,...i,focusable:!n,children:e.jsx(cn.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Or(t.onPointerMove,fD(_=>{n?l.onItemLeave(_):(l.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Or(t.onPointerLeave,fD(_=>l.onItemLeave(_))),onFocus:Or(t.onFocus,()=>f(!0)),onBlur:Or(t.onBlur,()=>f(!1))})})})}),Vjt="MenuCheckboxItem",$He=k.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(GHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Jde,{role:"menuitemcheckbox","aria-checked":Ioe(r)?"mixed":r,...a,ref:s,"data-state":gje(r),onSelect:Or(a.onSelect,()=>n==null?void 0:n(Ioe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});$He.displayName=Vjt;var qHe="MenuRadioGroup",[Hjt,Gjt]=M3(qHe,{value:void 0,onValueChange:()=>{}}),UHe=k.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=_d(n);return e.jsx(Hjt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(fje,{...a,ref:s})})});UHe.displayName=qHe;var VHe="MenuRadioItem",HHe=k.forwardRef((t,s)=>{const{value:r,...n}=t,a=Gjt(VHe,t.__scopeMenu),o=r===a.value;return e.jsx(GHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Jde,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":gje(o),onSelect:Or(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});HHe.displayName=VHe;var xje="MenuItemIndicator",[GHe,Wjt]=M3(xje,{checked:!1}),WHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=Wjt(xje,r);return e.jsx(qd,{present:n||Ioe(o.checked)||o.checked===!0,children:e.jsx(cn.span,{...a,ref:s,"data-state":gje(o.checked)})})});WHe.displayName=xje;var Kjt="MenuSeparator",KHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(cn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});KHe.displayName=Kjt;var Zjt="MenuArrow",ZHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Xde(r);return e.jsx(BO,{...a,...n,ref:s})});ZHe.displayName=Zjt;var Yjt="MenuSub",[XAs,YHe]=M3(Yjt),BI="MenuSubTrigger",QHe=k.forwardRef((t,s)=>{const r=T3(BI,t.__scopeMenu),n=GO(BI,t.__scopeMenu),a=YHe(BI,t.__scopeMenu),o=mje(BI,t.__scopeMenu),l=k.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},m=k.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return k.useEffect(()=>m,[m]),k.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(uje,{asChild:!0,...u,children:e.jsx(BHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":eGe(r.open),...t,ref:I1(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:Or(t.onPointerMove,fD(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),m()},100))})),onPointerLeave:Or(t.onPointerLeave,fD(f=>{var y,_;m();const g=(y=r.content)==null?void 0:y.getBoundingClientRect();if(g){const w=(_=r.content)==null?void 0:_.dataset.side,j=w==="right",N=j?-5:5,S=g[j?"left":"right"],M=g[j?"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:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Or(t.onKeyDown,f=>{var y;const g=o.searchRef.current!=="";t.disabled||g&&f.key===" "||Ajt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(y=r.content)==null||y.focus(),f.preventDefault())})})})});QHe.displayName=BI;var XHe="MenuSubContent",JHe=k.forwardRef((t,s)=>{const r=OHe(Lx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=T3(Lx,t.__scopeMenu),l=GO(Lx,t.__scopeMenu),i=YHe(XHe,t.__scopeMenu),c=k.useRef(null),u=Ka(s,c);return e.jsx(pD.Provider,{scope:t.__scopeMenu,children:e.jsx(qd,{present:n||o.open,children:e.jsx(pD.Slot,{scope:t.__scopeMenu,children:e.jsx(pje,{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:m=>{var f;l.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Or(t.onFocusOutside,m=>{m.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Or(t.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:Or(t.onKeyDown,m=>{var y;const f=m.currentTarget.contains(m.target),g=Ejt[l.dir].includes(m.key);f&&g&&(o.onOpenChange(!1),(y=i.trigger)==null||y.focus(),m.preventDefault())})})})})})});JHe.displayName=XHe;function eGe(t){return t?"open":"closed"}function Ioe(t){return t==="indeterminate"}function gje(t){return Ioe(t)?"indeterminate":t?"checked":"unchecked"}function Qjt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function Xjt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Jjt(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=Xjt(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 eNt(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-m)/(g-m)+u&&(a=!a)}return a}function tNt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return eNt(r,s)}function fD(t){return s=>s.pointerType==="mouse"?t(s):void 0}var sNt=DHe,rNt=uje,nNt=RHe,aNt=FHe,iNt=fje,oNt=zHe,lNt=Jde,cNt=$He,dNt=UHe,uNt=HHe,hNt=WHe,mNt=KHe,pNt=ZHe,fNt=QHe,xNt=JHe,eue="DropdownMenu",[gNt]=od(eue,[IHe]),Km=IHe(),[yNt,tGe]=gNt(eue),sGe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Km(s),u=k.useRef(null),[m,f]=lh({prop:a,defaultProp:o??!1,onChange:l,caller:eue});return e.jsx(yNt,{scope:s,triggerId:Iu(),triggerRef:u,contentId:Iu(),open:m,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(g=>!g),[f]),modal:i,children:e.jsx(sNt,{...c,open:m,onOpenChange:f,dir:n,modal:i,children:r})})};sGe.displayName=eue;var rGe="DropdownMenuTrigger",nGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=tGe(rGe,r),l=Km(r);return e.jsx(rNt,{asChild:!0,...l,children:e.jsx(cn.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:I1(s,o.triggerRef),onPointerDown:Or(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Or(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});nGe.displayName=rGe;var vNt="DropdownMenuPortal",aGe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Km(s);return e.jsx(nNt,{...n,...r})};aGe.displayName=vNt;var iGe="DropdownMenuContent",oGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=tGe(iGe,r),o=Km(r),l=k.useRef(!1);return e.jsx(aNt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Or(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Or(t.onInteractOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,m=c.button===2||u;(!a.modal||m)&&(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)"}})});oGe.displayName=iGe;var bNt="DropdownMenuGroup",_Nt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(iNt,{...a,...n,ref:s})});_Nt.displayName=bNt;var wNt="DropdownMenuLabel",lGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(oNt,{...a,...n,ref:s})});lGe.displayName=wNt;var jNt="DropdownMenuItem",cGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(lNt,{...a,...n,ref:s})});cGe.displayName=jNt;var NNt="DropdownMenuCheckboxItem",dGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(cNt,{...a,...n,ref:s})});dGe.displayName=NNt;var kNt="DropdownMenuRadioGroup",SNt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(dNt,{...a,...n,ref:s})});SNt.displayName=kNt;var CNt="DropdownMenuRadioItem",uGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(uNt,{...a,...n,ref:s})});uGe.displayName=CNt;var MNt="DropdownMenuItemIndicator",hGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(hNt,{...a,...n,ref:s})});hGe.displayName=MNt;var TNt="DropdownMenuSeparator",mGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(mNt,{...a,...n,ref:s})});mGe.displayName=TNt;var ANt="DropdownMenuArrow",ENt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(pNt,{...a,...n,ref:s})});ENt.displayName=ANt;var PNt="DropdownMenuSubTrigger",pGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(fNt,{...a,...n,ref:s})});pGe.displayName=PNt;var INt="DropdownMenuSubContent",fGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Km(r);return e.jsx(xNt,{...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)"}})});fGe.displayName=INt;var LNt=sGe,DNt=nGe,ONt=aGe,xGe=oGe,gGe=lGe,yGe=cGe,vGe=dGe,bGe=uGe,_Ge=hGe,wGe=mGe,jGe=pGe,NGe=fGe;const du=LNt,uu=DNt,RNt=k.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(jGe,{ref:a,className:Pt("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(da,{className:"ml-auto h-4 w-4"})]}));RNt.displayName=jGe.displayName;const FNt=k.forwardRef(({className:t,...s},r)=>e.jsx(NGe,{ref:r,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));FNt.displayName=NGe.displayName;const Ud=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(ONt,{children:e.jsx(xGe,{ref:n,sideOffset:s,className:Pt("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Ud.displayName=xGe.displayName;const La=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(yGe,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));La.displayName=yGe.displayName;const zNt=k.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(vGe,{ref:a,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(_Ge,{children:e.jsx(ua,{className:"h-4 w-4"})})}),s]}));zNt.displayName=vGe.displayName;const BNt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(bGe,{ref:n,className:Pt("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(_Ge,{children:e.jsx(jd,{className:"h-2 w-2 fill-current"})})}),s]}));BNt.displayName=bGe.displayName;const Bve=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(gGe,{ref:n,className:Pt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));Bve.displayName=gGe.displayName;const yw=k.forwardRef(({className:t,...s},r)=>e.jsx(wGe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));yw.displayName=wGe.displayName;const $Nt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=cje();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(Zi,{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(ur,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{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(Zi,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{className:"h-5 w-5",children:[e.jsx(Wa,{src:s.avatar_url||void 0}),e.jsx(Mn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Ji,{className:"h-3 w-3"})]})}),e.jsxs(Ud,{align:"start",className:"z-[2147483647]",children:[e.jsxs(La,{onClick:o,className:"gap-2",children:[e.jsx(Zi,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(Ye,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(yw,{}),r.map(i=>e.jsxs(La,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:i.avatar_url||void 0}),e.jsx(Mn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(Ye,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(Ye,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},or=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Fs(),c=hc();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(yxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(yxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(yxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var yje={};(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 xe=new OffscreenCanvas(1,1),ue=xe.getContext("2d");ue.fillRect(0,0,1,1);var ge=xe.transferToImageBitmap();ue.createPattern(ge,"no-repeat")}catch{return!1}return!0}();function c(){}function u(xe){var ue=r.exports.Promise,ge=ue!==void 0?ue:s.Promise;return typeof ge=="function"?new ge(xe):(xe(c,c),null)}var m=function(xe,ue){return{transform:function(ge){if(xe)return ge;if(ue.has(ge))return ue.get(ge);var _e=new OffscreenCanvas(ge.width,ge.height),Be=_e.getContext("2d");return Be.drawImage(ge,0,0),ue.set(ge,_e),_e},clear:function(){ue.clear()}}}(i,new Map),f=function(){var xe=Math.floor(16.666666666666668),ue,ge,_e={},Be=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ue=function(Se){var Ee=Math.random();return _e[Ee]=requestAnimationFrame(function Ae(Me){Be===Me||Be+xe-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 UNt(){const t=Qt();return Tt({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 VNt(){const t=Qt(),{user:s}=Fs();return Tt({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 tue="Dialog",[kGe,SGe]=od(tue),[HNt,py]=kGe(tue),CGe=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,m]=lh({prop:n,defaultProp:a??!1,onChange:o,caller:tue});return e.jsx(HNt,{scope:s,triggerRef:i,contentRef:c,contentId:Iu(),titleId:Iu(),descriptionId:Iu(),open:u,onOpenChange:m,onOpenToggle:k.useCallback(()=>m(f=>!f),[m]),modal:l,children:r})};CGe.displayName=tue;var MGe="DialogTrigger",TGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=py(MGe,r),o=Ka(s,a.triggerRef);return e.jsx(cn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":_je(a.open),...n,ref:o,onClick:Or(t.onClick,a.onOpenToggle)})});TGe.displayName=MGe;var vje="DialogPortal",[GNt,AGe]=kGe(vje,{forceMount:void 0}),EGe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=py(vje,s);return e.jsx(GNt,{scope:s,forceMount:r,children:k.Children.map(n,l=>e.jsx(qd,{present:r||o.open,children:e.jsx(eE,{asChild:!0,container:a,children:l})}))})};EGe.displayName=vje;var Loe="DialogOverlay",PGe=k.forwardRef((t,s)=>{const r=AGe(Loe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=py(Loe,t.__scopeDialog);return o.modal?e.jsx(qd,{present:n||o.open,children:e.jsx(KNt,{...a,ref:s})}):null});PGe.displayName=Loe;var WNt=fw("DialogOverlay.RemoveScroll"),KNt=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=py(Loe,r);return e.jsx(VO,{as:WNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(cn.div,{"data-state":_je(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),XS="DialogContent",IGe=k.forwardRef((t,s)=>{const r=AGe(XS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=py(XS,t.__scopeDialog);return e.jsx(qd,{present:n||o.open,children:o.modal?e.jsx(ZNt,{...a,ref:s}):e.jsx(YNt,{...a,ref:s})})});IGe.displayName=XS;var ZNt=k.forwardRef((t,s)=>{const r=py(XS,t.__scopeDialog),n=k.useRef(null),a=Ka(s,r.contentRef,n);return k.useEffect(()=>{const o=n.current;if(o)return Yde(o)},[]),e.jsx(LGe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Or(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Or(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Or(t.onFocusOutside,o=>o.preventDefault())})}),YNt=k.forwardRef((t,s)=>{const r=py(XS,t.__scopeDialog),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(LGe,{...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()}})}),LGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=py(XS,r),c=k.useRef(null),u=Ka(s,c);return Wde(),e.jsxs(e.Fragment,{children:[e.jsx(qO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Ew,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":_je(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(XNt,{titleId:i.titleId}),e.jsx(ekt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),bje="DialogTitle",DGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=py(bje,r);return e.jsx(cn.h2,{id:a.titleId,...n,ref:s})});DGe.displayName=bje;var OGe="DialogDescription",RGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=py(OGe,r);return e.jsx(cn.p,{id:a.descriptionId,...n,ref:s})});RGe.displayName=OGe;var FGe="DialogClose",zGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=py(FGe,r);return e.jsx(cn.button,{type:"button",...n,ref:s,onClick:Or(t.onClick,()=>a.onOpenChange(!1))})});zGe.displayName=FGe;function _je(t){return t?"open":"closed"}var BGe="DialogTitleWarning",[QNt,$Ge]=Lxt(BGe,{contentName:XS,titleName:bje,docsSlug:"dialog"}),XNt=({titleId:t})=>{const s=$Ge(BGe),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},JNt="DialogDescriptionWarning",ekt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$Ge(JNt).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},sue=CGe,wje=TGe,rue=EGe,dE=PGe,uE=IGe,WO=DGe,KO=RGe,ZO=zGe;const fs=sue,Oi=wje,tkt=rue,JAs=ZO,qGe=k.forwardRef(({className:t,...s},r)=>e.jsx(dE,{ref:r,className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));qGe.displayName=dE.displayName;const ps=k.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(tkt,{children:[e.jsx(qGe,{className:r}),e.jsxs(uE,{ref:a,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(ZO,{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(Er,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ps.displayName=uE.displayName;const js=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});js.displayName="DialogHeader";const Rn=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Rn.displayName="DialogFooter";const vs=k.forwardRef(({className:t,...s},r)=>e.jsx(WO,{ref:r,className:Pt("text-lg font-semibold leading-none tracking-tight",t),...s}));vs.displayName=WO.displayName;const Gr=k.forwardRef(({className:t,...s},r)=>e.jsx(KO,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Gr.displayName=KO.displayName;const skt={points_earned:_o,listing_created:xn,deal_closed:ml,custom:ea},v6e={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"},b6e=()=>{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 rkt(){const{user:t}=Fs(),s=Qt(),{data:r}=qNt(),n=UNt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=k.useCallback(()=>{const y=Date.now()+3e3,_={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(N,S)=>Math.random()*(S-N)+N,j=setInterval(()=>{const N=y-Date.now();if(N<=0){clearInterval(j);return}const S=50*(N/3e3);y6e({..._,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),y6e({..._,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);k.useEffect(()=>{b6e()||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],y=>(y==null?void 0:y.filter(_=>_.id!==g))??[]),await n.mutateAsync(g)}};if(b6e()||!a)return null;const m=skt[a.celebration_type]||ea,f=v6e[a.celebration_type]||v6e.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(m,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(nn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(nn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(nn,{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(G,{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 UGe="/assets/levelup-logo-horizontal-DEFNc0ms.png",jje="/assets/levelup-logo-white-C2RAgAoG.png",nkt="/assets/listings-hero-BI9Ki9Dq.jpg",Le=k.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Pt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Le.displayName="Input";var VGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Jv,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;",m={};r(m),a=c(m),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 m(x,d){var p=d[0],b=d[1],C=d[2],E=d[3],L=p*E-C*b;return L?(x[0]=E*(L=1/L),x[1]=-b*L,x[2]=-C*L,x[3]=p*L,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 p=d[0],b=d[1],C=d[2],E=d[3],L=d[4],R=d[5],U=d[6],K=d[7],te=d[8];return x[0]=L*te-R*K,x[1]=C*K-b*te,x[2]=b*R-C*L,x[3]=R*U-E*te,x[4]=p*te-C*U,x[5]=C*E-p*R,x[6]=E*K-L*U,x[7]=b*U-p*K,x[8]=p*L-b*E,x}function y(x,d,p){var b=d[0],C=d[1],E=d[2],L=d[3],R=d[4],U=d[5],K=d[6],te=d[7],se=d[8],ie=p[0],de=p[1],fe=p[2],Te=p[3],ze=p[4],Fe=p[5],Qe=p[6],nt=p[7],ct=p[8];return x[0]=ie*b+de*L+fe*K,x[1]=ie*C+de*R+fe*te,x[2]=ie*E+de*U+fe*se,x[3]=Te*b+ze*L+Fe*K,x[4]=Te*C+ze*R+Fe*te,x[5]=Te*E+ze*U+Fe*se,x[6]=Qe*b+nt*L+ct*K,x[7]=Qe*C+nt*R+ct*te,x[8]=Qe*E+nt*U+ct*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 w(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 j(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 p=d[0],b=d[1],C=d[2],E=d[3],L=d[4],R=d[5],U=d[6],K=d[7],te=d[8],se=d[9],ie=d[10],de=d[11],fe=d[12],Te=d[13],ze=d[14],Fe=d[15],Qe=p*R-b*L,nt=p*U-C*L,ct=p*K-E*L,kt=b*U-C*R,yt=b*K-E*R,Mt=C*K-E*U,Rt=te*Te-se*fe,Bt=te*ze-ie*fe,rs=te*Fe-de*fe,Gt=se*ze-ie*Te,us=se*Fe-de*Te,Ss=ie*Fe-de*ze,Cs=Qe*Ss-nt*us+ct*Gt+kt*rs-yt*Bt+Mt*Rt;return Cs?(x[0]=(R*Ss-U*us+K*Gt)*(Cs=1/Cs),x[1]=(C*us-b*Ss-E*Gt)*Cs,x[2]=(Te*Mt-ze*yt+Fe*kt)*Cs,x[3]=(ie*yt-se*Mt-de*kt)*Cs,x[4]=(U*rs-L*Ss-K*Bt)*Cs,x[5]=(p*Ss-C*rs+E*Bt)*Cs,x[6]=(ze*ct-fe*Mt-Fe*nt)*Cs,x[7]=(te*Mt-ie*ct+de*nt)*Cs,x[8]=(L*us-R*rs+K*Rt)*Cs,x[9]=(b*rs-p*us-E*Rt)*Cs,x[10]=(fe*yt-Te*ct+Fe*Qe)*Cs,x[11]=(se*ct-te*yt-de*Qe)*Cs,x[12]=(R*Bt-L*Gt-U*Rt)*Cs,x[13]=(p*Gt-b*Bt+C*Rt)*Cs,x[14]=(Te*nt-fe*kt-ze*Qe)*Cs,x[15]=(te*kt-se*nt+ie*Qe)*Cs,x):null}function S(x,d,p){var b=d[0],C=d[1],E=d[2],L=d[3],R=d[4],U=d[5],K=d[6],te=d[7],se=d[8],ie=d[9],de=d[10],fe=d[11],Te=d[12],ze=d[13],Fe=d[14],Qe=d[15],nt=p[0],ct=p[1],kt=p[2],yt=p[3];return x[0]=nt*b+ct*R+kt*se+yt*Te,x[1]=nt*C+ct*U+kt*ie+yt*ze,x[2]=nt*E+ct*K+kt*de+yt*Fe,x[3]=nt*L+ct*te+kt*fe+yt*Qe,x[4]=(nt=p[4])*b+(ct=p[5])*R+(kt=p[6])*se+(yt=p[7])*Te,x[5]=nt*C+ct*U+kt*ie+yt*ze,x[6]=nt*E+ct*K+kt*de+yt*Fe,x[7]=nt*L+ct*te+kt*fe+yt*Qe,x[8]=(nt=p[8])*b+(ct=p[9])*R+(kt=p[10])*se+(yt=p[11])*Te,x[9]=nt*C+ct*U+kt*ie+yt*ze,x[10]=nt*E+ct*K+kt*de+yt*Fe,x[11]=nt*L+ct*te+kt*fe+yt*Qe,x[12]=(nt=p[12])*b+(ct=p[13])*R+(kt=p[14])*se+(yt=p[15])*Te,x[13]=nt*C+ct*U+kt*ie+yt*ze,x[14]=nt*E+ct*K+kt*de+yt*Fe,x[15]=nt*L+ct*te+kt*fe+yt*Qe,x}function M(x,d,p){var b,C,E,L,R,U,K,te,se,ie,de,fe,Te=p[0],ze=p[1],Fe=p[2];return d===x?(x[12]=d[0]*Te+d[4]*ze+d[8]*Fe+d[12],x[13]=d[1]*Te+d[5]*ze+d[9]*Fe+d[13],x[14]=d[2]*Te+d[6]*ze+d[10]*Fe+d[14],x[15]=d[3]*Te+d[7]*ze+d[11]*Fe+d[15]):(C=d[1],E=d[2],L=d[3],R=d[4],U=d[5],K=d[6],te=d[7],se=d[8],ie=d[9],de=d[10],fe=d[11],x[0]=b=d[0],x[1]=C,x[2]=E,x[3]=L,x[4]=R,x[5]=U,x[6]=K,x[7]=te,x[8]=se,x[9]=ie,x[10]=de,x[11]=fe,x[12]=b*Te+R*ze+se*Fe+d[12],x[13]=C*Te+U*ze+ie*Fe+d[13],x[14]=E*Te+K*ze+de*Fe+d[14],x[15]=L*Te+te*ze+fe*Fe+d[15]),x}function I(x,d,p){var b=p[0],C=p[1],E=p[2];return x[0]=d[0]*b,x[1]=d[1]*b,x[2]=d[2]*b,x[3]=d[3]*b,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 P(x,d,p){var b=Math.sin(p),C=Math.cos(p),E=d[4],L=d[5],R=d[6],U=d[7],K=d[8],te=d[9],se=d[10],ie=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+K*b,x[5]=L*C+te*b,x[6]=R*C+se*b,x[7]=U*C+ie*b,x[8]=K*C-E*b,x[9]=te*C-L*b,x[10]=se*C-R*b,x[11]=ie*C-U*b,x}function O(x,d,p){var b=Math.sin(p),C=Math.cos(p),E=d[0],L=d[1],R=d[2],U=d[3],K=d[8],te=d[9],se=d[10],ie=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-K*b,x[1]=L*C-te*b,x[2]=R*C-se*b,x[3]=U*C-ie*b,x[8]=E*b+K*C,x[9]=L*b+te*C,x[10]=R*b+se*C,x[11]=U*b+ie*C,x}function q(x,d,p){var b=Math.sin(p),C=Math.cos(p),E=d[0],L=d[1],R=d[2],U=d[3],K=d[4],te=d[5],se=d[6],ie=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+K*b,x[1]=L*C+te*b,x[2]=R*C+se*b,x[3]=U*C+ie*b,x[4]=K*C-E*b,x[5]=te*C-L*b,x[6]=se*C-R*b,x[7]=ie*C-U*b,x}function $(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 z(x,d,p){var b,C,E,L=p[0],R=p[1],U=p[2],K=Math.sqrt(L*L+R*R+U*U);return K0&&(E=1/Math.sqrt(E)),x[0]=d[0]*E,x[1]=d[1]*E,x[2]=d[2]*E,x}function Oe(x,d){return x[0]*d[0]+x[1]*d[1]+x[2]*d[2]}function qe(x,d,p){var b=d[0],C=d[1],E=d[2],L=p[0],R=p[1],U=p[2];return x[0]=C*U-E*R,x[1]=E*L-b*U,x[2]=b*R-C*L,x}function ve(x,d,p,b){var C=d[0],E=d[1],L=d[2];return x[0]=C+b*(p[0]-C),x[1]=E+b*(p[1]-E),x[2]=L+b*(p[2]-L),x}function dt(x,d,p){var b=d[0],C=d[1],E=d[2],L=p[3]*b+p[7]*C+p[11]*E+p[15];return x[0]=(p[0]*b+p[4]*C+p[8]*E+p[12])/(L=L||1),x[1]=(p[1]*b+p[5]*C+p[9]*E+p[13])/L,x[2]=(p[2]*b+p[6]*C+p[10]*E+p[14])/L,x}function pe(x,d,p){var b=d[0],C=d[1],E=d[2];return x[0]=b*p[0]+C*p[3]+E*p[6],x[1]=b*p[1]+C*p[4]+E*p[7],x[2]=b*p[2]+C*p[5]+E*p[8],x}function Ue(x,d,p){var b=p[0],C=p[1],E=p[2],L=p[3],R=d[0],U=d[1],K=d[2],te=C*K-E*U,se=E*R-b*K,ie=b*U-C*R;return x[0]=R+L*(te+=te)+C*(ie+=ie)-E*(se+=se),x[1]=U+L*se+E*te-b*ie,x[2]=K+L*ie+b*se-C*te,x}function Xe(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 Ce=he,Je=xe,Ge=ce;function lt(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function He(x,d,p){return x[0]=d[0]*p,x[1]=d[1]*p,x[2]=d[2]*p,x[3]=d[3]*p,x}function We(x,d){var p=d[0],b=d[1],C=d[2],E=d[3],L=p*p+b*b+C*C+E*E;return L>0&&(L=1/Math.sqrt(L)),x[0]=p*L,x[1]=b*L,x[2]=C*L,x[3]=E*L,x}function tt(x,d,p){var b=d[0],C=d[1],E=d[2],L=d[3];return x[0]=p[0]*b+p[4]*C+p[8]*E+p[12]*L,x[1]=p[1]*b+p[5]*C+p[9]*E+p[13]*L,x[2]=p[2]*b+p[6]*C+p[10]*E+p[14]*L,x[3]=p[3]*b+p[7]*C+p[11]*E+p[15]*L,x}function Ke(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function rt(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function it(x,d,p){p*=.5;var b=d[0],C=d[1],E=d[2],L=d[3],R=Math.sin(p),U=Math.cos(p);return x[0]=b*U+L*R,x[1]=C*U+E*R,x[2]=E*U-C*R,x[3]=L*U-b*R,x}function It(x,d,p){p*=.5;var b=d[0],C=d[1],E=d[2],L=d[3],R=Math.sin(p),U=Math.cos(p);return x[0]=b*U-E*R,x[1]=C*U+L*R,x[2]=E*U+b*R,x[3]=L*U-C*R,x}J(),lt();var Vt,hs,Es,Ts=We,cr=(Vt=J(),hs=ne(1,0,0),Es=ne(0,1,0),function(x,d,p){var b=Oe(d,p);return b<-.999999?(qe(Vt,hs,d),Ge(Vt)<1e-6&&qe(Vt,Es,d),ke(Vt,Vt),function(C,E,L){L*=.5;var R=Math.sin(L);C[0]=R*E[0],C[1]=R*E[1],C[2]=R*E[2],C[3]=Math.cos(L)}(x,Vt,Math.PI),x):b>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(qe(Vt,d,p),x[0]=Vt[0],x[1]=Vt[1],x[2]=Vt[2],x[3]=1+b,Ts(x,x))});function zr(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function Ft(x,d){var p=new u(2);return p[0]=x,p[1]=d,p}function Ps(x,d,p){return x[0]=d,x[1]=p,x}function yr(x,d,p){return x[0]=d[0]+p[0],x[1]=d[1]+p[1],x}function Is(x,d,p){return x[0]=d[0]-p[0],x[1]=d[1]-p[1],x}function Ar(x,d,p){return x[0]=d[0]*p,x[1]=d[1]*p,x}function tn(x){var d=x[0],p=x[1];return Math.sqrt(d*d+p*p)}function na(x,d){var p=d[0],b=d[1],C=p*p+b*b;return C>0&&(C=1/Math.sqrt(C)),x[0]=d[0]*C,x[1]=d[1]*C,x}function Ln(x,d){return x[0]*d[0]+x[1]*d[1]}Ke(),Ke(),f();var tr,dr,Sr=Is;function dn(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}zr();var Yr=function(){if(dr)return tr;function x(d,p,b,C){this.cx=3*d,this.bx=3*(b-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*p,this.by=3*(C-p)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=p,this.p2x=b,this.p2y=C}return dr=1,tr=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,p){if(p===void 0&&(p=1e-6),d<0)return 0;if(d>1)return 1;for(var b=d,C=0;C<8;C++){var E=this.sampleCurveX(b)-d;if(Math.abs(E)E?R=b:U=b,b=.5*(U-R)+R;return b},solve:function(d,p){return this.sampleCurveY(this.solveCurveX(d,p))}},tr}(),ui=dn(Yr);function ns(x,d){this.x=x,this.y=d}function Wt(x,d){if(Array.isArray(x)){if(!Array.isArray(d)||x.length!==d.length)return!1;for(let p=0;p=1)return 1;const d=x*x,p=d*x;return 4*(x<.5?p:3*(x-d)+p-.75)}function no(x,d,p,b){const C=new ui(x,d,p,b);return function(E){return C.solve(E)}}const $t=no(.25,.1,.25,1);function je(x,d,p){return Math.min(p,Math.max(d,x))}function $e(x,d,p){return(p=je((p-x)/(d-x),0,1))*p*(3-2*p)}function st(x,d,p){const b=p-d,C=((x-d)%b+b)%b+d;return C===d?p:C}function vt(x,d,p){if(!x.length)return p(null,[]);let b=x.length;const C=new Array(x.length);let E=null;x.forEach((L,R)=>{d(L,(U,K)=>{U&&(E=U),C[R]=K,--b==0&&p(E,C)})})}let xt=1;function Ot(){return xt++}function Zt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function qt(x,d){x.forEach(p=>{d[p]&&(d[p]=d[p].bind(d))})}function Xt(x,d,p){const b={};for(const C in x)b[C]=d.call(this,x[C],C,x);return b}function Os(x,d,p){const b={};for(const C in x)d.call(this,x[C],C,x)&&(b[C]=x[C]);return b}function Ns(x){return Array.isArray(x)?x.map(Ns):typeof x=="object"&&x?Xt(x,Ns):x}function _r(x,d){for(let p=0;p=0)return!0;return!1}const Zr={};function gr(x){Zr[x]||(typeof console<"u"&&console.warn(x),Zr[x]=!0)}function Un(x,d,p){return(p.y-x.y)*(d.x-x.x)>(d.y-x.y)*(p.x-x.x)}function Vn(x){let d=0;for(let p,b,C=0,E=x.length,L=E-1;C@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(p,b,C,E)=>{const L=C||E;return d[b]=!L||L.toLowerCase(),""}),d["max-age"]){const p=parseInt(d["max-age"],10);isNaN(p)?delete d["max-age"]:d["max-age"]=p}return d}let cl=null;function ii(x,d){return[x[4*d],x[4*d+1],x[4*d+2],x[4*d+3]]}function fl(x,d,p,b){for(;d>1;x[C]>1;x[C]<=b?d=C+1:p=C}return d}function za(x){return x>0?1/(1.001-x):1+x}function mo(x){return x>0?1-1/(1.001-x):-x}function Ei(x,d,p){return(x-d.min)*(p.max-p.min)/(d.max-d.min)+p.min}const ya={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(!ya.API_URL)return null;try{const x=new URL(ya.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 po(x){return ya.API_URL_REGEX.test(x)}function Ac(x){return ya.API_SPRITE_REGEX.test(x)}let Wc,hu,$f,Vl,hh,Md;function Zm(){return Wc==null&&(Wc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Wc}const Hl={now:()=>Vl!==void 0?Vl:performance.now(),setNow(x){Vl=x},restoreNow(){Vl=void 0},frame(x){const d=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(x,d=0){const{width:p,height:b}=x;hh||(hh=document.createElement("canvas"));const C=hh.getContext("2d",{willReadFrequently:!0});if(!C)throw new Error("failed to create canvas 2d context");return(p>hh.width||b>hh.height)&&(hh.width=p,hh.height=b),C.clearRect(-d,-d,p+2*d,b+2*d),C.drawImage(x,0,0,p,b),C.getImageData(-d,-d,p+2*d,b+2*d)},resolveURL:x=>(hu||(hu=document.createElement("a")),hu.href=x,hu.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&($f==null&&($f=window.matchMedia("(prefers-reduced-motion: reduce)")),$f.matches)},hasCanvasFingerprintNoise(){if(Md!==void 0)return Md;if(!Zm())return Md=!1,!1;const x=new OffscreenCanvas(85,1),d=x.getContext("2d",{willReadFrequently:!0});let p=0;for(let C=0;C0?`?${E}`:""}`}const J1="mapbox-tiles";let eb=500,tb=50;const Rp=["language","worldview","jobid"];let dm,mu;function um(){try{return caches}catch{}}function Vd(){const x=um();x&&dm==null&&(dm=x.open(J1))}let Td=1/0;const pu={supported:!1,testSupport:function(x){!Ym&&Uf&&(Qm?sv(x):qf=x)}};let qf,Uf,Ym=!1,Qm=!1;const Ad=typeof self<"u"?self:{};function sv(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,Uf),x.isContextLost())return;pu.supported=!0}catch{}x.deleteTexture(d),Ym=!0}Ad.document&&(Uf=Ad.document.createElement("img"),Uf.onload=function(){qf&&sv(qf),qf=null,Qm=!0},Uf.onerror=function(){Ym=!0,qf=null},Uf.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const eg={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(eg);class Il extends Error{constructor(d,p,b){p===401&&po(b)&&(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=p,this.url=b}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const sb=ka()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,tg=function(x,d){if(!(/^file:/.test(p=x.url)||/^file:/.test(sb())&&!/^\w+:/.test(p))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(b,C){const E=new AbortController,L=new Request(b.url,{method:b.method||"GET",body:b.body,credentials:b.credentials,headers:b.headers,referrer:sb(),referrerPolicy:b.referrerPolicy,signal:E.signal});let R=!1,U=!1;const K=(te=L.url).indexOf("sku=")>0&&po(te);var te;b.type==="json"&&L.headers.set("Accept","application/json");const se=(de,fe,Te)=>{if(U)return;if(de&&de.message!=="SecurityError"&&gr(de.toString()),fe&&Te)return ie(fe);const ze=Date.now();fetch(L).then(Fe=>{if(Fe.ok){const Qe=K?Fe.clone():null;return ie(Fe,Qe,ze)}return C(new Il(Fe.statusText,Fe.status,b.url))}).catch(Fe=>{Fe.name!=="AbortError"&&C(new Error(`${Fe.message} ${b.url}`))})},ie=(de,fe,Te)=>{(b.type==="arrayBuffer"?de.arrayBuffer():b.type==="json"?de.json():de.text()).then(ze=>{U||(fe&&Te&&function(Fe,Qe,nt){if(Vd(),dm==null)return;const ct=jo(Qe.headers.get("Cache-Control")||"");if(ct["no-store"])return;const kt={status:Qe.status,statusText:Qe.statusText,headers:new Headers};Qe.headers.forEach((Rt,Bt)=>kt.headers.set(Bt,Rt)),ct["max-age"]&&kt.headers.set("Expires",new Date(nt+1e3*ct["max-age"]).toUTCString());const yt=kt.headers.get("Expires");if(!yt||new Date(yt).getTime()-nt<42e4)return;let Mt=_y(Fe.url,{persistentParams:Rp});if(Qe.status===206){const Rt=Fe.headers.get("Range");if(!Rt)return;kt.status=200,Mt=Jx(Mt,{range:Rt})}(function(Rt,Bt){if(mu===void 0)try{new Response(new ReadableStream),mu=!0}catch{mu=!1}mu?Bt(Rt.body):Rt.blob().then(Bt).catch(rs=>gr(rs.message))})(Qe,Rt=>{const Bt=new Response((rs=Qe.status)!==200&&rs!==404&&[101,103,204,205,304].includes(rs)?null:Rt,kt);var rs;Vd(),dm!=null&&dm.then(Gt=>Gt.put(Mt,Bt)).catch(Gt=>gr(Gt.message))})}(L,fe,Te),R=!0,C(null,ze,de.headers))}).catch(ze=>{U||C(new Error(ze.message))})};return K?function(de,fe){if(Vd(),dm==null)return fe(null);dm.then(Te=>{let ze=_y(de.url,{persistentParams:Rp});const Fe=de.headers.get("Range");Fe&&(ze=Jx(ze,{range:Fe})),Te.match(ze).then(Qe=>{const nt=function(ct){if(!ct)return!1;const kt=new Date(ct.headers.get("Expires")||0),yt=jo(ct.headers.get("Cache-Control")||"");return Number(kt)>Date.now()&&!yt["no-cache"]}(Qe);Te.delete(ze).catch(fe),nt&&Te.put(ze,Qe.clone()).catch(fe),fe(null,Qe,nt)}).catch(fe)}).catch(fe)}(L,se):se(null,null),{cancel:()=>{U=!0,R||E.abort()}}}(x,d);if(ka(self)&&self.worker.actor)return self.worker.actor.send("getResource",x,d,void 0,!0)}var p;return function(b,C){const E=new XMLHttpRequest;E.open(b.method||"GET",b.url,!0),b.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const L in b.headers)E.setRequestHeader(L,b.headers[L]);return b.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=b.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 L=E.response;if(b.type==="json")try{L=JSON.parse(E.response)}catch(U){return C(U)}const R=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(U=>{const K=U.split(": "),te=K.shift(),se=K.join(": ");R.append(te,se)}),C(null,L,R)}else C(new Il(E.statusText,E.status,b.url))},E.send(b.body),{cancel:()=>E.abort()}}(x,d)},Fh=function(x,d){return tg(Object.assign(x,{type:"arrayBuffer"}),d)};function Qw(x){const d=document.createElement("a");return d.href=x,d.protocol===location.protocol&&d.host===location.host}const H3="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let rv,Ba;rv=[],Ba=0;const wy=function(x,d){if(pu.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),Ba>=ya.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:x,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return rv.push(E),E}Ba++;let p=!1;const b=()=>{if(!p)for(p=!0,Ba--;rv.length&&Ba{b(),E?d(E):L&&(self.createImageBitmap?function(U,K){const te=new Blob([new Uint8Array(U)],{type:"image/png"});createImageBitmap(te).then(se=>{K(null,se)}).catch(se=>{K(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.`))})}(L,(U,K)=>d(U,K,R)):function(U,K){const te=new Image;te.onload=()=>{K(null,te),URL.revokeObjectURL(te.src),te.onload=null,requestAnimationFrame(()=>{te.src=H3})},te.onerror=()=>K(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(U)],{type:"image/png"});te.src=U.byteLength?URL.createObjectURL(se):H3}(L,(U,K)=>d(U,K,R)))});return{cancel:()=>{C.cancel(),b()}}};var Xw,G3,W3,hm={exports:{}},nv={exports:{}},av={exports:{}},Jw=function(){if(W3)return hm.exports;W3=1;var x=(Xw||(Xw=1,nv.exports=function(p,b){var C,E,L,R,U,K,te,se;for(E=p.length-(C=3&p.length),L=b,U=3432918353,K=461845907,se=0;se>>16)*U&65535)<<16)&4294967295)<<15|te>>>17))*K+(((te>>>16)*K&65535)<<16)&4294967295)<<13|L>>>19))+((5*(L>>>16)&65535)<<16)&4294967295))+((58964+(R>>>16)&65535)<<16);switch(te=0,C){case 3:te^=(255&p.charCodeAt(se+2))<<16;case 2:te^=(255&p.charCodeAt(se+1))<<8;case 1:L^=te=(65535&(te=(te=(65535&(te^=255&p.charCodeAt(se)))*U+(((te>>>16)*U&65535)<<16)&4294967295)<<15|te>>>17))*K+(((te>>>16)*K&65535)<<16)&4294967295}return L^=p.length,L=2246822507*(65535&(L^=L>>>16))+((2246822507*(L>>>16)&65535)<<16)&4294967295,L=3266489909*(65535&(L^=L>>>13))+((3266489909*(L>>>16)&65535)<<16)&4294967295,(L^=L>>>16)>>>0}),nv.exports),d=(G3||(G3=1,av.exports=function(p,b){for(var C,E=p.length,L=b^E,R=0;E>=4;)C=1540483477*(65535&(C=255&p.charCodeAt(R)|(255&p.charCodeAt(++R))<<8|(255&p.charCodeAt(++R))<<16|(255&p.charCodeAt(++R))<<24))+((1540483477*(C>>>16)&65535)<<16),L=1540483477*(65535&L)+((1540483477*(L>>>16)&65535)<<16)^(C=1540483477*(65535&(C^=C>>>24))+((1540483477*(C>>>16)&65535)<<16)),E-=4,++R;switch(E){case 3:L^=(255&p.charCodeAt(R+2))<<16;case 2:L^=(255&p.charCodeAt(R+1))<<8;case 1:L=1540483477*(65535&(L^=255&p.charCodeAt(R)))+((1540483477*(L>>>16)&65535)<<16)}return L=1540483477*(65535&(L^=L>>>13))+((1540483477*(L>>>16)&65535)<<16),(L^=L>>>15)>>>0}),av.exports);return hm.exports=x,hm.exports.murmur3=x,hm.exports.murmur2=d,hm.exports}(),rb=dn(Jw);class Xm{constructor(d,...p){Object.assign(this,p[0]||{}),this.type=d}}class jy extends Xm{constructor(d,p={}){super("error",Object.assign({error:d},p))}}function e2(x,d,p){p[x]&&p[x].indexOf(d)!==-1||(p[x]=p[x]||[],p[x].push(d))}function _t(x,d,p){if(p&&p[x]){const b=p[x].indexOf(d);b!==-1&&p[x].splice(b,1)}}class As{on(d,p){return this._listeners=this._listeners||{},e2(d,p,this._listeners),this}off(d,p){return _t(d,p,this._listeners),_t(d,p,this._oneTimeListeners),this}once(d,p){return p?(this._oneTimeListeners=this._oneTimeListeners||{},e2(d,p,this._oneTimeListeners),this):new Promise(b=>{this.once(d,b)})}fire(d,p){const b=typeof d=="string"?new Xm(d,p):d,C=b.type;if(this.listens(C)){b.target=this;const E=this._listeners&&this._listeners[C]?this._listeners[C].slice():[];for(const U of E)U.call(this,b);const L=this._oneTimeListeners&&this._oneTimeListeners[C]?this._oneTimeListeners[C].slice():[];for(const U of L)_t(C,U,this._oneTimeListeners),U.call(this,b);const R=this._eventedParent;if(R){const U=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(b,U),R.fire(b)}}else b instanceof jy&&console.error(b.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,p){return this._eventedParent=d,this._eventedParentData=p,this}}class Js{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Js(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[p,b]=d.split("");return new Js({name:p,iconsetId:b})}static isEqual(d,p){return d.name===p.name&&d.iconsetId===p.iconsetId}toString(){return Js.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var yn,vn={},xa=function(){if(yn)return vn;yn=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 p(E){return d(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function b(E){return(L=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:L>1?1:L;var L}function C(E,L,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?E+(L-E)*R*6:2*R<1?L:3*R<2?E+(L-E)*(2/3-R)*6:E}try{vn.parseCSSColor=function(E){var L,R=E.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(L=parseInt(R.substr(1),16))>=0&&L<=4095?[(3840&L)>>4|(3840&L)>>8,240&L|(240&L)>>4,15&L|(15&L)<<4,1]:null:R.length===7&&(L=parseInt(R.substr(1),16))>=0&&L<=16777215?[(16711680&L)>>16,(65280&L)>>8,255&L,1]:null;var U=R.indexOf("("),K=R.indexOf(")");if(U!==-1&&K+1===R.length){var te=R.substr(0,U),se=R.substr(U+1,K-(U+1)).split(","),ie=1;switch(te){case"rgba":if(se.length!==4)return null;ie=b(se.pop());case"rgb":return se.length!==3?null:[p(se[0]),p(se[1]),p(se[2]),ie];case"hsla":if(se.length!==4)return null;ie=b(se.pop());case"hsl":if(se.length!==3)return null;var de=(parseFloat(se[0])%360+360)%360/360,fe=b(se[1]),Te=b(se[2]),ze=Te<=.5?Te*(fe+1):Te+fe-Te*fe,Fe=2*Te-ze;return[d(255*C(Fe,ze,de+1/3)),d(255*C(Fe,ze,de)),d(255*C(Fe,ze,de-1/3)),ie];default:return null}}return null}}catch{}return vn}();class Wr{constructor(d,p,b,C=1){this.r=d,this.g=p,this.b=b,this.a=C}static parse(d){if(!d)return;if(d instanceof Wr)return d;if(typeof d!="string")return;const p=xa.parseCSSColor(d);return p?new Wr(p[0]/255,p[1]/255,p[2]/255,p[3]):void 0}toString(){const[d,p,b,C]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*p)},${Math.round(255*b)},${C})`}toNonPremultipliedRenderColor(d){const{r:p,g:b,b:C,a:E}=this;return new sg(d,p,b,C,E)}toPremultipliedRenderColor(d){const{r:p,g:b,b:C,a:E}=this;return new Fp(d,p*E,b*E,C*E,E)}clone(){return new Wr(this.r,this.g,this.b,this.a)}}class fo{constructor(d,p,b,C,E,L=!1){if(this.premultiplied=!1,this.premultiplied=L,d){const R=d.image.height,U=R*R;this.premultiplied?(p=E===0?0:p/E*(R-1),b=E===0?0:b/E*(R-1),C=E===0?0:C/E*(R-1)):(p*=R-1,b*=R-1,C*=R-1);const K=Math.floor(p),te=Math.floor(b),se=Math.floor(C),ie=Math.ceil(p),de=Math.ceil(b),fe=Math.ceil(C),Te=p-K,ze=b-te,Fe=C-se,Qe=d.image.data,nt=4*(K+te*U+se*R),ct=4*(K+te*U+fe*R),kt=4*(K+de*U+se*R),yt=4*(K+de*U+fe*R),Mt=4*(ie+te*U+se*R),Rt=4*(ie+te*U+fe*R),Bt=4*(ie+de*U+se*R),rs=4*(ie+de*U+fe*R);if(nt<0||rs>=Qe.length)throw new Error("out of range");this.r=Xr(Xr(Xr(Qe[nt],Qe[ct],Fe),Xr(Qe[kt],Qe[yt],Fe),ze),Xr(Xr(Qe[Mt],Qe[Rt],Fe),Xr(Qe[Bt],Qe[rs],Fe),ze),Te)/255*(this.premultiplied?E:1),this.g=Xr(Xr(Xr(Qe[nt+1],Qe[ct+1],Fe),Xr(Qe[kt+1],Qe[yt+1],Fe),ze),Xr(Xr(Qe[Mt+1],Qe[Rt+1],Fe),Xr(Qe[Bt+1],Qe[rs+1],Fe),ze),Te)/255*(this.premultiplied?E:1),this.b=Xr(Xr(Xr(Qe[nt+2],Qe[ct+2],Fe),Xr(Qe[kt+2],Qe[yt+2],Fe),ze),Xr(Xr(Qe[Mt+2],Qe[Rt+2],Fe),Xr(Qe[Bt+2],Qe[rs+2],Fe),ze),Te)/255*(this.premultiplied?E:1),this.a=E}else this.r=p,this.g=b,this.b=C,this.a=E}toArray(){const{r:d,g:p,b,a:C}=this;return[255*d,255*p,255*b,C]}toHslaArray(){let{r:d,g:p,b,a:C}=this;if(this.premultiplied){if(C===0)return[0,0,0,0];const fe=1/C;d*=fe,p*=fe,b*=fe}const E=Math.min(Math.max(d,0),1),L=Math.min(Math.max(p,0),1),R=Math.min(Math.max(b,0),1),U=Math.min(E,L,R),K=Math.max(E,L,R),te=K-U,se=.5*(U+K);if(te===0)return[0,0,100*se,C];const ie=se>.5?te/(2-K-U):te/(K+U);let de;switch(K){case E:de=60*((L-R)/te+(LXr(b,d[C],p))}Wr.black=new Wr(0,0,0,1),Wr.white=new Wr(1,1,1,1),Wr.transparent=new Wr(0,0,0,0),Wr.red=new Wr(1,0,0,1),Wr.blue=new Wr(0,0,1,1);var ov=Object.freeze({__proto__:null,array:iv,color:function(x,d,p){return new Wr(Xr(x.r,d.r,p),Xr(x.g,d.g,p),Xr(x.b,d.b,p),Xr(x.a,d.a,p))},number:Xr});class Jm extends Error{constructor(d,p){super(p),this.message=p,this.key=d}}class nb{constructor(d,p=[]){this.parent=d,this.bindings={};for(const[b,C]of p)this.bindings[b]=C}concat(d){return new nb(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 zp={kind:"null"},Vr={kind:"number"},$a={kind:"string"},Mi={kind:"boolean"},mh={kind:"color"},Vf={kind:"object"},bi={kind:"value"},K3={kind:"collator"},t2={kind:"formatted"},s2={kind:"resolvedImage"};function Hd(x,d){return{kind:"array",itemType:x,N:d}}function Nl(x){if(x.kind==="array"){const d=Nl(x.itemType);return typeof x.N=="number"?`array<${d}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${d}>`}return x.kind}const zme=[zp,Vr,$a,Mi,mh,t2,Vf,Hd(bi),s2];function Ny(x,d){if(d.kind==="error")return null;if(x.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!Ny(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 p of zme)if(!Ny(p,d))return null}}return`Expected ${Nl(x)} but found ${Nl(d)} instead.`}function n6(x,d){return d.some(p=>p.kind===x.kind)}function r2(x,d){return d.some(p=>p==="null"?x===null:p==="array"?Array.isArray(x):p==="object"?x&&!Array.isArray(x)&&typeof x=="object":p===typeof x)}function Z3(x,d){return x.kind==="array"&&d.kind==="array"?x.N===d.N&&Z3(x.itemType,d.itemType):x.kind===d.kind}class a6{constructor(d,p,b){this.sensitivity=d?p?"variant":"case":p?"accent":"base",this.locale=b,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(d,p){return this.collator.compare(d,p)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Y3{constructor(d,p,b,C,E){this.text=d.normalize?d.normalize():d,this.image=p,this.scale=b,this.fontStack=C,this.textColor=E}}class zu{constructor(d){this.sections=d}static fromString(d){return new zu([new Y3(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 zu?d:zu.fromString(d)}toString(){return this.sections.length===0?"":this.sections.map(d=>d.text).join("")}serialize(){const d=["format"];for(const p of this.sections){if(p.image){const C=p.image.getPrimary().id.toString();d.push(["image",C]);continue}d.push(p.text);const b={};p.fontStack&&(b["text-font"]=["literal",p.fontStack.split(",")]),p.scale&&(b["font-scale"]=p.scale),p.textColor&&(b["text-color"]=["rgba"].concat(p.textColor.toNonPremultipliedRenderColor(null).toArray())),d.push(b)}return d}}class rg{constructor(d,p={}){this.id=Js.from(d),this.params=p.params,this.sx=p.sx||1,this.sy=p.sy||1}toString(){return JSON.stringify(this)}static parse(d){let p,b,C,E;try{({id:p,params:b,sx:C,sy:E}=JSON.parse(d)||{})}catch{return null}return p?new rg(p,{params:b,sx:C,sy:E}):null}scaleSelf(d,p=d){return this.sx*=d,this.sy*=p,this}}class Bu{constructor(d,p,b,C,E=!1){this.primaryId=Js.from(d),this.primaryOptions=p,b&&(this.secondaryId=Js.from(b)),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 rg(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new rg(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Bu.build({name:d}):d}static build(d,p,b,C){return!d||typeof d=="object"&&!("name"in d)?null:new Bu(d,b,p,C)}}function lv(x,d,p,b){return typeof x=="number"&&x>=0&&x<=255&&typeof d=="number"&&d>=0&&d<=255&&typeof p=="number"&&p>=0&&p<=255?b===void 0||typeof b=="number"&&b>=0&&b<=1?null:`Invalid rgba value [${[x,d,p,b].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof b=="number"?[x,d,p,b]:[x,d,p]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ab(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof Wr||x instanceof a6||x instanceof zu||x instanceof Bu)return!0;if(Array.isArray(x)){for(const d of x)if(!ab(d))return!1;return!0}if(typeof x=="object"){for(const d in x)if(!ab(x[d]))return!1;return!0}return!1}function Ec(x){if(x===null)return zp;if(typeof x=="string")return $a;if(typeof x=="boolean")return Mi;if(typeof x=="number")return Vr;if(x instanceof Wr)return mh;if(x instanceof a6)return K3;if(x instanceof zu)return t2;if(x instanceof Bu)return s2;if(Array.isArray(x)){const d=x.length;let p;for(const b of x){const C=Ec(b);if(p){if(p===C)continue;p=bi;break}p=C}return Hd(p||bi,d)}return Vf}function ep(x){const d=typeof x;return x===null?"":d==="string"||d==="number"||d==="boolean"?String(x):x instanceof zu||x instanceof Bu||x instanceof Wr?x.toString():JSON.stringify(x)}class ng{constructor(d,p){this.type=d,this.value=p}static parse(d,p){if(d.length!==2)return p.error(`'literal' expression requires exactly one argument, but found ${d.length-1} instead.`);if(!ab(d[1]))return p.error("invalid value");const b=d[1];let C=Ec(b);const E=p.expectedType;return C.kind!=="array"||C.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(C=E),new ng(C,b)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Wr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof zu?this.value.serialize():this.value}}class pc{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const i6={string:$a,number:Vr,boolean:Mi,object:Vf};class Bp{constructor(d,p){this.type=d,this.args=p}static parse(d,p){if(d.length<2)return p.error("Expected at least one argument.");let b,C=1;const E=d[0];if(E==="array"){let R,U;if(d.length>2){const K=d[1];if(typeof K!="string"||!(K in i6)||K==="object")return p.error('The item type argument of "array" must be one of string, number, boolean',1);R=i6[K],C++}else R=bi;if(d.length>3){if(d[2]!==null&&(typeof d[2]!="number"||d[2]<0||d[2]!==Math.floor(d[2])))return p.error('The length argument to "array" must be a positive integer literal',2);U=d[2],C++}b=Hd(R,U)}else b=i6[E];const L=[];for(;Cd.outputDefined())}serialize(){const d=this.type,p=[d.kind];if(d.kind==="array"){const b=d.itemType;if(b.kind==="string"||b.kind==="number"||b.kind==="boolean"){p.push(b.kind);const C=d.N;(typeof C=="number"||this.args.length>1)&&p.push(C)}}return p.concat(this.args.map(b=>b.serialize()))}}class Hf{constructor(d){this.type=t2,this.sections=d}static parse(d,p){if(d.length<2)return p.error("Expected at least one argument.");const b=d[1];if(!Array.isArray(b)&&typeof b=="object")return p.error("First argument must be an image or text section.");const C=[];let E=!1;for(let L=1;L<=d.length-1;++L){const R=d[L];if(E&&typeof R=="object"&&!Array.isArray(R)){E=!1;let U=null;if(R["font-scale"]&&(U=p.parseObjectValue(R["font-scale"],L,"font-scale",Vr),!U))return null;let K=null;if(R["text-font"]&&(K=p.parseObjectValue(R["text-font"],L,"text-font",Hd($a)),!K))return null;let te=null;if(R["text-color"]&&(te=p.parseObjectValue(R["text-color"],L,"text-color",mh),!te))return null;const se=C[C.length-1];se.scale=U,se.font=K,se.textColor=te}else{const U=p.parse(d[L],L,bi);if(!U)return null;const K=U.type.kind;if(K!=="string"&&K!=="value"&&K!=="null"&&K!=="resolvedImage")return p.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,C.push({content:U,scale:null,font:null,textColor:null})}}return new Hf(C)}evaluate(d){return new zu(this.sections.map(p=>{const b=p.content.evaluate(d);return Z3(Ec(b),s2)?new Y3("",b,null,null,null):new Y3(ep(b),null,p.scale?p.scale.evaluate(d):null,p.font?p.font.evaluate(d).join(","):null,p.textColor?p.textColor.evaluate(d):null)}))}eachChild(d){for(const p of this.sections)d(p.content),p.scale&&d(p.scale),p.font&&d(p.font),p.textColor&&d(p.textColor)}outputDefined(){return!1}serialize(){const d=["format"];for(const p of this.sections){d.push(p.content.serialize());const b={};p.scale&&(b["font-scale"]=p.scale.serialize()),p.font&&(b["text-font"]=p.font.serialize()),p.textColor&&(b["text-color"]=p.textColor.serialize()),d.push(b)}return d}}class Gn{constructor(d,p,b,C){this._imageWarnHistory={},this.type=s2,this.namePrimary=d,this.nameSecondary=p,b&&(this.paramsPrimary=b.params,this.iconsetIdPrimary=b.iconset?b.iconset.id:void 0),C&&(this.paramsSecondary=C.params,this.iconsetIdSecondary=C.iconset?C.iconset.id:void 0)}static parse(d,p){if(d.length<2)return p.error("Expected two or more arguments.");let b=1;const C=[];function E(){if(bJs.isEqual(L,E)),C.available){const L=C.getSecondary()?C.getSecondary().id:null;L&&(C.available=d.availableImages.some(R=>Js.isEqual(R,L)))}}return C}eachChild(d){if(d(this.namePrimary),this.paramsPrimary)for(const p in this.paramsPrimary)this.paramsPrimary[p]&&d(this.paramsPrimary[p]);if(this.nameSecondary&&(d(this.nameSecondary),this.paramsSecondary))for(const p in this.paramsSecondary)this.paramsSecondary[p]&&d(this.paramsSecondary[p])}outputDefined(){return!1}serializeOptions(d,p){const b={};if(p&&(b.iconset={id:p}),d){b.params={};for(const C in d)d[C]&&(b.params[C]=d[C].serialize())}return Object.keys(b).length>0?b:void 0}serialize(){const d=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const p=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);p&&d.push(p)}if(this.nameSecondary&&(d.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const p=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);p&&d.push(p)}return d}}function Br(x){return bn(x)?"string":ib(x)?"number":X3(x)?"boolean":Array.isArray(x)?"array":x===null?"null":Q3(x)?"object":typeof x}function Q3(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function bn(x){return typeof x=="string"||x instanceof String}function ib(x){return typeof x=="number"||x instanceof Number}function X3(x){return typeof x=="boolean"||x instanceof Boolean}const gn={"to-boolean":Mi,"to-color":mh,"to-number":Vr,"to-string":$a};class Gf{constructor(d,p){this.type=d,this.args=p}static parse(d,p){if(d.length<2)return p.error("Expected at least one argument.");const b=d[0],C=[];let E=zp;if(b==="to-array"){if(!Array.isArray(d[1]))return null;const L=d[1].length;if(p.expectedType){if(p.expectedType.kind!=="array")return p.error(`Expected ${p.expectedType.kind} but found array.`);E=Hd(p.expectedType.itemType,L)}else{if(!(L>0&&ab(d[1][0])))return null;E=Hd(Ec(d[1][0]),L)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(p)}: expected an array containing either three or four numeric values.`:lv(p[0],p[1],p[2],p[3]),!b))return new Wr(p[0]/255,p[1]/255,p[2]/255,p[3])}throw new pc(b||`Could not parse color from value '${typeof p=="string"?p:String(JSON.stringify(p))}'`)}if(this.type.kind==="number"){let p=null;for(const b of this.args){if(p=b.evaluate(d),p===null)return 0;const C=Number(p);if(!isNaN(C))return C}throw new pc(`Could not convert ${JSON.stringify(p)} to number.`)}return this.type.kind==="formatted"?zu.fromString(ep(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Bu.build(ep(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(p=>p.evaluate(d)):ep(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 Hf([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Gn(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(p=>{d.push(p.serialize())}),d}}const o6=["Unknown","Point","LineString","Polygon"];class J3{constructor(d,p,b){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=p,this.iconImageUseTheme=b}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?o6[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,p=this.featureDistanceData.scale,{x:b,y:C}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(b*p-d[0])+this.featureDistanceData.bearing[1]*(C*p-d[1])}return 0}parseColor(d){let p=this._parseColorCache[d];return p||(p=this._parseColorCache[d]=Wr.parse(d)),p}getConfig(d){return this.options?this.options.get(d):null}}class $u{constructor(d,p,b,C,E){this.name=d,this.type=p,this._evaluate=b,this.args=C,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const p=$u.definitions[this.name];this._evaluate=Array.isArray(p)?p[2]:p.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,p){const b=d[0],C=$u.definitions[b];if(!C)return p.error(`Unknown expression "${b}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(C)?C[0]:C.type,L=Array.isArray(C)?[[C[1],C[2]]]:C.overloads,R=[];let U=null,K=-1;for(const[te,se]of L){if(Array.isArray(te)&&te.length!==d.length-1)continue;R.push(te),K++,U=new uC(p.registry,p.path,null,p.scope,void 0,p._scope,p.options,p.iconImageUseTheme);const ie=[];let de=!1;for(let fe=1;feie)).map(eC).join(" | "),se=[];for(let ie=1;iep;){if(b-p>600){const U=b-p+1,K=d-p+1,te=Math.log(U),se=.5*Math.exp(2*te/3),ie=.5*Math.sqrt(te*se*(U-se)/U)*(K-U/2<0?-1:1);tC(x,d,Math.max(p,Math.floor(d-K*se/U+ie)),Math.min(b,Math.floor(d+(U-K)*se/U+ie)),C)}const E=x[d];let L=p,R=b;for($p(x,p,d),C(x[b],E)>0&&$p(x,p,b);L0;)R--}C(x[p],E)===0?$p(x,p,R):(R++,$p(x,R,b)),R<=d&&(p=R+1),d<=R&&(b=R-1)}}function $p(x,d,p){const b=x[d];x[d]=x[p],x[p]=b}function l6(x,d){return xd?1:0}function ky(x){let d=0;for(let p,b,C=0,E=x.length,L=E-1;C=d[2]||x[1]<=d[1]||x[3]>=d[3])}function Bme(x,d,p){const b=x[0]-d[0],C=x[1]-d[1],E=x[0]-p[0],L=x[1]-p[1];return b*L-E*C==0&&b*E<=0&&C*L<=0}function ob(x,d,p=!1){let b=!1;for(let R=0,U=d.length;R(C=x)[1]!=(L=fe)[1]>C[1]&&C[0]<(L[0]-E[0])*(C[1]-E[1])/(L[1]-E[1])+E[0]&&(b=!b)}}var C,E,L;return b}function a2(x,d,p,b){const C=b[0]-p[0],E=b[1]-p[1],L=(x[0]-p[0])*E-C*(x[1]-p[1]),R=(d[0]-p[0])*E-C*(d[1]-p[1]);return L>0&&R<0||L<0&&R>0}function i2(x,d,p,b){return(C=[b[0]-p[0],b[1]-p[1]])[0]*(E=[d[0]-x[0],d[1]-x[1]])[1]-C[1]*E[0]!=0&&!(!a2(x,d,p,b)||!a2(p,b,x,d));var C,E}function ag(x){const d=new ns(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),p=new ns(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const b of x[0])d.x>b.x&&(d.x=b.x),d.y>b.y&&(d.y=b.y),p.xp[2]){const C=.5*b;let E=x[0]-p[0]>C?-b:p[0]-x[0]>C?b:0;E===0&&(E=x[0]-p[2]>C?-b:p[2]-x[0]>C?b:0),x[0]+=E}tp(d,x)}function KR(x,d,p,b){const C=Math.pow(2,b.z)*Sy,E=[b.x*Sy,b.y*Sy],L=[];if(!x)return L;for(const R of x)for(const U of R){const K=[U.x+E[0],U.y+E[1]];WR(K,d,p,C),L.push(K)}return L}function sC(x,d,p,b){const C=Math.pow(2,b.z)*Sy,E=[b.x*Sy,b.y*Sy],L=[];if(!x)return L;for(const U of x){const K=[];for(const te of U){const se=[te.x+E[0],te.y+E[1]];tp(d,se),K.push(se)}L.push(K)}if(d[2]-d[0]<=C/2){(R=d)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const U of L)for(const K of U)WR(K,d,p,C)}var R;return L}class My{constructor(d,p){this.type=Mi,this.geojson=d,this.geometries=p}static parse(d,p){if(d.length!==2)return p.error(`'within' expression requires exactly one argument, but found ${d.length-1} instead.`);if(ab(d[1])){const b=d[1];if(b.type==="FeatureCollection")for(let C=0;Cp)return rC(E,L,(p-(b-R))/R)}return d[d.length-1]}pointToSegmentDistance(d,p,b){let[C,E]=p,L=mm(b[0]-C)*this.kx,R=(b[1]-E)*this.ky;if(L!==0||R!==0){const U=(mm(d[0]-C)*this.kx*L+(d[1]-E)*this.ky*R)/(L*L+R*R);U>1?(C=b[0],E=b[1]):U>0&&(C+=L/this.kx*U,E+=R/this.ky*U)}return L=mm(d[0]-C)*this.kx,R=(d[1]-E)*this.ky,Math.sqrt(L*L+R*R)}pointOnLine(d,p){let b=1/0,C=d[0][0],E=d[0][1],L=0,R=0;for(let U=0;U1?(K=d[U+1][0],te=d[U+1][1]):de>0&&(K+=se/this.kx*de,te+=ie/this.ky*de)),se=mm(p[0]-K)*this.kx,ie=(p[1]-te)*this.ky;const fe=se*se+ie*ie;feE.index||C.index===E.index&&C.t>E.t){const K=C;C=E,E=K}const L=[C.point],R=C.index+1,U=E.index;!u6(b[R],L[0])&&R<=U&&L.push(b[R]);for(let K=R+1;K<=U;K++)L.push(b[K]);return u6(b[U],E.point)||L.push(E.point),L}lineSliceAlong(d,p,b){let C=0;const E=[];for(let L=0;Ld&&E.length===0&&E.push(rC(R,U,(d-(C-K))/K)),C>=p)return E.push(rC(R,U,(p-(C-K))/K)),E;C>d&&E.push(U)}return E}bufferPoint(d,p){const b=p/this.ky,C=p/this.kx;return[d[0]-C,d[1]-b,d[0]+C,d[1]+b]}bufferBBox(d,p){const b=p/this.ky,C=p/this.kx;return[d[0]-C,d[1]-b,d[2]+C,d[3]+b]}insideBBox(d,p){return mm(d[0]-p[0])>=0&&mm(d[0]-p[2])<=0&&d[1]>=p[1]&&d[1]<=p[3]}}function u6(x,d){return x[0]===d[0]&&x[1]===d[1]}function rC(x,d,p){const b=mm(d[0]-x[0]);return[x[0]+b*p,x[1]+(d[1]-x[1])*p]}function mm(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class nC{constructor(d=[],p=(b,C)=>bC?1:0){if(this.data=d,this.length=this.data.length,this.compare=p,this.length>0)for(let b=(this.length>>1)-1;b>=0;b--)this._down(b)}push(d){this.data.push(d),this._up(this.length++)}pop(){if(this.length===0)return;const d=this.data[0],p=this.data.pop();return--this.length>0&&(this.data[0]=p,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:p,compare:b}=this,C=p[d];for(;d>0;){const E=d-1>>1,L=p[E];if(b(C,L)>=0)break;p[d]=L,d=E}p[d]=C}_down(d){const{data:p,compare:b}=this,C=this.length>>1,E=p[d];for(;d=0)break;p[d]=p[L],d=L}p[d]=E}}var sr=8192;function h6(x,d){return d.dist-x.dist}const aC=100,iC=50;function m6(x){const d=[1/0,1/0,-1/0,-1/0];if(d.length!==x.length)return!1;for(let p=0;p=x[0]&&x[1]x[1])return[null,null];const p=l2(x);if(d){if(p===2)return[x,null];const b=Math.floor(p/2);return[[x[0],x[0]+b],[x[0]+b,x[1]]]}{if(p===1)return[x,null];const b=Math.floor(p/2)-1;return[[x[0],x[0]+b],[x[0]+b+1,x[1]]]}}function cv(x,d){const p=[1/0,1/0,-1/0,-1/0];if(!Wf(d,x.length))return p;for(let b=d[0];b<=d[1];++b)tp(p,x[b]);return p}function dv(x){const d=[1/0,1/0,-1/0,-1/0];for(let p=0;pd[2]&&(b=x[0]-d[2]),x[1]>d[3]&&(C=x[1]-d[3]),x[3]=b)return b;if(n2(C,E)){if(x6(x,d))return 0}else if(x6(d,x))return 0;let L=b;for(const R of x)for(let U=0,K=R.length,te=K-1;U=E)continue;const te=K.range1;if(l2(te)<=R){if(!Wf(te,x.length))return NaN;if(d){const se=Gme(x,te,p,b);if((E=Math.min(E,se))===0)return E}else for(let se=te[0];se<=te[1];++se){const ie=Hme(x[se],p,b);if((E=Math.min(E,ie))===0)return E}}else{const se=p6(te,d);if(se[0]!==null){const ie=Ty(cv(x,se[0]),U,b);ie=L)continue;const se=te.range1,ie=te.range2;if(l2(se)<=U&&l2(ie)<=K){if(!Wf(se,x.length)||!Wf(ie,p.length))return NaN;if(d&&b?L=Math.min(L,Ua(x,se,p,ie,C)):d||b?d&&!b?L=Math.min(L,f6(p,ie,x,se,C)):!d&&b&&(L=Math.min(L,f6(x,se,p,ie,C))):L=Math.min(L,Vme(x,se,p,ie,C)),L===0)return L}else{const de=p6(se,d),fe=p6(ie,b);xo(R,L,C,x,p,de[0],fe[0]),xo(R,L,C,x,p,de[0],fe[1]),xo(R,L,C,x,p,de[1],fe[0]),xo(R,L,C,x,p,de[1],fe[1])}}return L}function g6(x,d,p,b,C=1/0){let E=C;const L=cv(x,[0,x.length-1]);for(const R of p)if(!(E!==1/0&&Ty(L,cv(R,[0,R.length-1]),b)>=E)&&(E=Math.min(E,XR(x,d,R,!0,b,E)),E===0))return E;return E}function cC(x,d,p,b,C=1/0){let E=C;const L=cv(x,[0,x.length-1]);for(const R of p){if(E!==1/0&&Ty(L,dv(R),b)>=E)continue;const U=Kme(x,d,R,b,E);if(isNaN(U))return U;if((E=Math.min(E,U))===0)return E}return E}function y6(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class uv{constructor(d,p){this.type=Vr,this.geojson=d,this.geometries=p}static parse(d,p){if(d.length!==2)return p.error(`'distance' expression requires either one argument, but found ' ${d.length-1} instead.`);if(ab(d[1])){const b=d[1];if(b.type==="FeatureCollection"){for(let C=0;C{d&&!db(p)&&(d=!1)}),d}function c2(x){if(x instanceof $u&&x.name==="feature-state")return!1;let d=!0;return x.eachChild(p=>{d&&!c2(p)&&(d=!1)}),d}function ub(x,d){if(x instanceof $u&&d.indexOf(x.name)>=0)return!1;let p=!0;return x.eachChild(b=>{p&&!ub(b,d)&&(p=!1)}),p}function JR(x,d,p){return[x,d,p].filter(Boolean).join("")}function v6(x,d){switch(x){case"string":return ep(d);case"number":return+d;case"boolean":return!!d;case"color":return Wr.parse(d);case"formatted":return zu.fromString(ep(d));case"resolvedImage":return Bu.build(ep(d))}return d}function eF(x,d,p,b){return b!==void 0&&(x=b*Math.round(x/b)),d!==void 0&&xp&&(x=p),x}class hb{constructor(d,p,b,C=!1){this.type=d,this.key=p,this.scope=b,this.featureConstant=C}static parse(d,p){let b=p.expectedType;if(b==null&&(b=bi),d.length<2||d.length>3)return p.error("Invalid number of arguments for 'config' expression.");const C=p.parse(d[1],1);if(!(C instanceof ng))return p.error("Key name of 'config' expression must be a string literal.");let E,L=!0;const R=ep(C.value);if(d.length>=3){const U=p.parse(d[2],2);if(!(U instanceof ng))return p.error("Scope of 'config' expression must be a string literal.");E=ep(U.value)}if(p.options){const U=JR(R,E,p._scope),K=p.options.get(U);K&&(L=db(K.value||K.default))}return new hb(b,R,E,L)}evaluate(d){const p=JR(this.key,this.scope,d.scope),b=d.getConfig(p);if(!b)return null;const{type:C,value:E,values:L,minValue:R,maxValue:U,stepValue:K}=b,te=b.default.evaluate(d);let se=te;if(E){const ie=d.scope;d.scope=(ie||"").split("").slice(1).join(""),se=E.evaluate(d),d.scope=ie}return C&&(se=v6(C,se)),se===void 0||R===void 0&&U===void 0&&K===void 0||(typeof se=="number"?se=eF(se,R,U,K):Array.isArray(se)&&(se=se.map(ie=>typeof ie=="number"?eF(ie,R,U,K):ie))),E!==void 0&&se!==void 0&&L&&!L.includes(se)&&(se=te,C&&(se=v6(C,se))),(C&&C!==this.type||se!==void 0&&!Z3(Ec(se),this.type))&&(se=v6(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class dC{constructor(d,p){this.type=p.type,this.name=d,this.boundExpression=p}static parse(d,p){if(d.length!==2||typeof d[1]!="string")return p.error("'var' expression requires exactly one string literal argument.");const b=d[1];return p.scope.has(b)?new dC(b,p.scope.get(b)):p.error(`Unknown variable "${b}". Make sure "${b}" 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 uC{constructor(d,p=[],b,C=new nb,E=[],L,R,U){this.registry=d,this.path=p,this.key=p.map(K=>typeof K=="string"?`['${K}']`:`[${K}]`).join(""),this.scope=C,this.errors=E,this.expectedType=b,this._scope=L,this.options=R,this.iconImageUseTheme=U}parse(d,p,b,C,E={}){return p||b?this.concat(p,null,b,C)._parse(d,E):this._parse(d,E)}parseObjectValue(d,p,b,C,E,L={}){return this.concat(p,b,C,E)._parse(d,L)}_parse(d,p){function b(C,E,L){return L==="assert"?new Bp(E,[C]):L==="coerce"?new Gf(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 L=this.expectedType,R=E.type;if(L.kind!=="string"&&L.kind!=="number"&&L.kind!=="boolean"&&L.kind!=="object"&&L.kind!=="array"||R.kind!=="value")if(L.kind!=="color"&&L.kind!=="formatted"&&L.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(L,R))return null}else E=b(E,L,p.typeAnnotation||"coerce");else E=b(E,L,p.typeAnnotation||"assert")}if(!(E instanceof ng)&&E.type.kind!=="resolvedImage"&&b6(E)){const L=new J3(this._scope,this.options,this.iconImageUseTheme);try{E=new ng(E.type,E.evaluate(L))}catch(R){return this.error(R.message),null}}return E}return Gf.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,p,b,C){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof p=="string"?E.concat(p):E;const L=C?this.scope.concat(C):this.scope;return new uC(this.registry,E,b||null,L,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...p){const b=`${this.key}${p.map(C=>`[${C}]`).join("")}`;this.errors.push(new Jm(b,d))}checkSubtype(d,p){const b=Ny(d,p);return b&&this.error(b),b}}function b6(x){if(x instanceof dC)return b6(x.boundExpression);if(x instanceof $u&&x.name==="error"||x instanceof Kc||x instanceof My||x instanceof uv||x instanceof hb)return!1;const d=x instanceof Gf||x instanceof Bp;let p=!0;return x.eachChild(b=>{p=d?p&&b6(b):p&&b instanceof ng}),!!p&&db(x)&&ub(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 hC(x,d){const p=x.length-1;let b,C,E=0,L=p,R=0;for(;E<=L;)if(R=Math.floor((E+L)/2),b=x[R],C=x[R+1],b<=d){if(R===p||dd))throw new pc("Input is not a number.");L=R-1}return 0}class d2{constructor(d,p,b){this.type=d,this.input=p,this.labels=[],this.outputs=[];for(const[C,E]of b)this.labels.push(C),this.outputs.push(E)}static parse(d,p){if(d.length-1<4)return p.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if((d.length-1)%2!=0)return p.error("Expected an even number of arguments.");const b=p.parse(d[1],1,Vr);if(!b)return null;const C=[];let E=null;p.expectedType&&p.expectedType.kind!=="value"&&(E=p.expectedType);for(let L=1;L=R)return p.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',K);const se=p.parse(U,te,E);if(!se)return null;E=E||se.type,C.push([R,se])}return new d2(E,b,C)}evaluate(d){const p=this.labels,b=this.outputs;if(p.length===1)return b[0].evaluate(d);const C=this.input.evaluate(d);if(C<=p[0])return b[0].evaluate(d);const E=p.length;return C>=p[E-1]?b[E-1].evaluate(d):b[hC(p,C)].evaluate(d)}eachChild(d){d(this.input);for(const p of this.outputs)d(p)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){const d=["step",this.input.serialize()];for(let p=0;p0&&d.push(this.labels[p]),d.push(this.outputs[p].serialize());return d}}const tF=.95047,sF=1.08883,rF=4/29,mb=6/29,nF=3*mb*mb,Zme=mb*mb*mb,Yme=Math.PI/180,Qme=180/Math.PI;function _6(x){return x>Zme?Math.pow(x,1/3):x/nF+rF}function w6(x){return x>mb?x*x*x:nF*(x-rF)}function j6(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function N6(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function aF(x){const d=N6(x.r),p=N6(x.g),b=N6(x.b),C=_6((.4124564*d+.3575761*p+.1804375*b)/tF),E=_6((.2126729*d+.7151522*p+.072175*b)/1);return{l:116*E-16,a:500*(C-E),b:200*(E-_6((.0193339*d+.119192*p+.9503041*b)/sF)),alpha:x.a}}function mC(x){let d=(x.l+16)/116,p=isNaN(x.a)?d:d+x.a/500,b=isNaN(x.b)?d:d-x.b/200;return d=1*w6(d),p=tF*w6(p),b=sF*w6(b),new Wr(j6(3.2404542*p-1.5371385*d-.4985314*b),j6(-.969266*p+1.8760108*d+.041556*b),j6(.0556434*p-.2040259*d+1.0572252*b),x.alpha)}function pC(x,d,p){const b=d-x;return x+p*(b>180||b<-180?b-360*Math.round(b/360):b)}const pb={forward:aF,reverse:mC,interpolate:function(x,d,p){return{l:Xr(x.l,d.l,p),a:Xr(x.a,d.a,p),b:Xr(x.b,d.b,p),alpha:Xr(x.alpha,d.alpha,p)}}},u2={forward:function(x){const{l:d,a:p,b}=aF(x),C=Math.atan2(b,p)*Qme;return{h:C<0?C+360:C,c:Math.sqrt(p*p+b*b),l:d,alpha:x.a}},reverse:function(x){const d=x.h*Yme,p=x.c;return mC({l:x.l,a:Math.cos(d)*p,b:Math.sin(d)*p,alpha:x.alpha})},interpolate:function(x,d,p){return{h:pC(x.h,d.h,p),c:Xr(x.c,d.c,p),l:Xr(x.l,d.l,p),alpha:Xr(x.alpha,d.alpha,p)}}};var iF=Object.freeze({__proto__:null,hcl:u2,lab:pb});class pm{constructor(d,p,b,C,E){this.type=d,this.operator=p,this.interpolation=b,this.input=C,this.labels=[],this.outputs=[];for(const[L,R]of E)this.labels.push(L),this.outputs.push(R)}static interpolationFactor(d,p,b,C){let E=0;if(d.name==="exponential")E=fC(p,d.base,b,C);else if(d.name==="linear")E=fC(p,1,b,C);else if(d.name==="cubic-bezier"){const L=d.controlPoints;E=new ui(L[0],L[1],L[2],L[3]).solve(fC(p,1,b,C))}return E}static parse(d,p){let[b,C,E,...L]=d;if(!Array.isArray(C)||C.length===0)return p.error("Expected an interpolation type expression.",1);if(C[0]==="linear")C={name:"linear"};else if(C[0]==="exponential"){const K=C[1];if(typeof K!="number")return p.error("Exponential interpolation requires a numeric base.",1,1);C={name:"exponential",base:K}}else{if(C[0]!=="cubic-bezier")return p.error(`Unknown interpolation type ${String(C[0])}`,1,0);{const K=C.slice(1);if(K.length!==4||K.some(te=>typeof te!="number"||te<0||te>1))return p.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);C={name:"cubic-bezier",controlPoints:K}}}if(d.length-1<4)return p.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length-1>3&&(d.length-1)%2!=0)return p.error("Expected an even number of arguments.");if(E=p.parse(E,2,Vr),!E)return null;const R=[];let U=null;b==="interpolate-hcl"||b==="interpolate-lab"?U=mh:p.expectedType&&p.expectedType.kind!=="value"&&(U=p.expectedType);for(let K=0;K=te)return p.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ie);const fe=p.parse(se,de,U);if(!fe)return null;U=U||fe.type,R.push([te,fe])}return U.kind==="number"||U.kind==="color"||U.kind==="array"&&U.itemType.kind==="number"&&typeof U.N=="number"?new pm(U,b,C,E,R):p.error(`Type ${Nl(U)} is not interpolatable.`)}evaluate(d){const p=this.labels,b=this.outputs;if(p.length===1)return b[0].evaluate(d);const C=this.input.evaluate(d);if(C<=p[0])return b[0].evaluate(d);const E=p.length;if(C>=p[E-1])return b[E-1].evaluate(d);const L=hC(p,C),R=pm.interpolationFactor(this.interpolation,C,p[L],p[L+1]),U=b[L].evaluate(d),K=b[L+1].evaluate(d);return this.operator==="interpolate"?ov[this.type.kind.toLowerCase()](U,K,R):this.operator==="interpolate-hcl"?u2.reverse(u2.interpolate(u2.forward(U),u2.forward(K),R)):pb.reverse(pb.interpolate(pb.forward(U),pb.forward(K),R))}eachChild(d){d(this.input);for(const p of this.outputs)d(p)}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 p=[this.operator,d,this.input.serialize()];for(let b=0;bNy(C,R.type));return new h2(L?bi:b,E)}evaluate(d){let p,b=null,C=0;for(const E of this.args){if(C++,b=E.evaluate(d),b&&b instanceof Bu&&!b.available&&(p||(p=b),b=null,C===this.args.length))return p;if(b!==null)break}return b}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){const d=["coalesce"];return this.eachChild(p=>{d.push(p.serialize())}),d}}class ig{constructor(d,p){this.type=p.type,this.bindings=[].concat(d),this.result=p}evaluate(d){return this.result.evaluate(d)}eachChild(d){for(const p of this.bindings)d(p[1]);d(this.result)}static parse(d,p){if(d.length<4)return p.error(`Expected at least 3 arguments, but found ${d.length-1} instead.`);const b=[];for(let E=1;E=b.length)throw new pc("Array index out of bounds: index exceeds array size");if(p!==Math.floor(p))throw new pc("Array index must be an integer. Use at-interpolated for fractional indices");return b[p]}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class gC{constructor(d,p,b){this.type=d,this.index=p,this.input=b}static parse(d,p){if(d.length!==3)return p.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=p.parse(d[1],1,Vr),C=p.parse(d[2],2,Hd(p.expectedType||bi));return b&&C?new gC(C.type.itemType,b,C):null}evaluate(d){const p=this.index.evaluate(d),b=this.input.evaluate(d);if(p<0)throw new pc(`Array index out of bounds: ${p} < 0.`);if(p>b.length-1)throw new pc(`Array index out of bounds: ${p} > ${b.length-1}.`);if(p===Math.floor(p))return b[p];const C=Math.floor(p),E=Math.ceil(p),L=b[C],R=b[E];if(typeof L!="number"||typeof R!="number")throw new pc(`Cannot interpolate between non-number values at index ${p}.`);const U=p-C;return L*(1-U)+R*U}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class k6{constructor(d,p){this.type=Mi,this.needle=d,this.haystack=p}static parse(d,p){if(d.length!==3)return p.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=p.parse(d[1],1,bi),C=p.parse(d[2],2,bi);return b&&C?n6(b.type,[Mi,$a,Vr,zp,bi])?new k6(b,C):p.error(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(b.type)} instead`):null}evaluate(d){const p=this.needle.evaluate(d),b=this.haystack.evaluate(d);if(b==null)return!1;if(!r2(p,["boolean","string","number","null"]))throw new pc(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(Ec(p))} instead.`);if(!r2(b,["string","array"]))throw new pc(`Expected second argument to be of type array or string, but found ${Nl(Ec(b))} instead.`);return b.indexOf(p)>=0}eachChild(d){d(this.needle),d(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class fb{constructor(d,p,b){this.type=Vr,this.needle=d,this.haystack=p,this.fromIndex=b}static parse(d,p){if(d.length<=2||d.length>=5)return p.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const b=p.parse(d[1],1,bi),C=p.parse(d[2],2,bi);if(!b||!C)return null;if(!n6(b.type,[Mi,$a,Vr,zp,bi]))return p.error(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(b.type)} instead`);if(d.length===4){const E=p.parse(d[3],3,Vr);return E?new fb(b,C,E):null}return new fb(b,C)}evaluate(d){const p=this.needle.evaluate(d),b=this.haystack.evaluate(d);if(!r2(p,["boolean","string","number","null"]))throw new pc(`Expected first argument to be of type boolean, string, number or null, but found ${Nl(Ec(p))} instead.`);if(!r2(b,["string","array"]))throw new pc(`Expected second argument to be of type array or string, but found ${Nl(Ec(b))} instead.`);if(this.fromIndex){const C=this.fromIndex.evaluate(d);return b.indexOf(p,C)}return b.indexOf(p)}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 m2{constructor(d,p,b,C,E,L){this.inputType=d,this.type=p,this.input=b,this.cases=C,this.outputs=E,this.otherwise=L}static parse(d,p){if(d.length<5)return p.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length%2!=1)return p.error("Expected an even number of arguments.");let b,C;p.expectedType&&p.expectedType.kind!=="value"&&(C=p.expectedType);const E={},L=[];for(let K=2;KNumber.MAX_SAFE_INTEGER)return ie.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof fe=="number"&&Math.floor(fe)!==fe)return ie.error("Numeric branch labels must be integer values.");if(b){if(ie.checkSubtype(b,Ec(fe)))return null}else b=Ec(fe);if(E[String(fe)]!==void 0)return ie.error("Branch labels must be unique.");E[String(fe)]=L.length}const de=p.parse(se,K,C);if(!de)return null;C=C||de.type,L.push(de)}const R=p.parse(d[1],1,bi);if(!R)return null;const U=p.parse(d[d.length-1],d.length-1,C);return U?R.type.kind!=="value"&&p.concat(1).checkSubtype(b,R.type)?null:new m2(b,C,R,E,L,U):null}evaluate(d){const p=this.input.evaluate(d);return(Z3(Ec(p),this.inputType)&&this.outputs[this.cases[p]]||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()],p=Object.keys(this.cases).sort(),b=[],C={};for(const L of p){const R=C[this.cases[L]];R===void 0?(C[this.cases[L]]=b.length,b.push([this.cases[L],[L]])):b[R][1].push(L)}const E=L=>this.inputType.kind==="number"?Number(L):L;for(const[L,R]of b)d.push(R.length===1?E(R[0]):R.map(E)),d.push(this.outputs[L].serialize());return d.push(this.otherwise.serialize()),d}}class p2{constructor(d,p,b){this.type=d,this.branches=p,this.otherwise=b}static parse(d,p){if(d.length<4)return p.error(`Expected at least 3 arguments, but found only ${d.length-1}.`);if(d.length%2!=0)return p.error("Expected an odd number of arguments.");let b;p.expectedType&&p.expectedType.kind!=="value"&&(b=p.expectedType);const C=[];for(let L=1;Lp.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(p=>{d.push(p.serialize())}),d}}class yC{constructor(d,p,b,C){this.type=d,this.input=p,this.beginIndex=b,this.endIndex=C}static parse(d,p){if(d.length<=2||d.length>=5)return p.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const b=p.parse(d[1],1,bi),C=p.parse(d[2],2,Vr);if(!b||!C)return null;if(!n6(b.type,[Hd(bi),$a,bi]))return p.error(`Expected first argument to be of type array or string, but found ${Nl(b.type)} instead`);if(d.length===4){const E=p.parse(d[3],3,Vr);return E?new yC(b.type,b,C,E):null}return new yC(b.type,b,C)}evaluate(d){const p=this.input.evaluate(d),b=this.beginIndex.evaluate(d);if(!r2(p,["string","array"]))throw new pc(`Expected first argument to be of type array or string, but found ${Nl(Ec(p))} instead.`);if(this.endIndex){const C=this.endIndex.evaluate(d);return p.slice(b,C)}return p.slice(b)}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 S6{constructor(d,p){this.type=Hd($a),this.str=d,this.delimiter=p}static parse(d,p){if(d.length!==3)return p.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=p.parse(d[1],1,$a),C=p.parse(d[2],2,$a);return b&&C?new S6(b,C):void 0}evaluate(d){const p=this.str.evaluate(d),b=this.delimiter.evaluate(d);return p.split(b)}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 M6(x,d,p,b){return b.compare(d,p)===0}function xb(x,d,p){const b=x!=="=="&&x!=="!=";return class HGe{constructor(E,L,R){this.type=Mi,this.lhs=E,this.rhs=L,this.collator=R,this.hasUntypedArgument=E.type.kind==="value"||L.type.kind==="value"}static parse(E,L){if(E.length!==3&&E.length!==4)return L.error("Expected two or three arguments.");const R=E[0];let U=L.parse(E[1],1,bi);if(!U)return null;if(!C6(R,U.type))return L.concat(1).error(`"${R}" comparisons are not supported for type '${Nl(U.type)}'.`);let K=L.parse(E[2],2,bi);if(!K)return null;if(!C6(R,K.type))return L.concat(2).error(`"${R}" comparisons are not supported for type '${Nl(K.type)}'.`);if(U.type.kind!==K.type.kind&&U.type.kind!=="value"&&K.type.kind!=="value")return L.error(`Cannot compare types '${Nl(U.type)}' and '${Nl(K.type)}'.`);b&&(U.type.kind==="value"&&K.type.kind!=="value"?U=new Bp(K.type,[U]):U.type.kind!=="value"&&K.type.kind==="value"&&(K=new Bp(U.type,[K])));let te=null;if(E.length===4){if(U.type.kind!=="string"&&K.type.kind!=="string"&&U.type.kind!=="value"&&K.type.kind!=="value")return L.error("Cannot use collator to compare non-string types.");if(te=L.parse(E[3],3,K3),!te)return null}return new HGe(U,K,te)}evaluate(E){const L=this.lhs.evaluate(E),R=this.rhs.evaluate(E);if(b&&this.hasUntypedArgument){const U=Ec(L),K=Ec(R);if(U.kind!==K.kind||U.kind!=="string"&&U.kind!=="number")throw new pc(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${U.kind}, ${K.kind}) instead.`)}if(this.collator&&!b&&this.hasUntypedArgument){const U=Ec(L),K=Ec(R);if(U.kind!=="string"||K.kind!=="string")return d(E,L,R)}return this.collator?p(E,L,R,this.collator.evaluate(E)):d(E,L,R)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[x];return this.eachChild(L=>{E.push(L.serialize())}),E}}}const Xme=xb("==",function(x,d,p){return d===p},M6),Jme=xb("!=",function(x,d,p){return d!==p},function(x,d,p,b){return!M6(0,d,p,b)}),oF=xb("<",function(x,d,p){return d",function(x,d,p){return d>p},function(x,d,p,b){return b.compare(d,p)>0}),vC=xb("<=",function(x,d,p){return d<=p},function(x,d,p,b){return b.compare(d,p)<=0}),epe=xb(">=",function(x,d,p){return d>=p},function(x,d,p,b){return b.compare(d,p)>=0});class bC{constructor(d,p,b,C,E,L){this.type=$a,this.number=d,this.locale=p,this.currency=b,this.unit=C,this.minFractionDigits=E,this.maxFractionDigits=L}static parse(d,p){if(d.length!==3)return p.error("Expected two arguments.");const b=p.parse(d[1],1,Vr);if(!b)return null;const C=d[2];if(typeof C!="object"||Array.isArray(C))return p.error("NumberFormat options argument must be an object.");let E=null;if(C.locale&&(E=p.parseObjectValue(C.locale,2,"locale",$a),!E))return null;let L=null;if(C.currency&&(L=p.parseObjectValue(C.currency,2,"currency",$a),!L))return null;let R=null;if(C.unit&&(R=p.parseObjectValue(C.unit,2,"unit",$a),!R))return null;let U=null;if(C["min-fraction-digits"]&&(U=p.parseObjectValue(C["min-fraction-digits"],2,"min-fraction-digits",Vr),!U))return null;let K=null;return C["max-fraction-digits"]&&(K=p.parseObjectValue(C["max-fraction-digits"],2,"max-fraction-digits",Vr),!K)?null:new bC(b,E,L,R,U,K)}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 T6{constructor(d){this.type=Vr,this.input=d}static parse(d,p){if(d.length!==2)return p.error(`Expected 1 argument, but found ${d.length-1} instead.`);const b=p.parse(d[1],1);return b?b.type.kind!=="array"&&b.type.kind!=="string"&&b.type.kind!=="value"?p.error(`Expected argument of type string or array, but found ${Nl(b.type)} instead.`):new T6(b):null}evaluate(d){const p=this.input.evaluate(d);if(typeof p=="string"||Array.isArray(p))return p.length;throw new pc(`Expected value to be of type string or array, but found ${Nl(Ec(p))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(p=>{d.push(p.serialize())}),d}}function cF(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 gb={"==":Xme,"!=":Jme,">":lF,"<":oF,">=":epe,"<=":vC,array:Bp,at:xC,"at-interpolated":gC,boolean:Bp,case:p2,coalesce:h2,collator:Kc,format:Hf,image:Gn,in:k6,"index-of":fb,interpolate:pm,"interpolate-hcl":pm,"interpolate-lab":pm,length:T6,let:ig,literal:ng,match:m2,number:Bp,"number-format":bC,object:Bp,slice:yC,step:d2,string:Bp,"to-boolean":Gf,"to-color":Gf,"to-number":Gf,"to-string":Gf,var:dC,within:My,distance:uv,config:hb,split:S6};function A6(x,[d,p,b,C]){d=d.evaluate(x),p=p.evaluate(x),b=b.evaluate(x);const E=C?C.evaluate(x):1,L=lv(d,p,b,E);if(L)throw new pc(L);return new Wr(d/255,p/255,b/255,E)}function E6(x,[d,p,b,C]){d=d.evaluate(x),p=p.evaluate(x),b=b.evaluate(x);const E=C?C.evaluate(x):1,L=function(K,te,se,ie){return typeof K=="number"&&K>=0&&K<=360?typeof te=="number"&&te>=0&&te<=100&&typeof se=="number"&&se>=0&&se<=100?ie===void 0||typeof ie=="number"&&ie>=0&&ie<=1?null:`Invalid hsla value [${[K,te,se,ie].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ie=="number"?[K,te,se,ie]:[K,te,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ie=="number"?[K,te,se,ie]:[K,te,se]).join(", ")}]: 'h' must be between 0 and 360.`}(d,p,b,E);if(L)throw new pc(L);const R=`hsla(${d}, ${p}%, ${b}%, ${E})`,U=Wr.parse(R);if(!U)throw new pc(`Failed to parse HSLA color: ${R}`);return U}function dF(x,d){return x in d}function P6(x,d){const p=d[x];return p===void 0?null:p}function Ey(x){return{type:x}}function hv(x){if(x instanceof hb)return new Set([x.key]);let d=new Set;return x.eachChild(p=>{d=new Set([...d,...hv(p)])}),d}function _C(x){if(x instanceof $u&&x.name==="is-active-floor")return!0;let d=!1;return x.eachChild(p=>{!d&&_C(p)&&(d=!0)}),d}function uF(x){return{result:"success",value:x}}function Py(x){return{result:"error",value:x}}function I6(x,d){return!!x&&!!x.parameters&&x.parameters.indexOf(d)>-1}function f2(x){return x["property-type"]==="data-driven"}function hF(x){return I6(x.expression,"measure-light")}function mF(x){return I6(x.expression,"zoom")}function wC(x){return!!x.expression&&x.expression.interpolated}function jC(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function pF(x){return x}function fF(x,d){const p=d.type==="color",b=x.stops&&typeof x.stops[0][0]=="object",C=b||!(b||x.property!==void 0),E=x.type||(wC(d)?"exponential":"interval");if(p&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(K=>[K[0],Wr.parse(K[1])])),x.default=Wr.parse(x.default?x.default:d.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!iF[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let L,R,U;if(E==="exponential")L=xF;else if(E==="interval")L=spe;else if(E==="categorical"){L=tpe,R=Object.create(null);for(const K of x.stops)R[K[0]]=K[1];U=typeof x.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);L=gF}if(b){const K={},te=[];for(let de=0;dede[0]),evaluate:({zoom:de},fe)=>xF({stops:se,base:x.base},d,de).evaluate(de,fe)}}if(C){const K=E==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:K,interpolationFactor:pm.interpolationFactor.bind(void 0,K),zoomStops:x.stops.map(te=>te[0]),evaluate:({zoom:te})=>L(x,d,te,R,U)}}return{kind:"source",evaluate(K,te){const se=te&&te.properties?te.properties[x.property]:void 0;return se===void 0?Kf(x.default,d.default):L(x,d,se,R,U)}}}function Kf(x,d,p){return x!==void 0?x:d!==void 0?d:p!==void 0?p:void 0}function tpe(x,d,p,b,C){return Kf(typeof p===C?b[p]:void 0,x.default,d.default)}function spe(x,d,p){if(!ib(p))return Kf(x.default,d.default);const b=x.stops.length;if(b===1||p<=x.stops[0][0])return x.stops[0][1];if(p>=x.stops[b-1][0])return x.stops[b-1][1];const C=hC(x.stops.map(E=>E[0]),p);return x.stops[C][1]}function xF(x,d,p){const b=x.base!==void 0?x.base:1;if(!ib(p))return Kf(x.default,d.default);const C=x.stops.length;if(C===1||p<=x.stops[0][0])return x.stops[0][1];if(p>=x.stops[C-1][0])return x.stops[C-1][1];const E=hC(x.stops.map(te=>te[0]),p),L=function(te,se,ie,de){const fe=de-ie,Te=te-ie;return fe===0?0:se===1?Te/fe:(Math.pow(se,Te)-1)/(Math.pow(se,fe)-1)}(p,b,x.stops[E][0],x.stops[E+1][0]),R=x.stops[E][1],U=x.stops[E+1][1];let K=ov[d.type]||pF;if(x.colorSpace&&x.colorSpace!=="rgb"){const te=iF[x.colorSpace];K=(se,ie)=>te.reverse(te.interpolate(te.forward(se),te.forward(ie),L))}return typeof R.evaluate=="function"?{evaluate(...te){const se=R.evaluate.apply(void 0,te),ie=U.evaluate.apply(void 0,te);if(se!==void 0&&ie!==void 0)return K(se,ie,L)}}:K(R,U,L)}function gF(x,d,p){return d.type==="color"?p=Wr.parse(p):d.type==="formatted"?p=zu.fromString(p.toString()):d.type==="resolvedImage"?p=Bu.build(p.toString()):Br(p)===d.type||d.type==="enum"&&d.values[p]||(p=void 0),Kf(p,x.default,d.default)}$u.register(gb,{error:[{kind:"error"},[$a],(x,[d])=>{throw new pc(d.evaluate(x))}],typeof:[$a,[bi],(x,[d])=>Nl(Ec(d.evaluate(x)))],"to-rgba":[Hd(Vr,4),[mh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Hd(Vr,4),[mh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[mh,[Vr,Vr,Vr],A6],rgba:[mh,[Vr,Vr,Vr,Vr],A6],hsl:[mh,[Vr,Vr,Vr],E6],hsla:[mh,[Vr,Vr,Vr,Vr],E6],has:{type:Mi,overloads:[[[$a],(x,[d])=>dF(d.evaluate(x),x.properties())],[[$a,Vf],(x,[d,p])=>dF(d.evaluate(x),p.evaluate(x))]]},get:{type:bi,overloads:[[[$a],(x,[d])=>P6(d.evaluate(x),x.properties())],[[$a,Vf],(x,[d,p])=>P6(d.evaluate(x),p.evaluate(x))]]},"feature-state":[bi,[$a],(x,[d])=>P6(d.evaluate(x),x.featureState||{})],properties:[Vf,[],x=>x.properties()],"geometry-type":[$a,[],x=>x.geometryType()],worldview:[$a,[],x=>x.globals.worldview||""],"is-active-floor":[Mi,Ey($a),(x,d)=>{if(!(x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;const p=x.globals.activeFloors;return d.some(b=>{const C=b.evaluate(x);return p.has(C)})}],id:[bi,[],x=>x.id()],zoom:[Vr,[],x=>x.globals.zoom],pitch:[Vr,[],x=>x.globals.pitch||0],"distance-from-center":[Vr,[],x=>x.distanceFromCenter()],"measure-light":[Vr,[$a],(x,[d])=>x.measureLight(d.evaluate(x))],"heatmap-density":[Vr,[],x=>x.globals.heatmapDensity||0],"line-progress":[Vr,[],x=>x.globals.lineProgress||0],"raster-value":[Vr,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[Vr,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[Vr,[],x=>x.globals.skyRadialProgress||0],accumulated:[bi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[Vr,Ey(Vr),(x,d)=>{let p=0;for(const b of d)p+=b.evaluate(x);return p}],"*":[Vr,Ey(Vr),(x,d)=>{let p=1;for(const b of d)p*=b.evaluate(x);return p}],"-":{type:Vr,overloads:[[[Vr,Vr],(x,[d,p])=>d.evaluate(x)-p.evaluate(x)],[[Vr],(x,[d])=>-d.evaluate(x)]]},"/":[Vr,[Vr,Vr],(x,[d,p])=>d.evaluate(x)/p.evaluate(x)],"%":[Vr,[Vr,Vr],(x,[d,p])=>d.evaluate(x)%p.evaluate(x)],ln2:[Vr,[],()=>Math.LN2],pi:[Vr,[],()=>Math.PI],e:[Vr,[],()=>Math.E],"^":[Vr,[Vr,Vr],(x,[d,p])=>Math.pow(d.evaluate(x),p.evaluate(x))],sqrt:[Vr,[Vr],(x,[d])=>Math.sqrt(d.evaluate(x))],log10:[Vr,[Vr],(x,[d])=>Math.log(d.evaluate(x))/Math.LN10],ln:[Vr,[Vr],(x,[d])=>Math.log(d.evaluate(x))],log2:[Vr,[Vr],(x,[d])=>Math.log2(d.evaluate(x))],sin:[Vr,[Vr],(x,[d])=>Math.sin(d.evaluate(x))],cos:[Vr,[Vr],(x,[d])=>Math.cos(d.evaluate(x))],tan:[Vr,[Vr],(x,[d])=>Math.tan(d.evaluate(x))],asin:[Vr,[Vr],(x,[d])=>Math.asin(d.evaluate(x))],acos:[Vr,[Vr],(x,[d])=>Math.acos(d.evaluate(x))],atan:[Vr,[Vr],(x,[d])=>Math.atan(d.evaluate(x))],min:[Vr,Ey(Vr),(x,d)=>Math.min(...d.map(p=>p.evaluate(x)))],max:[Vr,Ey(Vr),(x,d)=>Math.max(...d.map(p=>p.evaluate(x)))],abs:[Vr,[Vr],(x,[d])=>Math.abs(d.evaluate(x))],round:[Vr,[Vr],(x,[d])=>{const p=d.evaluate(x);return p<0?-Math.round(-p):Math.round(p)}],floor:[Vr,[Vr],(x,[d])=>Math.floor(d.evaluate(x))],ceil:[Vr,[Vr],(x,[d])=>Math.ceil(d.evaluate(x))],"filter-==":[Mi,[$a,bi],(x,[d,p])=>x.properties()[d.value]===p.value],"filter-id-==":[Mi,[bi],(x,[d])=>x.id()===d.value],"filter-type-==":[Mi,[$a],(x,[d])=>x.geometryType()===d.value],"filter-<":[Mi,[$a,bi],(x,[d,p])=>{const b=x.properties()[d.value],C=p.value;return typeof b==typeof C&&b{const p=x.id(),b=d.value;return typeof p==typeof b&&p":[Mi,[$a,bi],(x,[d,p])=>{const b=x.properties()[d.value],C=p.value;return typeof b==typeof C&&b>C}],"filter-id->":[Mi,[bi],(x,[d])=>{const p=x.id(),b=d.value;return typeof p==typeof b&&p>b}],"filter-<=":[Mi,[$a,bi],(x,[d,p])=>{const b=x.properties()[d.value],C=p.value;return typeof b==typeof C&&b<=C}],"filter-id-<=":[Mi,[bi],(x,[d])=>{const p=x.id(),b=d.value;return typeof p==typeof b&&p<=b}],"filter->=":[Mi,[$a,bi],(x,[d,p])=>{const b=x.properties()[d.value],C=p.value;return typeof b==typeof C&&b>=C}],"filter-id->=":[Mi,[bi],(x,[d])=>{const p=x.id(),b=d.value;return typeof p==typeof b&&p>=b}],"filter-has":[Mi,[bi],(x,[d])=>d.value in x.properties()],"filter-has-id":[Mi,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[Mi,[Hd($a)],(x,[d])=>d.value.indexOf(x.geometryType())>=0],"filter-id-in":[Mi,[Hd(bi)],(x,[d])=>d.value.indexOf(x.id())>=0],"filter-in-small":[Mi,[$a,Hd(bi)],(x,[d,p])=>p.value.indexOf(x.properties()[d.value])>=0],"filter-in-large":[Mi,[$a,Hd(bi)],(x,[d,p])=>function(b,C,E,L){for(;E<=L;){const R=E+L>>1;if(C[R]===b)return!0;C[R]>b?L=R-1:E=R+1}return!1}(x.properties()[d.value],p.value,0,p.value.length-1)],all:{type:Mi,overloads:[[[Mi,Mi],(x,[d,p])=>d.evaluate(x)&&p.evaluate(x)],[Ey(Mi),(x,d)=>{for(const p of d)if(!p.evaluate(x))return!1;return!0}]]},any:{type:Mi,overloads:[[[Mi,Mi],(x,[d,p])=>d.evaluate(x)||p.evaluate(x)],[Ey(Mi),(x,d)=>{for(const p of d)if(p.evaluate(x))return!0;return!1}]]},"!":[Mi,[Mi],(x,[d])=>!d.evaluate(x)],"is-supported-script":[Mi,[$a],(x,[d])=>{const p=x.globals&&x.globals.isSupportedScript;return!p||p(d.evaluate(x))}],upcase:[$a,[$a],(x,[d])=>d.evaluate(x).toUpperCase()],downcase:[$a,[$a],(x,[d])=>d.evaluate(x).toLowerCase()],concat:[$a,Ey(bi),(x,d)=>d.map(p=>ep(p.evaluate(x))).join("")],"resolved-locale":[$a,[K3],(x,[d])=>d.evaluate(x).resolvedLocale()],random:[Vr,[Vr,Vr,bi],(x,d)=>{const[p,b,C]=d.map(L=>L.evaluate(x));if(p>b||p===b)return p;let E;if(typeof C=="string")E=function(L){let R=0;if(L.length===0)return R;for(let U=0;UJSON.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 x2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in gb}function Iy(x,d,p,b,C){const E=new uC(gb,[],d?function(R){const U={color:mh,string:$a,number:Vr,enum:$a,boolean:Mi,formatted:t2,resolvedImage:s2};return R.type==="array"?Hd(U[R.value]||bi,R.length):U[R.type]}(d):void 0,void 0,void 0,p,b,C),L=E.parse(x,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return L?uF(new NC(L,d,p,b,C)):Py(E.errors)}class yb{constructor(d,p,b,C){this.kind=d,this._styleExpression=p,this.isLightConstant=b,this.isLineProgressConstant=C,this.isStateDependent=d!=="constant"&&!c2(p.expression),this.configDependencies=hv(p.expression),this.isIndoorDependent=_C(p.expression)}evaluateWithoutErrorHandling(d,p,b,C,E,L){return this._styleExpression.evaluateWithoutErrorHandling(d,p,b,C,E,L)}evaluate(d,p,b,C,E,L,R){return this._styleExpression.evaluate(d,p,b,C,E,L,void 0,void 0,R)}}class mv{constructor(d,p,b,C,E,L){this.kind=d,this.zoomStops=b,this._styleExpression=p,this.isStateDependent=d!=="camera"&&!c2(p.expression),this.isIndoorDependent=_C(p.expression),this.isLightConstant=E,this.isLineProgressConstant=L,this.configDependencies=hv(p.expression),this.interpolationType=C}evaluateWithoutErrorHandling(d,p,b,C,E,L){return this._styleExpression.evaluateWithoutErrorHandling(d,p,b,C,E,L)}evaluate(d,p,b,C,E,L){return this._styleExpression.evaluate(d,p,b,C,E,L)}interpolationFactor(d,p,b){return this.interpolationType?pm.interpolationFactor(this.interpolationType,d,p,b):0}}function L6(x,d,p,b,C){if((x=Iy(x,d,p,b,C)).result==="error")return x;const E=x.value.expression,L=db(E);if(!L&&!f2(d))return Py([new Jm("","data expressions not supported")]);const R=ub(E,["zoom","pitch","distance-from-center"]);if(!R&&!mF(d))return Py([new Jm("","zoom expressions not supported")]);const U=ub(E,["measure-light"]);if(!U&&!hF(d))return Py([new Jm("","measure-light expression not supported")]);const K=ub(E,["line-progress"]);if(!K&&!function(ie){return I6(ie.expression,"line-progress")}(d))return Py([new Jm("","line-progress expression not supported")]);const te=d.expression&&d.expression.relaxZoomRestriction,se=qp(E);return se||R||te?se instanceof Jm?Py([se]):se instanceof pm&&!wC(d)?Py([new Jm("",'"interpolate" expressions cannot be used with this property')]):uF(se?new mv(L&&K?"camera":"composite",x.value,se.labels,se instanceof pm?se.interpolation:void 0,U,K):new yb(L&&K?"constant":"source",x.value,U,K)):Py([new Jm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class kC{constructor(d,p){this._parameters=d,this._specification=p,Object.assign(this,fF(this._parameters,this._specification))}static deserialize(d){return new kC(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function qp(x){let d=null;if(x instanceof ig)d=qp(x.result);else if(x instanceof h2){for(const p of x.args)if(d=qp(p),d)break}else(x instanceof d2||x instanceof pm)&&x.input instanceof $u&&x.input.name==="zoom"&&(d=x);return d instanceof Jm||x.eachChild(p=>{const b=qp(p);b instanceof Jm?d=b:d&&b&&d!==b&&(d=new Jm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var D6,yF,vF=function(){if(yF)return D6;yF=1,D6=d;var x=3;function d(p,b,C){var E=this.cells=[];if(p instanceof ArrayBuffer){this.arrayBuffer=p;var L=new Int32Array(this.arrayBuffer);p=L[0],this.d=(b=L[1])+2*(C=L[2]);for(var R=0;R=ie[Te+0]&&E>=ie[Te+1])?(U[fe]=!0,R.push(se[fe])):U[fe]=!1}}},d.prototype._forEachCell=function(p,b,C,E,L,R,U,K){for(var te=this._convertToCellCoord(p),se=this._convertToCellCoord(b),ie=this._convertToCellCoord(C),de=this._convertToCellCoord(E),fe=te;fe<=ie;fe++)for(var Te=se;Te<=de;Te++){var ze=this.d*Te+fe;if((!K||K(this._convertFromCellCoord(fe),this._convertFromCellCoord(Te),this._convertFromCellCoord(fe+1),this._convertFromCellCoord(Te+1)))&&L.call(this,p,b,C,E,ze,R,U,K))return}},d.prototype._convertFromCellCoord=function(p){return(p-this.padding)/this.scale},d.prototype._convertToCellCoord=function(p){return Math.max(0,Math.min(this.d-1,Math.floor(p*this.scale)+this.padding))},d.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var p=this.cells,b=x+this.cells.length+1+1,C=0,E=0;E=0||(C[E]=og(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 b!=="Object"&&(C.$name=b),C}throw new Error("can't serialize object of type "+typeof x)}function Ly(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||g2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(Ly);if(typeof x=="object"){const d=x.$name||"Object";if(d==="Map"){const C=x.entries||[],E=new Map;for(let L=0;Lx>=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 y2(x){for(const d of x)if(SC(d.charCodeAt(0)))return!0;return!1}function O6(x){for(const d of x)if(!bF(d.charCodeAt(0)))return!1;return!0}function bF(x){return!(an.Arabic(x)||an["Arabic Supplement"](x)||an["Arabic Extended-A"](x)||an["Arabic Presentation Forms-A"](x)||an["Arabic Presentation Forms-B"](x))}function SC(x){return!(x!==746&&x!==747&&(x<4352||!(an["Bopomofo Extended"](x)||an.Bopomofo(x)||an["CJK Compatibility Forms"](x)&&!(x>=65097&&x<=65103)||an["CJK Compatibility Ideographs"](x)||an["CJK Compatibility"](x)||an["CJK Radicals Supplement"](x)||an["CJK Strokes"](x)||!(!an["CJK Symbols and Punctuation"](x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||an["CJK Unified Ideographs Extension A"](x)||an["CJK Unified Ideographs"](x)||an["Enclosed CJK Letters and Months"](x)||an["Hangul Compatibility Jamo"](x)||an["Hangul Jamo Extended-A"](x)||an["Hangul Jamo Extended-B"](x)||an["Hangul Jamo"](x)||an["Hangul Syllables"](x)||an.Hiragana(x)||an["Ideographic Description Characters"](x)||an.Kanbun(x)||an["Kangxi Radicals"](x)||an["Katakana Phonetic Extensions"](x)||an.Katakana(x)&&x!==12540||!(!an["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)||!(!an["Small Form Variants"](x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||an["Unified Canadian Aboriginal Syllabics"](x)||an["Unified Canadian Aboriginal Syllabics Extended"](x)||an["Vertical Forms"](x)||an["Yijing Hexagram Symbols"](x)||an["Yi Syllables"](x)||an["Yi Radicals"](x))))}function CC(x){return!(SC(x)||function(d){return!!(an["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||an["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)||an["Letterlike Symbols"](d)||an["Number Forms"](d)||an["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)||an["Control Pictures"](d)&&d!==9251||an["Optical Character Recognition"](d)||an["Enclosed Alphanumerics"](d)||an["Geometric Shapes"](d)||an["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||an["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||an["CJK Symbols and Punctuation"](d)||an.Katakana(d)||an["Private Use Area"](d)||an["CJK Compatibility Forms"](d)||an["Small Form Variants"](d)||an["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 MC(x){return an.Arabic(x)||an["Arabic Supplement"](x)||an["Arabic Extended-A"](x)||an["Arabic Presentation Forms-A"](x)||an["Arabic Presentation Forms-B"](x)}function R6(x){return x>=1424&&x<=2303||an["Arabic Presentation Forms-A"](x)||an["Arabic Presentation Forms-B"](x)}function lg(x,d){return!(!d&&R6(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||an.Khmer(x))}function rpe(x){for(const d of x)if(R6(d.charCodeAt(0)))return!0;return!1}const zh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let F6=null,qu=zh.unavailable,cg=null;const v2=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(qu=zh.error),F6&&F6(x)};function TC(){AC.fire(new Xm("pluginStateChange",{pluginStatus:qu,pluginURL:cg}))}const AC=new As,b2=function(){return qu},_F=function(){if(qu!==zh.deferred||!cg)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");qu=zh.loading,TC(),cg&&Fh({url:cg},x=>{x?v2(x):(qu=zh.loaded,TC())})},dg={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>qu===zh.loaded||dg.applyArabicShaping!=null,isLoading:()=>qu===zh.loading,setState(x){qu=x.pluginStatus,cg=x.pluginURL},isParsing:()=>qu===zh.parsing,isParsed:()=>qu===zh.parsed,getPluginURL:()=>cg};class Yi{constructor(d,p){this.zoom=d,p?(this.now=p.now,this.fadeDuration=p.fadeDuration,this.transition=p.transition,this.pitch=p.pitch,this.brightness=p.brightness,this.worldview=p.worldview,this.activeFloors=p.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(d){return function(p,b){for(const C of p)if(!lg(C.charCodeAt(0),b))return!1;return!0}(d,dg.isLoaded())}}class EC{constructor(d,p,b,C,E){this.property=d,this.value=p,this.expression=function(L,R,U,K,te){if(jC(L))return new kC(L,R);if(x2(L)||Array.isArray(L)&&L.length>0){const se=L6(L,R,U,K,te);if(se.result==="error")throw new Error(se.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));return se.value}{let se=L;return typeof L=="string"&&R.type==="color"&&(se=Wr.parse(L)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(p===void 0?d.specification.default:p,d.specification,b,C,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,p,b,C){return this.property.possiblyEvaluate(this,d,p,b,C)}}class z6{constructor(d,p,b,C){this.property=d,this.value=new EC(d,void 0,p,b,C)}transitioned(d,p){return new jF(this.property,this.value,p,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new jF(this.property,this.value,null,{},0)}}class wF{constructor(d,p,b,C){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=p,this._options=b,this._iconImageUseTheme=C,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(d){return Ns(this._values[d].value.value)}setValue(d,p){this._values.hasOwnProperty(d)||(this._values[d]=new z6(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new EC(this._values[d].property,p===null?void 0:Ns(p),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,p){p&&(this._options=p);const b=this._properties.properties;if(d)for(const C in d){const E=d[C];if(C.endsWith("-transition")){const L=C.slice(0,-11);b[L]&&this.setTransition(L,E)}else b.hasOwnProperty(C)&&this.setValue(C,E)}}getTransition(d){return Ns(this._values[d].transition)}setTransition(d,p){this._values.hasOwnProperty(d)||(this._values[d]=new z6(this._values[d].property)),this._values[d].transition=Ns(p)||void 0}serialize(){const d={};for(const p of Object.keys(this._values)){const b=this.getValue(p);b!==void 0&&(d[p]=b);const C=this.getTransition(p);C!==void 0&&(d[`${p}-transition`]=C)}return d}transitioned(d,p){const b=new NF(this._properties);for(const C of Object.keys(this._values))b._values[C]=this._values[C].transitioned(d,p._values[C]);return b}untransitioned(){const d=new NF(this._properties);for(const p of Object.keys(this._values))d._values[p]=this._values[p].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class jF{constructor(d,p,b,C,E){const L=C.delay||0,R=C.duration||0;E=E||0,this.property=d,this.value=p,this.begin=E+L,this.end=this.begin+R,d.specification.transition&&(C.delay||C.duration)&&(this.prior=b)}possiblyEvaluate(d,p,b){const C=d.now||0,E=this.value.possiblyEvaluate(d,p,b),L=this.prior;if(L){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 SF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function PC(x){if(Array.isArray(x))return x.map(PC);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const d={};for(const p in x)d[p]=PC(x[p]);return d}return SF(x)}function Zf(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(!Zf(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function IC(x,d="",p=null,b="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Zf(x)||(x=LC(x));const C=x;let E=!0;try{E=function(te){if(!bb(te))return te;let se=PC(te);return CF(se),se=yv(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 L=null,R=null;if(b!=="background"&&b!=="sky"&&b!=="slot"){R=Kt[`filter_${b}`];const te=Iy(E,R,d,p);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));L=(se,ie,de)=>te.value.evaluate(se,ie,{},de)}let U=null,K=null;if(E!==C){const te=Iy(C,R,d,p);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));U=(se,ie,de,fe,Te)=>te.value.evaluate(se,ie,{},de,void 0,void 0,fe,Te),K=!db(te.value.expression)}return{filter:L,dynamicFilter:U||void 0,needGeometry:MF(E),needFeature:!!K}}function yv(x){if(!Array.isArray(x))return x;const d=function(p){if(npe.has(p[0])){for(let b=1;byv(p))}function CF(x){let d=!1;const p=[];if(x[0]==="case"){for(let b=1;b",">=","<","<=","to-boolean"]);function ape(x,d){return xd?1:0}function MF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?DC(x[1],x[2],d):d==="any"?(p=x.slice(1),["any"].concat(p.map(LC))):d==="all"?["all"].concat(x.slice(1).map(LC)):d==="none"?["all"].concat(x.slice(1).map(LC).map(_2)):d==="in"?OC(x[1],x.slice(2)):d==="!in"?_2(OC(x[1],x.slice(2))):d==="has"?RC(x[1]):d!=="!has"||_2(RC(x[1]));var p}function DC(x,d,p){switch(x){case"$type":return[`filter-type-${p}`,d];case"$id":return[`filter-id-${p}`,d];default:return[`filter-${p}`,x,d]}}function OC(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(p=>typeof p!=typeof d[0])?["filter-in-large",x,["literal",d.sort(ape)]]:["filter-in-small",x,["literal",d]]}}function RC(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function _2(x){return["!",x]}const vv="";function Up(x,d){return d?`${x}${vv}${d}`:x}let TF;const AF=()=>TF||(TF=new Oo({"icon-size":new lr(Kt.layout_symbol["icon-size"]),"icon-image":new lr(Kt.layout_symbol["icon-image"]),"icon-rotate":new lr(Kt.layout_symbol["icon-rotate"]),"icon-offset":new lr(Kt.layout_symbol["icon-offset"]),"text-size":new lr(Kt.layout_symbol["text-size"]),"text-rotate":new lr(Kt.layout_symbol["text-rotate"]),"text-offset":new lr(Kt.layout_symbol["text-offset"])}));class EF{constructor(d,p,b,C,E,L){const R=Iy(d,Kt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=p,b){this.properties=new xv(AF()),this.unevaluatedLayout=new kF(AF(),C,E,L);for(const U in b)this.unevaluatedLayout.setValue(U,b[U])}}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,p,b){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(d,void 0,p,b))}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"),p=this.hasProperty("icon-size"),b=this.hasProperty("icon-offset"),C=this.hasProperty("icon-rotate");return d||p||b||C}hasTextProperties(){const d=this.hasProperty("text-size"),p=this.hasProperty("text-offset"),b=this.hasProperty("text-rotate");return d||p||b}hasProperty(d){return this.getUnevaluatedProperty(d).value!==void 0}}const PF="-transition",Yf=new Set(["fill","line","background","hillshade","raster"]);class Uu extends As{constructor(d,p,b,C,E,L){if(super(),this.id=d.id,this.fqid=Up(this.id,b),this.type=d.type,this.scope=b,this.lut=C,this.options=E,this.iconImageUseTheme=L,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=Iy(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),p.layout&&(this._unevaluatedLayout=new kF(p.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()),p.paint){this._transitionablePaint=new wF(p.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 xv(p.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Yf.has(this.type)}getLayoutProperty(d){return d==="visibility"?this.visibility:this._unevaluatedLayout.getValue(d)}setLayoutProperty(d,p){if(this.type==="custom"&&d==="visibility")return void(this.visibility=p);const b=this._unevaluatedLayout;b._properties.properties[d]&&(b.setValue(d,p),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...b.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||b.isIndoorDependent(),d==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(d){this.appearances=[],d.forEach(p=>{this.appearances.push(new EF(p.condition,p.name,p.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(PF)?this._transitionablePaint.getTransition(d.slice(0,-11)):this._transitionablePaint.getValue(d)}isPaintProperty(d){return!!this._transitionablePaint._properties.properties[d]}setPaintProperty(d,p){const b=this._transitionablePaint,C=b._properties.properties;if(d.endsWith(PF)){const se=d.slice(0,-11);return C[se]&&b.setTransition(se,p||void 0),!1}if(!C[d])return!1;const E=b._values[d],L=E.value.isDataDriven(),R=E.value;b.setValue(d,p),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...b.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||b.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const U=b._values[d].value,K=U.isDataDriven(),te=d.endsWith("pattern")||d==="line-dasharray";return K||L||te||this._handleOverridablePaintPropertyUpdate(d,R,U)}_handleSpecialPaintPropertyUpdate(d){}getProgramIds(){return null}getDefaultProgramParams(d,p,b){return null}_handleOverridablePaintPropertyUpdate(d,p,b){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,p){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(d,void 0,p,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(d,void 0,p)}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(p=>p.serialize())),Os(d,(p,b)=>!(p===void 0||b==="layout"&&!Object.keys(p).length||b==="paint"&&!Object.keys(p).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 p=this.paint.get(d);if(p instanceof fv&&f2(p.property.specification)&&(p.value.kind==="source"||p.value.kind==="composite")&&p.value.isStateDependent)return!0}for(const d of this.appearances)if(!c2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=IC(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,p,b){return{}}queryRadius(d){}queryIntersectsFeature(d,p,b,C,E,L,R,U,K){}}const IF={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class w2{constructor(d,p){this._structArray=d,this._pos1=p*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const ipe=new ArrayBuffer(0);class io{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(d,p){return d._trim(),p&&d.arrayBuffer&&p.add(d.arrayBuffer),{length:d.length,arrayBuffer:d.arrayBuffer}}static deserialize(d){const p=Object.create(this.prototype);return p.arrayBuffer=d.arrayBuffer,p.length=d.length,d.arrayBuffer?p.capacity=d.arrayBuffer.byteLength/p.bytesPerElement:(p.capacity=0,p.arrayBuffer=ipe),p._refreshViews(),p}_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 p=this.uint8;this._refreshViews(),p&&this.uint8.set(p)}}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 _a(x,d=1){let p=0,b=0;return{members:x.map(C=>{const E=IF[C.type].BYTES_PER_ELEMENT,L=p=LF(p,Math.max(d,E)),R=C.components||1;return b=Math.max(b,E),p+=E*R,{name:C.name,type:C.type,components:R,offset:L}}),size:LF(p,Math.max(b,d)),alignment:d}}function LF(x,d){return Math.ceil(x/d)*d}class Dy extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p){const b=this.length;return this.resize(b+1),this.emplace(b,d,p)}emplace(d,p,b){const C=2*d;return this.int16[C+0]=p,this.int16[C+1]=b,d}}Dy.prototype.bytesPerElement=4,Cr(Dy,"StructArrayLayout2i4");class _b extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,p,b)}emplace(d,p,b,C){const E=3*d;return this.int16[E+0]=p,this.int16[E+1]=b,this.int16[E+2]=C,d}}_b.prototype.bytesPerElement=6,Cr(_b,"StructArrayLayout3i6");class wb extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,p,b,C)}emplace(d,p,b,C,E){const L=4*d;return this.int16[L+0]=p,this.int16[L+1]=b,this.int16[L+2]=C,this.int16[L+3]=E,d}}wb.prototype.bytesPerElement=8,Cr(wb,"StructArrayLayout4i8");class ug extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d){const p=this.length;return this.resize(p+1),this.emplace(p,d)}emplace(d,p){return this.float32[1*d+0]=p,d}}ug.prototype.bytesPerElement=4,Cr(ug,"StructArrayLayout1f4");class B6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,p,b)}emplace(d,p,b,C){const E=4*d,L=2*d;return this.int16[E+0]=p,this.int16[E+1]=b,this.float32[L+1]=C,d}}B6.prototype.bytesPerElement=8,Cr(B6,"StructArrayLayout2i1f8");class $6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,p,b)}emplace(d,p,b,C){const E=4*d;return this.int16[E+0]=p,this.int16[E+1]=b,this.int16[E+2]=C,d}}$6.prototype.bytesPerElement=8,Cr($6,"StructArrayLayout3i8");class q6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E){const L=this.length;return this.resize(L+1),this.emplace(L,d,p,b,C,E)}emplace(d,p,b,C,E,L){const R=5*d;return this.int16[R+0]=p,this.int16[R+1]=b,this.int16[R+2]=C,this.int16[R+3]=E,this.int16[R+4]=L,d}}q6.prototype.bytesPerElement=10,Cr(q6,"StructArrayLayout5i10");class FC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R){const U=this.length;return this.resize(U+1),this.emplace(U,d,p,b,C,E,L,R)}emplace(d,p,b,C,E,L,R,U){const K=6*d,te=12*d,se=3*d;return this.int16[K+0]=p,this.int16[K+1]=b,this.uint8[te+4]=C,this.uint8[te+5]=E,this.uint8[te+6]=L,this.uint8[te+7]=R,this.float32[se+2]=U,d}}FC.prototype.bytesPerElement=12,Cr(FC,"StructArrayLayout2i4ub1f12");class fm extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,p,b)}emplace(d,p,b,C){const E=3*d;return this.float32[E+0]=p,this.float32[E+1]=b,this.float32[E+2]=C,d}}fm.prototype.bytesPerElement=12,Cr(fm,"StructArrayLayout3f12");class ph extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E){const L=this.length;return this.resize(L+1),this.emplace(L,d,p,b,C,E)}emplace(d,p,b,C,E,L){const R=6*d,U=3*d;return this.uint16[R+0]=p,this.uint16[R+1]=b,this.uint16[R+2]=C,this.uint16[R+3]=E,this.float32[U+2]=L,d}}ph.prototype.bytesPerElement=12,Cr(ph,"StructArrayLayout4ui1f12");class bv extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,p,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,p,b,C)}emplace(d,p,b,C,E){const L=4*d;return this.uint16[L+0]=p,this.uint16[L+1]=b,this.uint16[L+2]=C,this.uint16[L+3]=E,d}}bv.prototype.bytesPerElement=8,Cr(bv,"StructArrayLayout4ui8");class zC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L){const R=this.length;return this.resize(R+1),this.emplace(R,d,p,b,C,E,L)}emplace(d,p,b,C,E,L,R){const U=6*d;return this.int16[U+0]=p,this.int16[U+1]=b,this.int16[U+2]=C,this.int16[U+3]=E,this.int16[U+4]=L,this.int16[U+5]=R,d}}zC.prototype.bytesPerElement=12,Cr(zC,"StructArrayLayout6i12");class U6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R,U,K,te,se,ie){const de=this.length;return this.resize(de+1),this.emplace(de,d,p,b,C,E,L,R,U,K,te,se,ie)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie,de){const fe=12*d;return this.int16[fe+0]=p,this.int16[fe+1]=b,this.int16[fe+2]=C,this.int16[fe+3]=E,this.uint16[fe+4]=L,this.uint16[fe+5]=R,this.uint16[fe+6]=U,this.uint16[fe+7]=K,this.int16[fe+8]=te,this.int16[fe+9]=se,this.int16[fe+10]=ie,this.int16[fe+11]=de,d}}U6.prototype.bytesPerElement=24,Cr(U6,"StructArrayLayout4i4ui4i24");class V6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L){const R=this.length;return this.resize(R+1),this.emplace(R,d,p,b,C,E,L)}emplace(d,p,b,C,E,L,R){const U=10*d,K=5*d;return this.int16[U+0]=p,this.int16[U+1]=b,this.int16[U+2]=C,this.float32[K+2]=E,this.float32[K+3]=L,this.float32[K+4]=R,d}}V6.prototype.bytesPerElement=20,Cr(V6,"StructArrayLayout3i3f20");class Oy extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,p,b,C)}emplace(d,p,b,C,E){const L=4*d;return this.float32[L+0]=p,this.float32[L+1]=b,this.float32[L+2]=C,this.float32[L+3]=E,d}}Oy.prototype.bytesPerElement=16,Cr(Oy,"StructArrayLayout4f16");class BC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d){const p=this.length;return this.resize(p+1),this.emplace(p,d)}emplace(d,p){return this.uint32[1*d+0]=p,d}}BC.prototype.bytesPerElement=4,Cr(BC,"StructArrayLayout1ul4");class xm extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,p){const b=this.length;return this.resize(b+1),this.emplace(b,d,p)}emplace(d,p,b){const C=2*d;return this.uint16[C+0]=p,this.uint16[C+1]=b,d}}xm.prototype.bytesPerElement=4,Cr(xm,"StructArrayLayout2ui4");class $C extends io{_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,p,b,C,E,L,R,U,K,te,se,ie,de){const fe=this.length;return this.resize(fe+1),this.emplace(fe,d,p,b,C,E,L,R,U,K,te,se,ie,de)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe){const Te=20*d,ze=10*d;return this.int16[Te+0]=p,this.int16[Te+1]=b,this.int16[Te+2]=C,this.int16[Te+3]=E,this.int16[Te+4]=L,this.float32[ze+3]=R,this.float32[ze+4]=U,this.float32[ze+5]=K,this.float32[ze+6]=te,this.int16[Te+14]=se,this.uint32[ze+8]=ie,this.uint16[Te+18]=de,this.uint16[Te+19]=fe,d}}$C.prototype.bytesPerElement=40,Cr($C,"StructArrayLayout5i4f1i1ul2ui40");class qC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R){const U=this.length;return this.resize(U+1),this.emplace(U,d,p,b,C,E,L,R)}emplace(d,p,b,C,E,L,R,U){const K=8*d;return this.int16[K+0]=p,this.int16[K+1]=b,this.int16[K+2]=C,this.int16[K+4]=E,this.int16[K+5]=L,this.int16[K+6]=R,this.int16[K+7]=U,d}}qC.prototype.bytesPerElement=16,Cr(qC,"StructArrayLayout3i2i2i16");class UC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E){const L=this.length;return this.resize(L+1),this.emplace(L,d,p,b,C,E)}emplace(d,p,b,C,E,L){const R=4*d,U=8*d;return this.float32[R+0]=p,this.float32[R+1]=b,this.float32[R+2]=C,this.int16[U+6]=E,this.int16[U+7]=L,d}}UC.prototype.bytesPerElement=16,Cr(UC,"StructArrayLayout2f1f2i16");class H6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L){const R=this.length;return this.resize(R+1),this.emplace(R,d,p,b,C,E,L)}emplace(d,p,b,C,E,L,R){const U=20*d,K=5*d;return this.uint8[U+0]=p,this.uint8[U+1]=b,this.float32[K+1]=C,this.float32[K+2]=E,this.float32[K+3]=L,this.float32[K+4]=R,d}}H6.prototype.bytesPerElement=20,Cr(H6,"StructArrayLayout2ub4f20");class Gl extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,p,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,p,b)}emplace(d,p,b,C){const E=3*d;return this.uint16[E+0]=p,this.uint16[E+1]=b,this.uint16[E+2]=C,d}}Gl.prototype.bytesPerElement=6,Cr(Gl,"StructArrayLayout3ui6");class jb extends io{_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,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt){const yt=this.length;return this.resize(yt+1),this.emplace(yt,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt,yt){const Mt=30*d,Rt=15*d,Bt=60*d;return this.int16[Mt+0]=p,this.int16[Mt+1]=b,this.int16[Mt+2]=C,this.float32[Rt+2]=E,this.float32[Rt+3]=L,this.uint16[Mt+8]=R,this.uint16[Mt+9]=U,this.uint32[Rt+5]=K,this.uint32[Rt+6]=te,this.uint32[Rt+7]=se,this.uint16[Mt+16]=ie,this.uint16[Mt+17]=de,this.uint16[Mt+18]=fe,this.float32[Rt+10]=Te,this.float32[Rt+11]=ze,this.uint8[Bt+48]=Fe,this.uint8[Bt+49]=Qe,this.uint8[Bt+50]=nt,this.uint32[Rt+13]=ct,this.int16[Mt+28]=kt,this.uint8[Bt+58]=yt,d}}jb.prototype.bytesPerElement=60,Cr(jb,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class G6 extends io{_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,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt,yt,Mt,Rt,Bt,rs,Gt,us,Ss,Cs,Hs,Ws,Bs){const Us=this.length;return this.resize(Us+1),this.emplace(Us,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt,yt,Mt,Rt,Bt,rs,Gt,us,Ss,Cs,Hs,Ws,Bs)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt,yt,Mt,Rt,Bt,rs,Gt,us,Ss,Cs,Hs,Ws,Bs,Us){const cs=20*d,as=40*d,Vs=80*d;return this.float32[cs+0]=p,this.float32[cs+1]=b,this.int16[as+4]=C,this.int16[as+5]=E,this.int16[as+6]=L,this.int16[as+7]=R,this.int16[as+8]=U,this.int16[as+9]=K,this.int16[as+10]=te,this.int16[as+11]=se,this.int16[as+12]=ie,this.uint16[as+13]=de,this.uint16[as+14]=fe,this.uint16[as+15]=Te,this.uint16[as+16]=ze,this.uint16[as+17]=Fe,this.uint16[as+18]=Qe,this.uint16[as+19]=nt,this.uint16[as+20]=ct,this.uint16[as+21]=kt,this.uint16[as+22]=yt,this.uint16[as+23]=Mt,this.uint16[as+24]=Rt,this.uint16[as+25]=Bt,this.uint16[as+26]=rs,this.uint16[as+27]=Gt,this.uint32[cs+14]=us,this.float32[cs+15]=Ss,this.float32[cs+16]=Cs,this.float32[cs+17]=Hs,this.float32[cs+18]=Ws,this.uint8[Vs+76]=Bs,this.uint16[as+39]=Us,d}}G6.prototype.bytesPerElement=80,Cr(G6,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class W6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L){const R=this.length;return this.resize(R+1),this.emplace(R,d,p,b,C,E,L)}emplace(d,p,b,C,E,L,R){const U=6*d;return this.float32[U+0]=p,this.float32[U+1]=b,this.float32[U+2]=C,this.float32[U+3]=E,this.float32[U+4]=L,this.float32[U+5]=R,d}}W6.prototype.bytesPerElement=24,Cr(W6,"StructArrayLayout6f24");class _v extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E){const L=this.length;return this.resize(L+1),this.emplace(L,d,p,b,C,E)}emplace(d,p,b,C,E,L){const R=5*d;return this.float32[R+0]=p,this.float32[R+1]=b,this.float32[R+2]=C,this.float32[R+3]=E,this.float32[R+4]=L,d}}_v.prototype.bytesPerElement=20,Cr(_v,"StructArrayLayout5f20");class K6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R){const U=this.length;return this.resize(U+1),this.emplace(U,d,p,b,C,E,L,R)}emplace(d,p,b,C,E,L,R,U){const K=7*d;return this.float32[K+0]=p,this.float32[K+1]=b,this.float32[K+2]=C,this.float32[K+3]=E,this.float32[K+4]=L,this.float32[K+5]=R,this.float32[K+6]=U,d}}K6.prototype.bytesPerElement=28,Cr(K6,"StructArrayLayout7f28");class Z6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R,U,K,te,se){const ie=this.length;return this.resize(ie+1),this.emplace(ie,d,p,b,C,E,L,R,U,K,te,se)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie){const de=11*d;return this.float32[de+0]=p,this.float32[de+1]=b,this.float32[de+2]=C,this.float32[de+3]=E,this.float32[de+4]=L,this.float32[de+5]=R,this.float32[de+6]=U,this.float32[de+7]=K,this.float32[de+8]=te,this.float32[de+9]=se,this.float32[de+10]=ie,d}}Z6.prototype.bytesPerElement=44,Cr(Z6,"StructArrayLayout11f44");class Nb extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R,U,K){const te=this.length;return this.resize(te+1),this.emplace(te,d,p,b,C,E,L,R,U,K)}emplace(d,p,b,C,E,L,R,U,K,te){const se=9*d;return this.float32[se+0]=p,this.float32[se+1]=b,this.float32[se+2]=C,this.float32[se+3]=E,this.float32[se+4]=L,this.float32[se+5]=R,this.float32[se+6]=U,this.float32[se+7]=K,this.float32[se+8]=te,d}}Nb.prototype.bytesPerElement=36,Cr(Nb,"StructArrayLayout9f36");class Qf extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p){const b=this.length;return this.resize(b+1),this.emplace(b,d,p)}emplace(d,p,b){const C=2*d;return this.float32[C+0]=p,this.float32[C+1]=b,d}}Qf.prototype.bytesPerElement=8,Cr(Qf,"StructArrayLayout2f8");class fh extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,p,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,p,b,C)}emplace(d,p,b,C,E){const L=6*d;return this.uint32[3*d+0]=p,this.uint16[L+2]=b,this.uint16[L+3]=C,this.uint16[L+4]=E,d}}fh.prototype.bytesPerElement=12,Cr(fh,"StructArrayLayout1ul3ui12");class Ry extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d){const p=this.length;return this.resize(p+1),this.emplace(p,d)}emplace(d,p){return this.uint16[1*d+0]=p,d}}Ry.prototype.bytesPerElement=2,Cr(Ry,"StructArrayLayout1ui2");class Y6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze){const Fe=this.length;return this.resize(Fe+1),this.emplace(Fe,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze)}emplace(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe){const Qe=16*d;return this.float32[Qe+0]=p,this.float32[Qe+1]=b,this.float32[Qe+2]=C,this.float32[Qe+3]=E,this.float32[Qe+4]=L,this.float32[Qe+5]=R,this.float32[Qe+6]=U,this.float32[Qe+7]=K,this.float32[Qe+8]=te,this.float32[Qe+9]=se,this.float32[Qe+10]=ie,this.float32[Qe+11]=de,this.float32[Qe+12]=fe,this.float32[Qe+13]=Te,this.float32[Qe+14]=ze,this.float32[Qe+15]=Fe,d}}Y6.prototype.bytesPerElement=64,Cr(Y6,"StructArrayLayout16f64");class VC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,p,b,C,E,L,R){const U=this.length;return this.resize(U+1),this.emplace(U,d,p,b,C,E,L,R)}emplace(d,p,b,C,E,L,R,U){const K=10*d,te=5*d;return this.uint16[K+0]=p,this.uint16[K+1]=b,this.uint16[K+2]=C,this.uint16[K+3]=E,this.float32[te+2]=L,this.float32[te+3]=R,this.float32[te+4]=U,d}}VC.prototype.bytesPerElement=20,Cr(VC,"StructArrayLayout4ui3f20");class Q6 extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d){const p=this.length;return this.resize(p+1),this.emplace(p,d)}emplace(d,p){return this.int16[1*d+0]=p,d}}Q6.prototype.bytesPerElement=2,Cr(Q6,"StructArrayLayout1i2");class HC extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(d){const p=this.length;return this.resize(p+1),this.emplace(p,d)}emplace(d,p){return this.uint8[1*d+0]=p,d}}HC.prototype.bytesPerElement=1,Cr(HC,"StructArrayLayout1ub1");class GC extends w2{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]}}GC.prototype.size=40;class DF extends $C{get(d){return new GC(this,d)}}Cr(DF,"CollisionBoxArray");class WC extends w2{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}}WC.prototype.size=60;class OF extends jb{get(d){return new WC(this,d)}}Cr(OF,"PlacedSymbolArray");class RF extends w2{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]}}RF.prototype.size=80;class X6 extends G6{get(d){return new RF(this,d)}}Cr(X6,"SymbolInstanceArray");class KC extends ug{getoffsetX(d){return this.float32[1*d+0]}}Cr(KC,"GlyphOffsetArray");class FF extends Dy{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}Cr(FF,"SymbolLineVertexArray");class J6 extends w2{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]}}J6.prototype.size=12;class eP extends fh{get(d){return new J6(this,d)}}Cr(eP,"FeatureIndexArray");class zF extends xm{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}Cr(zF,"FillExtrusionCentroidArray");class ZC extends w2{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]}}ZC.prototype.size=6;class j2 extends _b{get(d){return new ZC(this,d)}}Cr(j2,"FillExtrusionWallArray");const BF=_a([{name:"a_pos",components:2,type:"Int16"}],4),ope=_a([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),$F=_a([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class No{constructor(d=[]){this.segments=d}_prepareSegment(d,p,b,C){let E=this.segments[this.segments.length-1];return d>No.MAX_VERTEX_ARRAY_LENGTH&&gr(`Max vertices per segment is ${No.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>No.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==C)&&(E={vertexOffset:p,primitiveOffset:b,vertexLength:0,primitiveLength:0},C!==void 0&&(E.sortKey=C),this.segments.push(E)),E}prepareSegment(d,p,b,C){return this._prepareSegment(d,p.length,b.length,C)}get(){return this.segments}destroy(){for(const d of this.segments)for(const p in d.vaos)d.vaos[p].destroy()}static simpleSegment(d,p,b,C){return new No([{vertexOffset:d,primitiveOffset:p,vertexLength:b,primitiveLength:C,vaos:{},sortKey:0}])}}function YC(x,d){return 256*(x=je(Math.floor(x),0,255))+je(Math.floor(d),0,255)}No.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Cr(No,"SegmentVector");const lpe=_a([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),cpe=_a([{name:"a_pattern_b",components:4,type:"Uint16"}]),dpe=_a([{name:"a_dash",components:4,type:"Uint16"}]);class N2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,p,b,C){this.ids.push(tP(d)),this.positions.push(p,b,C)}eachPosition(d,p){const b=tP(d);let C=0,E=this.ids.length-1;for(;C>1;this.ids[L]>=b?E=L:C=L+1}for(;this.ids[C]===b;)p(this.positions[3*C],this.positions[3*C+1],this.positions[3*C+2]),C++}static serialize(d,p){const b=new Float64Array(d.ids),C=new Uint32Array(d.positions);return sP(b,C,0,b.length-1),p&&(p.add(b.buffer),p.add(C.buffer)),{ids:b,positions:C}}static deserialize(d){const p=new N2;let b;p.ids=d.ids,p.positions=d.positions;for(const C of p.ids)C!==b&&p.uniqueIds.push(C),b=C;return p.indexed=!0,p}}function tP(x){const d=+x;return Number.isSafeInteger(d)?d:rb(String(x))}function sP(x,d,p,b){for(;p>1];let E=p-1,L=b+1;for(;;){do E++;while(x[E]C);if(E>=L)break;QC(x,E,L),QC(d,3*E,3*L),QC(d,3*E+1,3*L+1),QC(d,3*E+2,3*L+2)}L-p`u_${E}`),this.type=b,this.context=C}setUniform(d,p,b,C,E){const L=C.constantOr(this.value);p.set(d,E,L instanceof Wr?L.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):L)}getBinding(d,p){return this.type==="color"?new S2(d):new Wl(d)}}class kb{constructor(d,p){this.uniformNames=p.map(b=>`u_${b}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(d,p){this.pixelRatio=d.pixelRatio||1,this.pattern=d.tl.concat(d.br),this.patternTransition=p?p.tl.concat(p.br):this.pattern}setUniform(d,p,b,C,E){let L=null;E!=="u_pattern"&&E!=="u_dash"||(L=this.pattern),E==="u_pattern_b"&&(L=this.patternTransition),E==="u_pixel_ratio"&&(L=this.pixelRatio),L&&p.set(d,E,L)}getBinding(d,p){return p==="u_pattern"||p==="u_pattern_b"||p==="u_dash"?new JC(d):new Wl(d)}}class mg{constructor(d,p,b,C){this.expression=d,this.type=b,this.maxValue=0,this.paintVertexAttributes=p.map(E=>({name:`a_${E}`,type:"Float32",components:b==="color"?2:1,offset:0})),this.paintVertexArray=new C}populatePaintArray(d,p,b,C,E,L,R,U){const K=this.paintVertexArray.length,te=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Yi(0,{brightness:L,worldview:U}),p,{},E,C,R):this.expression.kind==="constant"&&this.expression.value,se=M2(this.lutExpression,p,{},C,E,L,R,U);this.paintVertexArray.resize(d),this._setPaintValue(K,d,te,se?null:this.context.lut)}updatePaintArray(d,p,b,C,E,L,R,U){const K=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:U},b,C,void 0,E):this.expression.kind==="constant"&&this.expression.value,te=M2(this.lutExpression,b,C,E,void 0,R,void 0,U);this._setPaintValue(d,p,K,te?null:this.context.lut)}_setPaintValue(d,p,b,C){if(this.type==="color"){const E=rP(b.toPremultipliedRenderColor(C));for(let L=d;L`u_${R}_t`),this.type=b,this.useIntegerZoom=C,this.context=E,this.maxValue=0,this.paintVertexAttributes=p.map(R=>({name:`a_${R}`,type:"Float32",components:b==="color"?4:2,offset:0})),this.paintVertexArray=new L}populatePaintArray(d,p,b,C,E,L,R,U){const K=this.expression.evaluate(new Yi(this.context.zoom,{brightness:L,worldview:U}),p,{},E,C,R),te=this.expression.evaluate(new Yi(this.context.zoom+1,{brightness:L,worldview:U}),p,{},E,C,R),se=M2(this.lutExpression,p,{},C,E,L,R,U),ie=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ie,d,K,te,se?null:this.context.lut)}updatePaintArray(d,p,b,C,E,L,R,U){const K=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:U},b,C,void 0,E),te=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:U},b,C,void 0,E),se=M2(this.lutExpression,b,C,E,void 0,R,void 0,U);this._setPaintValue(d,p,K,te,se?null:this.context.lut)}_setPaintValue(d,p,b,C,E){if(this.type==="color"){const L=rP(b.toPremultipliedRenderColor(E)),R=rP(b.toPremultipliedRenderColor(E));for(let U=d;U!0){this.binders={},this._buffers=[],this.context=p;const C=[];for(const E in d.paint._values){const L=d.paint.get(E);if(E.endsWith("-use-theme")||!b(E)||!(L instanceof fv&&f2(L.property.specification)))continue;const R=ppe(E,d.type),U=L.value,K=L.property.specification.type,te=!!L.property.useIntegerZoom,se=E==="line-dasharray"||E.endsWith("pattern"),ie=d.paint.get(`${E}-use-theme`),de=E==="line-dasharray"&&d.layout.get("line-cap").value.kind!=="constant"||ie&&ie.value.kind!=="constant";if(U.kind!=="constant"||de)if(U.kind==="source"||de||se){const fe=nP(E,K,"source");this.binders[E]=se?new fg(U,R,K,fe,d.id):new mg(U,R,K,fe),C.push(`/a_${E}`)}else{const fe=nP(E,K,"composite");this.binders[E]=new pg(U,R,K,te,p,fe),C.push(`/z_${E}`)}else this.binders[E]=se?new kb(U.value,R):new T2(U.value,R,K,p),C.push(`/u_${E}`);ie&&(this.binders[E].lutExpression=ie.value)}this.cacheKey=C.sort().join("")}getMaxValue(d){const p=this.binders[d];return p instanceof mg||p instanceof pg?p.maxValue:0}populatePaintArrays(d,p,b,C,E,L,R,U){for(const K in this.binders){const te=this.binders[K];te.context=this.context,(te instanceof mg||te instanceof pg||te instanceof fg)&&te.populatePaintArray(d,p,b,C,E,L,R,U)}}setConstantPatternPositions(d,p){for(const b in this.binders){const C=this.binders[b];C instanceof kb&&C.setConstantPatternPositions(d,p)}}getPatternTransitionVertexBuffer(d){const p=this.binders[d];return p instanceof fg?p.paintTransitionVertexBuffer:null}updatePaintArrays(d,p,b,C,E,L,R,U,K,te){let se=!1;const ie=Object.keys(d),de=ie.length!==0&&!U,fe=de?ie:p.uniqueIds;this.context.lut=E.lut;for(const Te in this.binders){const ze=this.binders[Te];if(ze.context=this.context,(ze instanceof mg||ze instanceof pg||ze instanceof fg)&&ze.expression&&ze.expression.kind&&ze.expression.kind!=="constant"&&(ze.expression.isStateDependent===!0||ze.expression.isLightConstant===!1)){const Fe=E.paint.get(Te);ze.expression=Fe.value;for(const Qe of fe){const nt=d[Qe.toString()];p.eachPosition(Qe,(ct,kt,yt)=>{const Mt=C.feature(ct);ze.updatePaintArray(kt,yt,Mt,nt,L,R,K,te)})}if(!de)for(const Qe of b.uniqueIds){const nt=d[Qe.toString()];b.eachPosition(Qe,(ct,kt,yt)=>{const Mt=C.feature(ct);ze.updatePaintArray(kt,yt,Mt,nt,L,R,K,te)})}se=!0}}return se}defines(){const d=[];for(const p in this.binders){const b=this.binders[p];(b instanceof T2||b instanceof kb)&&d.push(...b.uniformNames.map(C=>`#define HAS_UNIFORM_${C}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const p=[];for(const b in this.binders){const C=this.binders[b];if(C instanceof T2||C instanceof kb||C instanceof pg)for(const E of C.uniformNames)p.push({name:E,property:b,binding:C.getBinding(d,E)})}return p}setUniforms(d,p,b,C,E){for(const{name:L,property:R,binding:U}of b)this.binders[R].setUniform(d,U,E,C.get(R),L)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const p=this.binders[d];(p instanceof mg||p instanceof pg||p instanceof fg)&&p.paintVertexBuffer&&this._buffers.push(p.paintVertexBuffer),p instanceof fg&&p.paintTransitionVertexBuffer&&this._buffers.push(p.paintTransitionVertexBuffer)}}upload(d){for(const p in this.binders){const b=this.binders[p];(b instanceof mg||b instanceof pg||b instanceof fg)&&b.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const p=this.binders[d];(p instanceof mg||p instanceof pg||p instanceof fg)&&p.destroy()}}}class Vp{constructor(d,p,b=()=>!0){this.programConfigurations={};for(const C of d)this.programConfigurations[C.id]=new Fy(C,p,b);this.needsUpload=!1,this._featureMap=new N2,this._featureMapWithoutIds=new N2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,p,b,C,E,L,R,U,K){for(const te in this.programConfigurations)this.programConfigurations[te].populatePaintArrays(d,p,C,E,L,R,U,K);p.id!==void 0?this._featureMap.add(p.id,b,this._bufferOffset,d):(this._featureMapWithoutIds.add(this._idlessCounter,b,this._bufferOffset,d),this._idlessCounter+=1),this._bufferOffset=d,this.needsUpload=!0}updatePaintArrays(d,p,b,C,E,L,R,U){for(const K of b)this.needsUpload=this.programConfigurations[K.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,p,K,C,E,L,R||0,U)||this.needsUpload}get(d){return this.programConfigurations[d]}upload(d){if(this.needsUpload){for(const p in this.programConfigurations)this.programConfigurations[p].upload(d);this.needsUpload=!1}}destroy(){for(const d in this.programConfigurations)this.programConfigurations[d].destroy()}}const mpe={"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 ppe(x,d){return mpe[x]||[x.replace(`${d}-`,"").replace(/-/g,"_")]}const fpe={"line-pattern":{source:ph,composite:ph},"fill-pattern":{source:ph,composite:ph},"fill-extrusion-pattern":{source:ph,composite:ph},"line-dasharray":{source:bv,composite:bv}},xpe={color:{source:Qf,composite:Oy},number:{source:ug,composite:Qf}};function nP(x,d,p){const b=fpe[x];return b&&b[p]||xpe[d][p]}Cr(T2,"ConstantBinder"),Cr(kb,"PatternConstantBinder"),Cr(mg,"SourceExpressionBinder"),Cr(fg,"PatternCompositeBinder"),Cr(pg,"CompositeExpressionBinder"),Cr(Fy,"ProgramConfiguration",{omit:["_buffers"]}),Cr(Vp,"ProgramConfigurationSet");const Gd=sr/Math.PI/2,rp=5,s5=6,gpe=16383,Sb=64,aP=[Sb,32,16],np=-Gd,ap=Gd;function wv(x,d,p,b=Gd){return p=xr(p),[x*Math.sin(p)*b,-d*b,x*Math.cos(p)*b]}function Cb(x,d,p){return wv(Math.cos(xr(x)),Math.sin(xr(x)),d,p)}const T=63710088e-1,h=2*Math.PI*T;class v{constructor(d,p){if(isNaN(d)||isNaN(p))throw new Error(`Invalid LngLat object: (${d}, ${p})`);if(this.lng=+d,this.lat=+p,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new v(st(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(d){const p=Math.PI/180,b=this.lat*p,C=d.lat*p,E=Math.sin(b)*Math.sin(C)+Math.cos(b)*Math.cos(C)*Math.cos((d.lng-this.lng)*p);return T*Math.acos(Math.min(E,1))}toBounds(d=0){const p=360*d/40075017,b=p/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-b,lat:this.lat-p},{lng:this.lng+b,lat:this.lat+p})}toEcef(d){return Cb(this.lat,this.lng,Gd+d*Gd/T)}static convert(d){if(d instanceof v)return d;if(Array.isArray(d)&&(d.length===2||d.length===3))return new v(Number(d[0]),Number(d[1]));if(!Array.isArray(d)&&typeof d=="object"&&d!==null)return new v(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,p){d&&(p?this.setSouthWest(d).setNorthEast(p):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 v?new v(d.lng,d.lat):v.convert(d),this}setSouthWest(d){return this._sw=d instanceof v?new v(d.lng,d.lat):v.convert(d),this}extend(d){const p=this._sw,b=this._ne;let C,E;if(d instanceof v)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(v.convert(d)):typeof d=="object"&&d!==null&&d.hasOwnProperty("lat")&&(d.hasOwnProperty("lon")||d.hasOwnProperty("lng"))?this.extend(v.convert(d)):this;if(C=d._sw,E=d._ne,!C||!E)return this}return p||b?(p.lng=Math.min(C.lng,p.lng),p.lat=Math.min(C.lat,p.lat),b.lng=Math.max(E.lng,b.lng),b.lat=Math.max(E.lat,b.lat)):(this._sw=new v(C.lng,C.lat),this._ne=new v(E.lng,E.lat)),this}getCenter(){return new v((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 v(this.getWest(),this.getNorth())}getSouthEast(){return new v(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:p,lat:b}=v.convert(d);let C=this._sw.lng<=p&&p<=this._ne.lng;return this._sw.lng>this._ne.lng&&(C=this._sw.lng>=p&&p>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&C}static convert(d){if(d)return d instanceof A?d:new A(d)}}const D=0,F=25.5;function B(x){return h*Math.cos(x*Math.PI/180)}function W(x){return(180+x)/360}function ee(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function ae(x,d){return x/B(d)}function le(x){return 360*x-180}function we(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function be(x,d){return x*B(we(d))}const Ne=85.051129;function Re(x){return Math.cos(xr(je(x,-Ne,Ne)))}function Ie(x,d){const p=je(d,D,F),b=Math.pow(2,p);return Re(x)*h/(512*b)}function Ze(x){return 1/Math.cos(x*Math.PI/180)}function Ve(x,d=0){const p=Math.exp(Math.PI*(1-(x.y+d/sr)/(1<=U?(ht(x,d,p,K,te,E,se,R,U),ht(x,K,te,b,C,se,L,R,U)):x.push(L)}function ot(x,d,p){let b=x[0],C=b.x,E=b.y;d(b);const L=[b];for(let R=1;Rx.x+1||bx.y+1)&&gr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Dt(x,d,p){const b=x.loadGeometry(),C=x.extent,E=sr/C;if(d&&p&&p.projection.isReprojectedInTileSpace){const L=1<{const de=le((d.x+ie.x/C)/L),fe=we((d.y+ie.y/C)/L),Te=te.project(de,fe);ie.x=(Te.x*R-U)*C,ie.y=(Te.y*R-K)*C};for(let ie=0;ie=C||fe.y<0||fe.y>=C||(se(fe),de.push(fe));b[ie]=de}}for(const L of b)for(const R of L)gt(R,E);return b}function Ht(x,d){return{type:x.type,id:x.id,properties:x.properties,geometry:d?Dt(x):[]}}class Ut{constructor(d,p,b,C,E){this.properties={},this.extent=b,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=C,this._values=E,d.readFields(es,this,p)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const p=d.readVarint()+d.pos,b=[];let C,E=1,L=0,R=0,U=0;for(;d.pos>3}if(L--,E===1||E===2)R+=d.readSVarint(),U+=d.readSVarint(),E===1&&(C&&b.push(C),C=[]),C&&C.push(new ns(R,U));else{if(E!==7)throw new Error(`unknown command ${E}`);C&&C.push(C[0].clone())}}return C&&b.push(C),b}bbox(){const d=this._pbf;d.pos=this._geometry;const p=d.readVarint()+d.pos;let b=1,C=0,E=0,L=0,R=1/0,U=-1/0,K=1/0,te=-1/0;for(;d.pos>3}if(C--,b===1||b===2)E+=d.readSVarint(),L+=d.readSVarint(),EU&&(U=E),Lte&&(te=L);else if(b!==7)throw new Error(`unknown command ${b}`)}return[R,K,U,te]}toGeoJSON(d,p,b){const C=this.extent*Math.pow(2,b),E=this.extent*d,L=this.extent*p,R=this.loadGeometry();function U(ie){return[360*(ie.x+E)/C-180,360/Math.PI*Math.atan(Math.exp((1-2*(ie.y+L)/C)*Math.PI))-90]}function K(ie){return ie.map(U)}let te;if(this.type===1){const ie=[];for(const fe of R)ie.push(fe[0]);const de=K(ie);te=ie.length===1?{type:"Point",coordinates:de[0]}:{type:"MultiPoint",coordinates:de}}else if(this.type===2){const ie=R.map(K);te=ie.length===1?{type:"LineString",coordinates:ie[0]}:{type:"MultiLineString",coordinates:ie}}else{if(this.type!==3)throw new Error("unknown feature type");{const ie=function(fe){const Te=fe.length;if(Te<=1)return[fe];const ze=[];let Fe,Qe;for(let nt=0;nt=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[d];const p=this._pbf.readVarint()+this._pbf.pos;return new Ut(this._pbf,p,this.extent,this._keys,this._values)}}function Ks(x,d,p){x===15?d.version=p.readVarint():x===1?d.name=p.readString():x===5?d.extent=p.readVarint():x===2?d._features.push(p.pos):x===3?d._keys.push(p.readString()):x===4&&d._values.push(function(b){let C=null;const E=b.readVarint()+b.pos;for(;b.pos>3;C=L===1?b.readString():L===2?b.readFloat():L===3?b.readDouble():L===4?b.readVarint64():L===5?b.readVarint():L===6?b.readSVarint():L===7?b.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}(p))}class Yt{constructor(d,p){this.layers=d.readFields(zt,{},p)}}function zt(x,d,p){if(x===3){const b=new _s(p,p.readVarint()+p.pos);b.length&&(d[b.name]=b)}}const is="3d_elevation_id",Jt="level";class zs{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,p){return this._valid&&d(p(this._geometry)),this}require(d,p,b){return this.get(d,!0,p,b)}optional(d,p,b){return this.get(d,!1,p,b)}success(){return this._valid}get(d,p,b,C){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?b(C?C(E):E):p&&(this._valid=!1),this}}class ir{constructor(d,p){this.featureFunc=d,this.vertexFunc=p}parseFeature(d,p,b){return this.featureFunc(d,p,b)}parseVertex(d,p,b){return this.vertexFunc(d,p,b)}}const br=new ir((x,d,p)=>x.reset(d).require(is,b=>{p.id=b}).optional("fixed_height_relative",b=>{p.constantHeight=b},Zs.decodeRelativeHeight).geometry(b=>{p.bounds=b},ag).success(),(x,d,p)=>x.reset(d).require(is,b=>{p.id=b}).require("elevation_idx",b=>{p.idx=b}).require("extent",b=>{p.extent=b}).require("height_relative",b=>{p.height=b},Zs.decodeRelativeHeight).geometry(b=>{p.position=b},Zs.getPoint).success()),er=new ir((x,d,p)=>x.reset(d).require(is,b=>{p.id=b}).optional("fixed_height",b=>{p.constantHeight=b},Zs.decodeMetricHeight).geometry(b=>{p.bounds=b},ag).success(),(x,d,p)=>x.reset(d).require(is,b=>{p.id=b}).require("elevation_idx",b=>{p.idx=b}).require("extent",b=>{p.extent=b}).require("height",b=>{p.height=b},Zs.decodeMetricHeight).geometry(b=>{p.position=b},Zs.getPoint).success());class Zs{static getPoint(d){return Ft(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"?er:void 0:br}static parse(d){const p=[],b=[],C=d.length,E=new zs;for(let L=0;L=0);if(E===0)return 0;E!==d.length&&(p=!1)}return p?2:1}function On(x,d){for(const p of x.projections){const b=wr(d,x.points[0],p.axis);if(p.projection[1]b[1])return 0}return 1}function Sa(x,d){let p=0;const b=[0,0,0,0];for(let L=0;L=0&&p++;var C,E;return p}class oi{constructor(d,p){this.points=d||new Array(8).fill([0,0,0]),this.planes=p||new Array(6).fill([0,0,0,0]),this.bounds=Fr.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ce([],this.points[2],this.points[3]),Ce([],this.points[0],this.points[3]),Ce([],this.points[4],this.points[0]),Ce([],this.points[5],this.points[1]),Ce([],this.points[6],this.points[2]),Ce([],this.points[7],this.points[3])];for(const b of this.frustumEdges){const C=[0,-b[2],b[1]],E=[b[2],0,-b[0]];this.projections.push({axis:C,projection:wr(this.points,this.points[0],C)}),this.projections.push({axis:E,projection:wr(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,p,b,C){const E=Math.pow(2,b),L=[[-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(K=>{const te=tt([],K,d),se=1/te[3]/p*E;return(ie=te)[0]=(de=te)[0]*(fe=[se,se,C?1/te[3]:se,se])[0],ie[1]=de[1]*fe[1],ie[2]=de[2]*fe[2],ie[3]=de[3]*fe[3],ie;var ie,de,fe}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(K=>{const te=ke([],qe([],Ce([],L[K[0]],L[K[1]]),Ce([],L[K[2]],L[K[1]]))),se=-Oe(te,L[K[1]]);return te.concat(se)}),U=[];for(let K=0;KK[1]||K[0]>U[1])return 0}return 1}containsPoint(d){for(const p of this.planes){const b=p[3];if(Oe([p[0],p[1],p[2]],d)+b<0)return!1}return!0}}class Fr{static fromPoints(d){const p=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];for(const C of d)ue(p,p,C),ge(b,b,C);return new Fr(p,b)}static fromTileIdAndHeight(d,p,b){const C=1<d.max[p]||d.min[p]>this.max[p])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 p=0;p<3;p++)this.min[p]=Math.min(this.min[p],d.min[p]),this.max[p]=Math.max(this.max[p],d.max[p])}encapsulatePoint(d){for(let p=0;p<3;p++)this.min[p]=Math.min(this.min[p],d[p]),this.max[p]=Math.max(this.max[p],d[p])}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])]}}Cr(Fr,"Aabb");class ei{constructor(d,p){this.feature=d,this.metersToTile=p,this.index=0}get(){const d=this.feature.vertices[this.index],p=this.feature.vertexProps[this.index].dir,b=p[1],C=-p[0],E=(d.extent+1)*this.metersToTile;return[new ns(Math.trunc(d.position[0]+b*E),Math.trunc(d.position[1]+C*E)),new ns(Math.trunc(d.position[0]-b*E),Math.trunc(d.position[1]-C*E))]}next(){this.index++}valid(){return this.index{return R.a0?_e(U,U,1/K):re(U,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(d){if(this.edges.length===0)return;let p=0,b=Number.POSITIVE_INFINITY,C=0;const[E,L,R,U,K,te,se]=this._tmpVec2;Ps(se,d.x,d.y);const ie=new Dr(se,null);for(let de=0;de0?Ln(U,R)/ct:0,yt=je(kt,0,1),Mt=Math.abs((kt-yt)*this.edgeProps[de].len);Is(K,se,ze),Ps(te,Te[1],-Te[0]);const Rt=Mt+Math.abs(Ln(K,te));Rt=0;--L){const R=this.edges[L].a,U=this.edges[L].b,{position:K,height:te,extent:se}=this.vertices[R],{position:ie,height:de,extent:fe}=this.vertices[U],Te=this.vertexProps[R].dir,ze=this.vertexProps[U].dir;if(re(p,K[0]/d,K[1]/d,te),re(b,ie[0]/d,ie[1]/d,de),re(C,Te[1],-Te[0],0),_e(C,C,se),re(E,ze[1],-ze[0],0),_e(E,E,fe),this.distSqLines(ne(p[0]+.5*C[0],p[1]+.5*C[1],p[2]+.5*C[2]),ne(b[0]-.5*E[0],b[1]-.5*E[1],b[2]-.5*E[2]),ne(p[0]-.5*C[0],p[1]-.5*C[1],p[2]-.5*C[2]),ne(b[0]+.5*E[0],b[1]+.5*E[1],b[2]+.5*E[2]))<=.0025000000000000005)continue;const Fe=this.vertices.length,Qe=yr(zr(),K,ie);this.vertices.push({position:Ar(Qe,Qe,.5),height:.5*(te+de),extent:.5*(se+fe)});const nt=yr(zr(),Te,ze);this.vertexProps.push({dir:na(nt,nt)}),this.edges.splice(L,1),this.edgeProps.splice(L,1),this.edges.push({a:R,b:Fe}),this.edges.push({a:Fe,b:U});const ct=Is(zr(),this.vertices[Fe].position,K),kt=tn(ct),yt={vec:ct,dir:Ar(zr(),ct,1/kt),len:kt};this.edgeProps.push(yt),this.edgeProps.push(yt)}}distSqLines(d,p,b,C){const E=he(J(),p,d),L=he(J(),C,b),R=he(J(),d,b),U=Oe(E,E),K=Oe(E,L),te=Oe(E,R),se=Oe(L,L),ie=Oe(L,R),de=U*se-K*K;if(de===0)return Ee(ve(E,b,C,Oe(R,L)/Oe(L,L)),d);const fe=(U*ie-K*te)/de;return Ee(ve(E,d,p,(K*ie-te*se)/de),ve(L,b,C,fe))}}class pi{static parseFrom(d,p){const b=Zs.parse(d);if(!b)return[];let{vertices:C,features:E}=b;const L=1/Ve(p);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,ie)=>se===ie.findIndex(de=>de.id===te.id&&de.idx===te.idx));const R=new Array;let U=0;const K=C.length;for(const te of E){if(te.constantHeight){R.push(new En(te.id,te.bounds,te.constantHeight));continue}for(;U!==K&&C[U].idC.id===b)}}class Ti{constructor(d,p){this.zScale=1,this.xOffset=0,this.yOffset=0,d.equals(p)||(this.zScale=Math.pow(2,p.z-d.z),this.xOffset=(d.x*this.zScale-p.x)*sr,this.yOffset=(d.y*this.zScale-p.y)*sr)}constantElevation(d,p){if(d.constantHeight!=null)return this.computeBiasedHeight(d.constantHeight,p)}pointElevation(d,p,b){const C=this.constantElevation(p,b);return C??(d.x=d.x*this.zScale+this.xOffset,d.y=d.y*this.zScale+this.yOffset,this.computeBiasedHeight(p.pointElevation(d),b))}computeBiasedHeight(d,p){return p<=0?d:d+p*$e(0,p,d>=0?d:Math.abs(.5*d))}}Cr(En,"ElevationFeature");class ji{constructor(d){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.hasPattern=!1,this.projection=d.projection,this.layoutVertexArray=new Dy,this.indexArray=new Gl,this.segments=new No,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new ug),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,p){}updateAppearances(d,p,b,C){}populate(d,p,b,C){const E=this.layers[0],L=[];let R=null;E.type==="circle"&&(R=E.layout.get("circle-sort-key"));for(const{feature:K,id:te,index:se,sourceLayerIndex:ie}of d){const de=this.layers[0]._featureFilter.needGeometry,fe=Ht(K,de);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),fe,b))continue;const Te=R?R.evaluate(fe,{},b):void 0,ze={id:te,properties:K.properties,type:K.type,sourceLayerIndex:ie,index:se,geometry:de?fe.geometry:Dt(K,b,C),patterns:{},sortKey:Te};L.push(ze)}R&&L.sort((K,te)=>K.sortKey-te.sortKey);let U=null;C.projection.name==="globe"&&(this.globeExtVertexArray=new zC,U=C.projection);for(const K of L){const{geometry:te,index:se,sourceLayerIndex:ie}=K,de=d[se].feature;this.addFeature(K,te,se,p.availableImages,b,U,p.brightness,p.elevationFeatures),p.featureIndex.insert(de,te,se,ie,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,p,b,C,E,L,R){this.programConfigurations.updatePaintArrays(d,p,E,b,C,L,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,BF.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,$F.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,ope.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,p,b,C,E,L,R,U){let K;this.elevationMode!=="none"&&(K=pi.getElevationFeature(d,U));for(const te of p)for(const se of te){const ie=se.x,de=se.y;if(ie<0||ie>=sr||de<0||de>=sr)continue;if(L){const ze=L.projectTilePoint(ie,de,E),Fe=L.upVector(E,ie,de);this.addGlobeExtVertex(ze,Fe),this.addGlobeExtVertex(ze,Fe),this.addGlobeExtVertex(ze,Fe),this.addGlobeExtVertex(ze,Fe)}const fe=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),Te=fe.vertexLength;if(this.addCircleVertex(ie,de,-1,-1),this.addCircleVertex(ie,de,1,-1),this.addCircleVertex(ie,de,1,1),this.addCircleVertex(ie,de,-1,1),this.elevationMode!=="none"){const ze=K?K.pointElevation(new ns(ie,de)):0;this.hasElevation=this.hasElevation||ze!==0;for(let Fe=0;Fe<4;Fe++)this.elevatedLayoutVertexArray.emplaceBack(ze)}this.indexArray.emplaceBack(Te,Te+1,Te+2),this.indexArray.emplaceBack(Te,Te+2,Te+3),fe.vertexLength+=4,fe.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,b,{},C,E,R,void 0,this.worldview)}addCircleVertex(d,p,b,C){this.layoutVertexArray.emplaceBack(2*d+(b+1)/2,2*p+(C+1)/2)}addGlobeExtVertex(d,p){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,p[0]*16384,p[1]*16384,p[2]*16384)}}function Xa(x,d){for(let p=0;p1){if(oo(x,d))return!0;for(let b=0;b1?p:p.sub(d)._mult(C)._add(d))}function ko(x,d){let p,b,C,E=!1;for(let L=0;Ld.y!=C.y>d.y&&d.x<(C.x-b.x)*(d.y-b.y)/(C.y-b.y)+b.x&&(E=!E)}return E}function Ri(x,d){let p=!1;for(let b=0,C=x.length-1;bd.y!=L.y>d.y&&d.x<(L.x-E.x)*(d.y-E.y)/(L.y-E.y)+E.x&&(p=!p)}return p}function Vu(x,d,p,b,C){for(const L of x)if(d<=L.x&&p<=L.y&&b>=L.x&&C>=L.y)return!0;const E=[new ns(d,p),new ns(d,C),new ns(b,C),new ns(b,p)];if(x.length>2){for(const L of E)if(Ri(x,L))return!0}for(let L=0;LC.x&&d.x>C.x||x.yC.y&&d.y>C.y)return!1;const E=Un(x,d,p[0]);return E!==Un(x,d,p[1])||E!==Un(x,d,p[2])||E!==Un(x,d,p[3])}function Kl(x,d,p,b,C,E){let L=d.y-x.y,R=x.x-d.x;if(E=E||0){const U=L*L+R*R;if(U===0)return!0;const K=Math.sqrt(U);L/=K,R/=K}return!((p.x-x.x)*L+(p.y-x.y)*R-E<0||(b.x-x.x)*L+(b.y-x.y)*R-E<0||(C.x-x.x)*L+(C.y-x.y)*R-E<0)}function Wd(x,d,p,b,C,E,L){return!(Kl(x,d,b,C,E,L)||Kl(d,p,b,C,E,L)||Kl(p,x,b,C,E,L)||Kl(b,C,x,d,p,L)||Kl(C,E,x,d,p,L)||Kl(E,b,x,d,p,L))}function Kd(x,d,p){const b=d.paint.get(x).value;return b.kind==="constant"?b.value:p.programConfigurations.get(d.id).getMaxValue(x)}function ld(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function gm(x,d,p,b,C){if(!d[0]&&!d[1])return x;const E=ns.convert(d)._mult(C);p==="viewport"&&E._rotate(-b);const L=[];for(let R=0;R>p&&d.y===this.y>>p}url(d,p){const b=function(E,L,R){var U=nl(256*E,256*(L=Math.pow(2,R)-L-1),R),K=nl(256*(E+1),256*(L+1),R);return U[0]+","+U[1]+","+K[0]+","+K[1]}(this.x,this.y,this.z),C=function(E,L,R){let U,K="";for(let te=E;te>0;te--)U=1<this.canonical.z?new Ao(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Ao(d,this.wrap,d,this.canonical.x>>p,this.canonical.y>>p)}calculateScaledKey(d,p=!0){if(this.overscaledZ===d&&p)return this.key;if(d>this.canonical.z)return So(this.wrap*+p,d,this.canonical.z,this.canonical.x,this.canonical.y);{const b=this.canonical.z-d;return So(this.wrap*+p,d,d,this.canonical.x>>b,this.canonical.y>>b)}}isChildOf(d){if(d.wrap!==this.wrap)return!1;const p=this.canonical.z-d.canonical.z;return d.overscaledZ===0||d.overscaledZ>p&&d.canonical.y===this.canonical.y>>p}children(d){if(this.overscaledZ>=d)return[new Ao(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const p=this.canonical.z+1,b=2*this.canonical.x,C=2*this.canonical.y;return[new Ao(p,this.wrap,p,b,C),new Ao(p,this.wrap,p,b+1,C),new Ao(p,this.wrap,p,b,C+1),new Ao(p,this.wrap,p,b+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,p=x.wrap;return d<0&&(d=(1<{let d=x.canonical.x+1,p=x.wrap;return d===1<new Ao(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new Ao(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(b,C,E,L){const R=Math.sin(E);return b*(Math.sin((1-L)*E)/R)+C*(Math.sin(L*E)/R)}(x.a[d],x.b[d],x.angle,je(p,0,1))+x.center[d]}function Gp(x){if(x.z<=1)return xg[x.z+2*x.y+x.x];const d=ype(qF(x));return Fr.fromPoints(d)}function yg(x,d,p){return _e(x,x,1-p),Be(x,x,d,p)}function R3e(x,d,p){for(const b of x)dt(b,b,d),_e(b,b,p)}function F3e(x,d,p,b){const C=d/x.worldSize,E=x.globeMatrix;if(p.z<=1){const Bt=Gp(p).getCorners();return R3e(Bt,E,C),Fr.fromPoints(Bt)}const L=qF(p,b),R=ype(L,Gd+Jf(x._tileCoverLift));R3e(R,E,C);const U=Number.MAX_VALUE,K=[-U,-U,-U],te=[U,U,U];if(L.contains(x.center)){for(const Gt of R)ue(te,te,Gt),ge(K,K,Gt);K[2]=0;const Bt=x.point,rs=[Bt.x*C,Bt.y*C,0];return ue(te,te,rs),ge(K,K,rs),new Fr(te,K)}if(x._tileCoverLift>0){for(const Bt of R)ue(te,te,Bt),ge(K,K,Bt);return new Fr(te,K)}const se=[E[12]*C,E[13]*C,E[14]*C],ie=L.getCenter(),de=je(x.center.lat,-Ne,Ne),fe=je(ie.lat,-Ne,Ne),Te=W(x.center.lng),ze=ee(de);let Fe=Te-W(ie.lng);const Qe=ze-ee(fe);Fe>.5?Fe-=1:Fe<-.5&&(Fe+=1);let nt=0;Math.abs(Fe)>Math.abs(Qe)?nt=Fe>=0?1:3:(nt=Qe>=0?0:2,Be(se,se,[E[4]*C,E[5]*C,E[6]*C],-Math.sin(xr(Qe>=0?L.getSouth():L.getNorth()))*Gd));const ct=R[nt],kt=R[(nt+1)%4],yt=new zy(ct,kt,se),Mt=[gg(yt,0)||ct[0],gg(yt,1)||ct[1],gg(yt,2)||ct[2]],Rt=Ab(x.zoom);if(Rt>0){const Bt=function({x:Gt,y:us,z:Ss},Cs,Hs,Ws,Bs){const Us=1/(1<.5?Ys=-1:$r<-.5&&(Ys=1),cs=((cs+Ys)*Cs-(Ws*=Cs))*Hs+Ws,as=((as+Ys)*Cs-Ws)*Hs+Ws,Vs=(Vs*Cs-(Bs*=Cs))*Hs+Bs,nr=(nr*Cs-Bs)*Hs+Bs,[[cs,nr,0],[as,nr,0],[as,Vs,0],[cs,Vs,0]]}(p,d,x._pixelsPerMercatorPixel,Te,ze);for(let Gt=0;GtMath.PI/2*1.01}const U3e=xr(85),xdt=Math.cos(U3e),gdt=Math.sin(U3e),ydt=_(),V3e=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 H3e(x,d,p,b,C,E,L,R,U){if(E&&x.queryGeometry.isAboveHorizon)return!1;E&&(U*=x.pixelToTileUnitsFactor);const K=x.tileID.canonical,te=p.projection.upVectorScale(K,p.center.lat,p.worldSize).metersToTile;for(const se of d)for(const ie of se){const de=ie.add(R),fe=C&&p.elevation?p.elevation.exaggeration()*C.getElevationAt(de.x,de.y,!0):0,Te=p.projection.projectTilePoint(de.x,de.y,K);if(fe>0){const nt=p.projection.upVector(K,de.x,de.y);Te.x+=nt[0]*te*fe,Te.y+=nt[1]*te*fe,Te.z+=nt[2]*te*fe}const ze=E?de:vdt(Te.x,Te.y,Te.z,b),Fe=E?x.tilespaceRays.map(nt=>_dt(nt,fe)):x.queryGeometry.screenGeometry,Qe=tt([],[Te.x,Te.y,Te.z,1],b);if(!L&&E?U*=Qe[3]/p.cameraToCenterDistance:L&&!E&&(U*=p.cameraToCenterDistance/Qe[3]),E){const nt=we((ie.y/sr+K.y)/(1<x.width||C.height>x.height||p.x>x.width-C.width||p.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||b.x>d.width-C.width||b.y>d.height-C.height)throw new RangeError("out of range destination coordinates for image copy");const U=x.data,K=d.data,te=E===4&&R;for(let se=0;se{d[x.evaluationKey]=U;const K=x.expression.evaluate(d),te=K?K.toNonPremultipliedRenderColor(null):null;te&&(C.data[L+R+0]=Math.floor(255*te.r),C.data[L+R+1]=Math.floor(255*te.g),C.data[L+R+2]=Math.floor(255*te.b),C.data[L+R+3]=Math.floor(255*te.a))};if(x.clips)for(let L=0,R=0;L80*p){R=x[0],U=x[1];let te=R,se=U;for(let ie=p;iete&&(te=de),fe>se&&(se=fe)}K=Math.max(te-R,se-U),K=K!==0?32767/K:0}return lP(E,L,p,R,U,K,0),L}function tCe(x,d,p,b,C){let E;if(C===function(L,R,U,K){let te=0;for(let se=R,ie=U-K;se0)for(let L=d;L=d;L-=b)E=aCe(L/b|0,x[L],x[L+1],E);return E&&n5(E,E.next)&&(uP(E),E=E.next),E}function P2(x,d){if(!x)return x;d||(d=x);let p,b=x;do if(p=!1,b.steiner||!n5(b,b.next)&&Zc(b.prev,b,b.next)!==0)b=b.next;else{if(uP(b),b=d=b.prev,b===b.next)break;p=!0}while(p||b!==d);return d}function lP(x,d,p,b,C,E,L){if(!x)return;!L&&E&&function(U,K,te,se){let ie=U;do ie.z===0&&(ie.z=jpe(ie.x,ie.y,K,te,se)),ie.prevZ=ie.prev,ie.nextZ=ie.next,ie=ie.next;while(ie!==U);ie.prevZ.nextZ=null,ie.prevZ=null,function(de){let fe,Te=1;do{let ze,Fe=de;de=null;let Qe=null;for(fe=0;Fe;){fe++;let nt=Fe,ct=0;for(let yt=0;yt0||kt>0&&nt;)ct!==0&&(kt===0||!nt||Fe.z<=nt.z)?(ze=Fe,Fe=Fe.nextZ,ct--):(ze=nt,nt=nt.nextZ,kt--),Qe?Qe.nextZ=ze:de=ze,ze.prevZ=Qe,Qe=ze;Fe=nt}Qe.nextZ=null,Te*=2}while(fe>1)}(ie)}(x,b,C,E);let R=x;for(;x.prev!==x.next;){const U=x.prev,K=x.next;if(E?Cdt(x,b,C,E):Sdt(x))d.push(U.i,x.i,K.i),uP(x),x=K.next,R=K.next;else if((x=K)===R){L?L===1?lP(x=Mdt(P2(x),d),d,p,b,C,E,2):L===2&&Tdt(x,d,p,b,C,E):lP(P2(x),d,p,b,C,E,1);break}}}function Sdt(x){const d=x.prev,p=x,b=x.next;if(Zc(d,p,b)>=0)return!1;const C=d.x,E=p.x,L=b.x,R=d.y,U=p.y,K=b.y,te=Math.min(C,E,L),se=Math.min(R,U,K),ie=Math.max(C,E,L),de=Math.max(R,U,K);let fe=b.next;for(;fe!==d;){if(fe.x>=te&&fe.x<=ie&&fe.y>=se&&fe.y<=de&&cP(C,R,E,U,L,K,fe.x,fe.y)&&Zc(fe.prev,fe,fe.next)>=0)return!1;fe=fe.next}return!0}function Cdt(x,d,p,b){const C=x.prev,E=x,L=x.next;if(Zc(C,E,L)>=0)return!1;const R=C.x,U=E.x,K=L.x,te=C.y,se=E.y,ie=L.y,de=Math.min(R,U,K),fe=Math.min(te,se,ie),Te=Math.max(R,U,K),ze=Math.max(te,se,ie),Fe=jpe(de,fe,d,p,b),Qe=jpe(Te,ze,d,p,b);let nt=x.prevZ,ct=x.nextZ;for(;nt&&nt.z>=Fe&&ct&&ct.z<=Qe;){if(nt.x>=de&&nt.x<=Te&&nt.y>=fe&&nt.y<=ze&&nt!==C&&nt!==L&&cP(R,te,U,se,K,ie,nt.x,nt.y)&&Zc(nt.prev,nt,nt.next)>=0||(nt=nt.prevZ,ct.x>=de&&ct.x<=Te&&ct.y>=fe&&ct.y<=ze&&ct!==C&&ct!==L&&cP(R,te,U,se,K,ie,ct.x,ct.y)&&Zc(ct.prev,ct,ct.next)>=0))return!1;ct=ct.nextZ}for(;nt&&nt.z>=Fe;){if(nt.x>=de&&nt.x<=Te&&nt.y>=fe&&nt.y<=ze&&nt!==C&&nt!==L&&cP(R,te,U,se,K,ie,nt.x,nt.y)&&Zc(nt.prev,nt,nt.next)>=0)return!1;nt=nt.prevZ}for(;ct&&ct.z<=Qe;){if(ct.x>=de&&ct.x<=Te&&ct.y>=fe&&ct.y<=ze&&ct!==C&&ct!==L&&cP(R,te,U,se,K,ie,ct.x,ct.y)&&Zc(ct.prev,ct,ct.next)>=0)return!1;ct=ct.nextZ}return!0}function Mdt(x,d){let p=x;do{const b=p.prev,C=p.next.next;!n5(b,C)&&rCe(b,p,p.next,C)&&dP(b,C)&&dP(C,b)&&(d.push(b.i,p.i,C.i),uP(p),uP(p.next),p=x=C),p=p.next}while(p!==x);return P2(p)}function Tdt(x,d,p,b,C,E){let L=x;do{let R=L.next.next;for(;R!==L.prev;){if(L.i!==R.i&&Ldt(L,R)){let U=nCe(L,R);return L=P2(L,L.next),U=P2(U,U.next),lP(L,d,p,b,C,E,0),void lP(U,d,p,b,C,E,0)}R=R.next}L=L.next}while(L!==x)}function Adt(x,d){let p=x.x-d.x;return p===0&&(p=x.y-d.y,p===0)&&(p=(x.next.y-x.y)/(x.next.x-x.x)-(d.next.y-d.y)/(d.next.x-d.x)),p}function Edt(x,d){const p=function(C,E){let L=E;const R=C.x,U=C.y;let K,te=-1/0;if(n5(C,L))return L;do{if(n5(C,L.next))return L.next;if(U<=L.y&&U>=L.next.y&&L.next.y!==L.y){const Te=L.x+(U-L.y)*(L.next.x-L.x)/(L.next.y-L.y);if(Te<=R&&Te>te&&(te=Te,K=L.x=L.x&&L.x>=ie&&R!==L.x&&sCe(UK.x||L.x===K.x&&Pdt(K,L)))&&(K=L,fe=Te)}L=L.next}while(L!==se);return K}(x,d);if(!p)return d;const b=nCe(p,x);return P2(b,b.next),P2(p,p.next)}function Pdt(x,d){return Zc(x.prev,x,d.prev)<0&&Zc(d.next,x,x.next)<0}function jpe(x,d,p,b,C){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-p)*C|0)|x<<8))|x<<4))|x<<2))|x<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-b)*C|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function Idt(x){let d=x,p=x;do(d.x=(x-L)*(E-R)&&(x-L)*(b-R)>=(p-L)*(d-R)&&(p-L)*(E-R)>=(C-L)*(b-R)}function cP(x,d,p,b,C,E,L,R){return!(x===L&&d===R)&&sCe(x,d,p,b,C,E,L,R)}function Ldt(x,d){return x.next.i!==d.i&&x.prev.i!==d.i&&!function(p,b){let C=p;do{if(C.i!==p.i&&C.next.i!==p.i&&C.i!==b.i&&C.next.i!==b.i&&rCe(C,C.next,p,b))return!0;C=C.next}while(C!==p);return!1}(x,d)&&(dP(x,d)&&dP(d,x)&&function(p,b){let C=p,E=!1;const L=(p.x+b.x)/2,R=(p.y+b.y)/2;do C.y>R!=C.next.y>R&&C.next.y!==C.y&&L<(C.next.x-C.x)*(R-C.y)/(C.next.y-C.y)+C.x&&(E=!E),C=C.next;while(C!==p);return E}(x,d)&&(Zc(x.prev,x,d.prev)||Zc(x,d.prev,d))||n5(x,d)&&Zc(x.prev,x,x.next)>0&&Zc(d.prev,d,d.next)>0)}function Zc(x,d,p){return(d.y-x.y)*(p.x-d.x)-(d.x-x.x)*(p.y-d.y)}function n5(x,d){return x.x===d.x&&x.y===d.y}function rCe(x,d,p,b){const C=GF(Zc(x,d,p)),E=GF(Zc(x,d,b)),L=GF(Zc(p,b,x)),R=GF(Zc(p,b,d));return C!==E&&L!==R||!(C!==0||!HF(x,p,d))||!(E!==0||!HF(x,b,d))||!(L!==0||!HF(p,x,b))||!(R!==0||!HF(p,d,b))}function HF(x,d,p){return d.x<=Math.max(x.x,p.x)&&d.x>=Math.min(x.x,p.x)&&d.y<=Math.max(x.y,p.y)&&d.y>=Math.min(x.y,p.y)}function GF(x){return x>0?1:x<0?-1:0}function dP(x,d){return Zc(x.prev,x,x.next)<0?Zc(x,d,x.next)>=0&&Zc(x,x.prev,d)>=0:Zc(x,d,x.prev)<0||Zc(x,x.next,d)<0}function nCe(x,d){const p=Npe(x.i,x.x,x.y),b=Npe(d.i,d.x,d.y),C=x.next,E=d.prev;return x.next=d,d.prev=x,p.next=C,C.prev=p,b.next=p,p.prev=b,E.next=b,b.prev=E,b}function aCe(x,d,p,b){const C=Npe(x,d,p);return b?(C.next=b.next,C.prev=b,b.next.prev=C,b.next=C):(C.prev=C,C.next=C),C}function uP(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 Npe(x,d,p){return{i:x,x:d,y:p,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function hP(x,d){const p=x.length;if(p<=1)return[x];const b=[];let C,E;for(let L=0;L1)for(let L=0;L=sr&&p>=sr}static evaluate(d){if(d.length===0)return new jv;let p=[];for(const U of d)p.push(...U.portals);if(p.length===0)return new jv;for(const U of p){const K=U.va,te=U.vb;(jv.isOnBorder(K.x,te.x)||jv.isOnBorder(K.y,te.y))&&(U.type="border")}const b=p.filter(U=>U.type!=="unevaluated"),C=p.filter(U=>U.type==="unevaluated");if(C.length===0)return new jv;C.sort((U,K)=>U.hash===K.hash?U.isTunnel===K.isTunnel?0:U.isTunnel?-1:1:U.hashU.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Vp(p,{zoom:b,lut:C},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,p){const b=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||ie.x>=E.min.x&&ie.x<=E.max.x&&ie.y>=E.min.y&&ie.y<=E.max.y||Ed(se,ie,R))||this.isOnBorder(se.x,ie.x)||this.isOnBorder(se.y,ie.y))continue;const de=ym.computeEdgeHash(this.unevalVertices[K],this.unevalVertices[te]);let fe,Te=this.vertexHashLookup.get(ym.computePosHash(se));Te!=null?fe=Te.next:(Te=this.vertexHashLookup.get(ym.computePosHash(ie)),fe=Te!=null?Te.prev:de),this.unevalEdges.push({polygonIdx:d,a:K,b:te,hash:de,portalHash:fe,isTunnel:C,type:"unevaluated",featureInfo:L})}}addPortalCandidates(d,p,b,C,E){if(p.length===0)return;this.portalPolygons.add(d,{geometry:p,zLevel:E});const L=p[0];this.vertexHashLookup.clear();let R=ym.computeEdgeHash(L[L.length-2],L[L.length-1]);for(let U=0;U({vertexOffset:0,primitiveOffset:this.indexArray.length}),b=ie=>{ie.primitiveLength=this.indexArray.length-ie.primitiveOffset},C=new Odt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=p(),L=p(),R=p(),U=(ie,de)=>{ie.sort((Te,ze)=>Te.type===de&&ze.type!==de?-1:Te.type!==de&&ze.type===de?1:0);const fe=ie.findIndex(Te=>Te.type!==de);return fe>=0?fe:ie.length};let K=0;this.unevalEdges.length>0&&(K=U(this.unevalEdges,"none"),this.constructBridgeStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:K},this.tileToMeters)),b(R);const te=p(),se=p();if(this.unevalEdges.length>0){const ie=this.unevalEdges.splice(K),de=U(ie,"tunnel")+K;this.unevalEdges.push(...ie),this.constructTunnelStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:K},{min:K,max:de})}b(te),C.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),b(se),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),b(L),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),b(E),this.maskSegments=No.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=No.simpleSegment(0,L.primitiveOffset,0,L.primitiveLength),this.renderableBridgeSegments=No.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=No.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.shadowCasterSegments=No.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,p,b,C,E,L,R,U){this.bridgeProgramConfigurations.updatePaintArrays(d,p,E,b,C,L,R,U),this.tunnelProgramConfigurations.updatePaintArrays(d,p,E,b,C,L,R,U)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,Ndt.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,kdt.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,p,b,C,E){const L=(R,U)=>{for(let K=0;Kre(Hs,p[Ws].x,p[Ws].y,b[Ws]*U),se=J(),ie=J(),de=J(),fe=J(),Te=J(),ze=(Hs,Ws)=>{const Bs=R.get(ym.computePosHash(p[Ws])),Us=Bs.from,cs=Bs.to;if(!Us||!cs)return;te(se,Us),te(ie,Ws),te(de,cs),Xe(fe),et(se,ie)||(Ce(Te,ie,se),ke(fe,Te)),et(de,ie)||(Ce(Te,de,ie),oe(fe,fe,ke(Te,Te)));const as=Ge(fe);return as>0?_e(Hs,fe,1/as):void 0};let Fe=Number.POSITIVE_INFINITY;this.sortSubarray(C,E.min,E.max,(Hs,Ws)=>Hs.featureInfo.featureIndex-Ws.featureInfo.featureIndex);const Qe=J(),nt=J(),ct=J(),kt=J(),yt=J(),Mt=J(),Rt=J(),Bt=J(),rs=J(),Gt=[J(),J(),J(),J()],us=[J(),J(),J(),J()],Ss=[{coord:new ns(0,0),height:0},{coord:new ns(0,0),height:0}],Cs=(Hs,Ws)=>Hs>Ws;for(let Hs=E.min;HsFe.featureInfo.featureIndex-Qe.featureInfo.featureIndex;this.sortSubarray(C,E.min,E.max,U),this.sortSubarray(C,L.min,L.max,U);const K=Fe=>ke(Fe,Fe),te=[{coord:new ns(0,0),height:0},{coord:new ns(0,0),height:0}],se=(Fe,Qe)=>FeR.hash===U.hash?U.polygonIdx-R.polygonIdx:U.hash>R.hash?1:-1);let b=0,C=0,E=0,L=p[b].polygonIdx;do C++,(C===p.length||p[b].hash!==p[C].hash)&&((C-b==1||p[C-1].polygonIdx!==L)&&(EK.portalHashte.hash?R++:te.hash>K.portalHash?U++:(K.type=te.type,R++)}}}isOnBorder(d,p){return d<=0&&p<=0||d>=sr&&p>=sr}addFeatureSection(d,p,b,C){return d!==p&&(p=d,b.push({featureIndex:d,vertexStart:C.getVertexCount()}),C.clearVertexLookup()),p}sortSubarray(d,p,b,C){const E=d.slice(p,b);E.sort(C),d.splice(p,E.length,...E)}static computeEdgeHash(d,p){return(d.y===p.y&&d.x>p.x||d.y>p.y)&&([d,p]=[p,d]),BigInt(ym.computePosHash(d))<<32n|BigInt(ym.computePosHash(p))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var lCe,cCe={exports:{}},dCe=(lCe||(lCe=1,function(x){function d(bt,St){return bt>St?1:bt0){var Ur=Gs+Math.floor(mr/2),Kr={key:St[Ur],data:ms[Ur],parent:bt};return Kr.left=C(Kr,St,ms,Gs,Ur),Kr.right=C(Kr,St,ms,Ur+1,hr),Kr}return null}function E(bt,St,ms,Gs,hr){if(!(ms>=Gs)){for(var mr=bt[ms+Gs>>1],Ur=ms-1,Kr=Gs+1;;){do Ur++;while(hr(bt[Ur],mr)<0);do Kr--;while(hr(bt[Kr],mr)>0);if(Ur>=Kr)break;var zn=bt[Ur];bt[Ur]=bt[Kr],bt[Kr]=zn,zn=St[Ur],St[Ur]=St[Kr],St[Kr]=zn}E(bt,St,ms,Kr,hr),E(bt,St,Kr+1,Gs,hr)}}p.prototype.rotateLeft=function(bt){var St=bt.right;St&&(bt.right=St.left,St.left&&(St.left.parent=bt),St.parent=bt.parent),bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.left=bt),bt.parent=St},p.prototype.rotateRight=function(bt){var St=bt.left;St&&(bt.left=St.right,St.right&&(St.right.parent=bt),St.parent=bt.parent),bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.right=bt),bt.parent=St},p.prototype._splay=function(bt){for(;bt.parent;){var St=bt.parent;St.parent?St.left===bt&&St.parent.left===St?(this.rotateRight(St.parent),this.rotateRight(St)):St.right===bt&&St.parent.right===St?(this.rotateLeft(St.parent),this.rotateLeft(St)):St.left===bt&&St.parent.right===St?(this.rotateRight(St),this.rotateLeft(St)):(this.rotateLeft(St),this.rotateRight(St)):St.left===bt?this.rotateRight(St):this.rotateLeft(St)}},p.prototype.splay=function(bt){for(var St,ms,Gs,hr,mr;bt.parent;)(ms=(St=bt.parent).parent)&&ms.parent?((Gs=ms.parent).left===ms?Gs.left=bt:Gs.right=bt,bt.parent=Gs):(bt.parent=null,this._root=bt),hr=bt.left,mr=bt.right,bt===St.left?(ms&&(ms.left===St?(St.right?(ms.left=St.right,ms.left.parent=ms):ms.left=null,St.right=ms,ms.parent=St):(hr?(ms.right=hr,hr.parent=ms):ms.right=null,bt.left=ms,ms.parent=bt)),mr?(St.left=mr,mr.parent=St):St.left=null,bt.right=St,St.parent=bt):(ms&&(ms.right===St?(St.left?(ms.right=St.left,ms.right.parent=ms):ms.right=null,St.left=ms,ms.parent=St):(mr?(ms.left=mr,mr.parent=ms):ms.left=null,bt.right=ms,ms.parent=bt)),hr?(St.right=hr,hr.parent=St):St.right=null,bt.left=St,St.parent=bt)},p.prototype.replace=function(bt,St){bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.parent=bt.parent)},p.prototype.minNode=function(bt){if(bt===void 0&&(bt=this._root),bt)for(;bt.left;)bt=bt.left;return bt},p.prototype.maxNode=function(bt){if(bt===void 0&&(bt=this._root),bt)for(;bt.right;)bt=bt.right;return bt},p.prototype.insert=function(bt,St){var ms=this._root,Gs=null,hr=this._compare;if(this._noDuplicates)for(;ms;){if(Gs=ms,hr(ms.key,bt)===0)return;ms=hr(ms.key,bt)<0?ms.right:ms.left}else for(;ms;)Gs=ms,ms=hr(ms.key,bt)<0?ms.right:ms.left;return ms={key:bt,data:St,left:null,right:null,parent:Gs},Gs?hr(Gs.key,ms.key)<0?Gs.right=ms:Gs.left=ms:this._root=ms,this.splay(ms),this._size++,ms},p.prototype.find=function(bt){for(var St=this._root,ms=this._compare;St;){var Gs=ms(St.key,bt);if(Gs<0)St=St.right;else{if(!(Gs>0))return St;St=St.left}}return null},p.prototype.contains=function(bt){for(var St=this._root,ms=this._compare;St;){var Gs=ms(bt,St.key);if(Gs===0)return!0;St=Gs<0?St.left:St.right}return!1},p.prototype.remove=function(bt){var St=this.find(bt);if(!St)return!1;if(this.splay(St),St.left)if(St.right){var ms=this.minNode(St.right);ms.parent!==St&&(this.replace(ms,ms.right),ms.right=St.right,ms.right.parent=ms),this.replace(St,ms),ms.left=St.left,ms.left.parent=ms}else this.replace(St,St.left);else this.replace(St,St.right);return this._size--,!0},p.prototype.removeNode=function(bt){if(!bt)return!1;if(this.splay(bt),bt.left)if(bt.right){var St=this.minNode(bt.right);St.parent!==bt&&(this.replace(St,St.right),St.right=bt.right,St.right.parent=St),this.replace(bt,St),St.left=bt.left,St.left.parent=St}else this.replace(bt,bt.left);else this.replace(bt,bt.right);return this._size--,!0},p.prototype.erase=function(bt){var St=this.find(bt);if(St){this.splay(St);var ms=St.left,Gs=St.right,hr=null;ms&&(ms.parent=null,hr=this.maxNode(ms),this.splay(hr),this._root=hr),Gs&&(ms?hr.right=Gs:this._root=Gs,Gs.parent=hr),this._size--}},p.prototype.pop=function(){var bt=this._root,St=null;if(bt){for(;bt.left;)bt=bt.left;St={key:bt.key,data:bt.data},this.remove(bt.key)}return St},p.prototype.next=function(bt){var St=bt;if(St)if(St.right)for(St=St.right;St&&St.left;)St=St.left;else for(St=bt.parent;St&&St.right===bt;)bt=St,St=St.parent;return St},p.prototype.prev=function(bt){var St=bt;if(St)if(St.left)for(St=St.left;St&&St.right;)St=St.right;else for(St=bt.parent;St&&St.left===bt;)bt=St,St=St.parent;return St},p.prototype.forEach=function(bt){for(var St=this._root,ms=[],Gs=!1,hr=0;!Gs;)St?(ms.push(St),St=St.left):ms.length>0?(bt(St=ms.pop(),hr++),St=St.right):Gs=!0;return this},p.prototype.range=function(bt,St,ms,Gs){for(var hr=[],mr=this._compare,Ur=this._root;hr.length!==0||Ur;)if(Ur)hr.push(Ur),Ur=Ur.left;else{if(mr((Ur=hr.pop()).key,St)>0)break;if(mr(Ur.key,bt)>=0&&ms.call(Gs,Ur))return this;Ur=Ur.right}return this},p.prototype.keys=function(){for(var bt=this._root,St=[],ms=[],Gs=!1;!Gs;)bt?(St.push(bt),bt=bt.left):St.length>0?(bt=St.pop(),ms.push(bt.key),bt=bt.right):Gs=!0;return ms},p.prototype.values=function(){for(var bt=this._root,St=[],ms=[],Gs=!1;!Gs;)bt?(St.push(bt),bt=bt.left):St.length>0?(bt=St.pop(),ms.push(bt.data),bt=bt.right):Gs=!0;return ms},p.prototype.at=function(bt){for(var St=this._root,ms=[],Gs=!1,hr=0;!Gs;)if(St)ms.push(St),St=St.left;else if(ms.length>0){if(St=ms.pop(),hr===bt)return St;hr++,St=St.right}else Gs=!0;return null},p.prototype.load=function(bt,St,ms){if(bt===void 0&&(bt=[]),St===void 0&&(St=[]),ms===void 0&&(ms=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Gs=bt.length;return ms&&E(bt,St,0,Gs-1,this._compare),this._root=C(null,bt,St,0,Gs),this._size=Gs,this},p.prototype.min=function(){var bt=this.minNode(this._root);return bt?bt.key:null},p.prototype.max=function(){var bt=this.maxNode(this._root);return bt?bt.key:null},p.prototype.isEmpty=function(){return this._root===null},b.size.get=function(){return this._size},p.createTree=function(bt,St,ms,Gs,hr){return new p(ms,hr).load(bt,St,Gs)},Object.defineProperties(p.prototype,b);var L=0,R=1,U=2,K=3,te=0,se=1,ie=2,de=3;function fe(bt,St,ms){St===null?(bt.inOut=!1,bt.otherInOut=!0):(bt.isSubject===St.isSubject?(bt.inOut=!St.inOut,bt.otherInOut=St.otherInOut):(bt.inOut=!St.otherInOut,bt.otherInOut=St.isVertical()?!St.inOut:St.inOut),St&&(bt.prevInResult=!Te(St,ms)||St.isVertical()?St.prevInResult:St));var Gs=Te(bt,ms);bt.resultTransition=Gs?function(hr,mr){var Ur,Kr=!hr.inOut,zn=!hr.otherInOut;switch(mr){case te:Ur=Kr&&zn;break;case se:Ur=Kr||zn;break;case de:Ur=Kr^zn;break;case ie:Ur=hr.isSubject?Kr&&!zn:zn&&!Kr}return Ur?1:-1}(bt,ms):0}function Te(bt,St){switch(bt.type){case L:switch(St){case te:return!bt.otherInOut;case se:return bt.otherInOut;case ie:return bt.isSubject&&bt.otherInOut||!bt.isSubject&&!bt.otherInOut;case de:return!0}break;case U:return St===te||St===se;case K:return St===ie;case R:return!1}return!1}var ze=function(bt,St,ms,Gs,hr){this.left=St,this.point=bt,this.otherEvent=ms,this.isSubject=Gs,this.type=hr||L,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Fe={inResult:{configurable:!0}};function Qe(bt,St){return bt[0]===St[0]&&bt[1]===St[1]}ze.prototype.isBelow=function(bt){var St=this.point,ms=this.otherEvent.point;return this.left?(St[0]-bt[0])*(ms[1]-bt[1])-(ms[0]-bt[0])*(St[1]-bt[1])>0:(ms[0]-bt[0])*(St[1]-bt[1])-(St[0]-bt[0])*(ms[1]-bt[1])>0},ze.prototype.isAbove=function(bt){return!this.isBelow(bt)},ze.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Fe.inResult.get=function(){return this.resultTransition!==0},ze.prototype.clone=function(){var bt=new ze(this.point,this.left,this.otherEvent,this.isSubject,this.type);return bt.contourId=this.contourId,bt.resultTransition=this.resultTransition,bt.prevInResult=this.prevInResult,bt.isExteriorRing=this.isExteriorRing,bt.inOut=this.inOut,bt.otherInOut=this.otherInOut,bt},Object.defineProperties(ze.prototype,Fe);var nt=11102230246251565e-32,ct=134217729,kt=(3+8*nt)*nt;function yt(bt,St,ms,Gs,hr){var mr,Ur,Kr,zn,Yn=St[0],ta=Gs[0],wa=0,un=0;ta>Yn==ta>-Yn?(mr=Yn,Yn=St[++wa]):(mr=ta,ta=Gs[++un]);var _n=0;if(waYn==ta>-Yn?(Kr=mr-((Ur=Yn+mr)-Yn),Yn=St[++wa]):(Kr=mr-((Ur=ta+mr)-ta),ta=Gs[++un]),mr=Ur,Kr!==0&&(hr[_n++]=Kr);waYn==ta>-Yn?(Kr=mr-((Ur=mr+Yn)-(zn=Ur-mr))+(Yn-zn),Yn=St[++wa]):(Kr=mr-((Ur=mr+ta)-(zn=Ur-mr))+(ta-zn),ta=Gs[++un]),mr=Ur,Kr!==0&&(hr[_n++]=Kr);for(;wa0!=wa>0)return un;var _n=Math.abs(ta+wa);return Math.abs(un)>=Rt*_n?un:-function(Za,ti,si,Ni,zi,Ii,li){var xi,Qn,Ea,go,on,ja,Di,Vi,Qi,al,Gi,ln,Co,ki,lo,Zl,Ic,kl,Sl=Za-zi,xc=si-zi,gh=ti-Ii,Wi=Ni-Ii;Gt[0]=(lo=(Vi=Sl-(Di=(ja=ct*Sl)-(ja-Sl)))*(al=Wi-(Qi=(ja=ct*Wi)-(ja-Wi)))-((ki=Sl*Wi)-Di*Qi-Vi*Qi-Di*al))-((Gi=lo-(Ic=(Vi=gh-(Di=(ja=ct*gh)-(ja-gh)))*(al=xc-(Qi=(ja=ct*xc)-(ja-xc)))-((Zl=gh*xc)-Di*Qi-Vi*Qi-Di*al)))+(on=lo-Gi))+(on-Ic),Gt[1]=(Co=ki-((ln=ki+Gi)-(on=ln-ki))+(Gi-on))-((Gi=Co-Zl)+(on=Co-Gi))+(on-Zl),Gt[2]=ln-((kl=ln+Gi)-(on=kl-ln))+(Gi-on),Gt[3]=kl;var Zo=function(qy,Pd){for(var Hu=Pd[0],bm=1;bm<4;bm++)Hu+=Pd[bm];return Hu}(0,Gt),il=Bt*li;if(Zo>=il||-Zo>=il||(xi=Za-(Sl+(on=Za-Sl))+(on-zi),Ea=si-(xc+(on=si-xc))+(on-zi),Qn=ti-(gh+(on=ti-gh))+(on-Ii),go=Ni-(Wi+(on=Ni-Wi))+(on-Ii),xi===0&&Qn===0&&Ea===0&&go===0)||(il=rs*li+kt*Math.abs(Zo),(Zo+=Sl*go+Wi*xi-(gh*Ea+xc*Qn))>=il||-Zo>=il))return Zo;Hs[0]=(lo=(Vi=xi-(Di=(ja=ct*xi)-(ja-xi)))*(al=Wi-(Qi=(ja=ct*Wi)-(ja-Wi)))-((ki=xi*Wi)-Di*Qi-Vi*Qi-Di*al))-((Gi=lo-(Ic=(Vi=Qn-(Di=(ja=ct*Qn)-(ja-Qn)))*(al=xc-(Qi=(ja=ct*xc)-(ja-xc)))-((Zl=Qn*xc)-Di*Qi-Vi*Qi-Di*al)))+(on=lo-Gi))+(on-Ic),Hs[1]=(Co=ki-((ln=ki+Gi)-(on=ln-ki))+(Gi-on))-((Gi=Co-Zl)+(on=Co-Gi))+(on-Zl),Hs[2]=ln-((kl=ln+Gi)-(on=kl-ln))+(Gi-on),Hs[3]=kl;var Bh=yt(4,Gt,4,Hs,us);Hs[0]=(lo=(Vi=Sl-(Di=(ja=ct*Sl)-(ja-Sl)))*(al=go-(Qi=(ja=ct*go)-(ja-go)))-((ki=Sl*go)-Di*Qi-Vi*Qi-Di*al))-((Gi=lo-(Ic=(Vi=gh-(Di=(ja=ct*gh)-(ja-gh)))*(al=Ea-(Qi=(ja=ct*Ea)-(ja-Ea)))-((Zl=gh*Ea)-Di*Qi-Vi*Qi-Di*al)))+(on=lo-Gi))+(on-Ic),Hs[1]=(Co=ki-((ln=ki+Gi)-(on=ln-ki))+(Gi-on))-((Gi=Co-Zl)+(on=Co-Gi))+(on-Zl),Hs[2]=ln-((kl=ln+Gi)-(on=kl-ln))+(Gi-on),Hs[3]=kl;var Yl=yt(Bh,us,4,Hs,Ss);Hs[0]=(lo=(Vi=xi-(Di=(ja=ct*xi)-(ja-xi)))*(al=go-(Qi=(ja=ct*go)-(ja-go)))-((ki=xi*go)-Di*Qi-Vi*Qi-Di*al))-((Gi=lo-(Ic=(Vi=Qn-(Di=(ja=ct*Qn)-(ja-Qn)))*(al=Ea-(Qi=(ja=ct*Ea)-(ja-Ea)))-((Zl=Qn*Ea)-Di*Qi-Vi*Qi-Di*al)))+(on=lo-Gi))+(on-Ic),Hs[1]=(Co=ki-((ln=ki+Gi)-(on=ln-ki))+(Gi-on))-((Gi=Co-Zl)+(on=Co-Gi))+(on-Zl),Hs[2]=ln-((kl=ln+Gi)-(on=kl-ln))+(Gi-on),Hs[3]=kl;var tx=yt(Yl,Ss,4,Hs,Cs);return Cs[tx-1]}(hr,mr,Ur,Kr,zn,Yn,_n)}(bt[0],bt[1],St[0],St[1],ms[0],ms[1]);return Gs>0?-1:Gs<0?1:0}function Bs(bt,St){var ms=bt.point,Gs=St.point;return ms[0]>Gs[0]?1:ms[0]Gs[1]?1:-1:function(hr,mr,Ur,Kr){return hr.left!==mr.left?hr.left?1:-1:Ws(Ur,hr.otherEvent.point,mr.otherEvent.point)!==0?hr.isBelow(mr.otherEvent.point)?-1:1:!hr.isSubject&&mr.isSubject?1:-1}(bt,St,ms)}function Us(bt,St,ms){var Gs=new ze(St,!1,bt,bt.isSubject),hr=new ze(St,!0,bt.otherEvent,bt.isSubject);return Qe(bt.point,bt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",bt),Gs.contourId=hr.contourId=bt.contourId,Bs(hr,bt.otherEvent)>0&&(bt.otherEvent.left=!0,hr.left=!1),bt.otherEvent.otherEvent=hr,bt.otherEvent=Gs,ms.push(hr),ms.push(Gs),ms}function cs(bt,St){return bt[0]*St[1]-bt[1]*St[0]}function as(bt,St){return bt[0]*St[0]+bt[1]*St[1]}function Vs(bt,St,ms){var Gs=function(zn,Yn,ta,wa,un){var _n=[Yn[0]-zn[0],Yn[1]-zn[1]],Za=[wa[0]-ta[0],wa[1]-ta[1]];function ti(ja,Di,Vi){return[ja[0]+Di*Vi[0],ja[1]+Di*Vi[1]]}var si=[ta[0]-zn[0],ta[1]-zn[1]],Ni=cs(_n,Za),zi=Ni*Ni,Ii=as(_n,_n);if(zi>0){var li=cs(si,Za)/Ni;if(li<0||li>1)return null;var xi=cs(si,_n)/Ni;return xi<0||xi>1?null:li===0||li===1?[ti(zn,li,_n)]:xi===0||xi===1?[ti(ta,xi,Za)]:[ti(zn,li,_n)]}if((zi=(Ni=cs(si,_n))*Ni)>0)return null;var Qn=as(_n,si)/Ii,Ea=Qn+as(_n,Za)/Ii,go=Math.min(Qn,Ea),on=Math.max(Qn,Ea);return go<=1&&on>=0?go===1?[ti(zn,go>0?go:0,_n)]:on===0?[ti(zn,on<1?on:1,_n)]:[ti(zn,go>0?go:0,_n),ti(zn,on<1?on:1,_n)]:null}(bt.point,bt.otherEvent.point,St.point,St.otherEvent.point),hr=Gs?Gs.length:0;if(hr===0||hr===1&&(Qe(bt.point,St.point)||Qe(bt.otherEvent.point,St.otherEvent.point))||hr===2&&bt.isSubject===St.isSubject)return 0;if(hr===1)return Qe(bt.point,Gs[0])||Qe(bt.otherEvent.point,Gs[0])||Us(bt,Gs[0],ms),Qe(St.point,Gs[0])||Qe(St.otherEvent.point,Gs[0])||Us(St,Gs[0],ms),1;var mr=[],Ur=!1,Kr=!1;return Qe(bt.point,St.point)?Ur=!0:Bs(bt,St)===1?mr.push(St,bt):mr.push(bt,St),Qe(bt.otherEvent.point,St.otherEvent.point)?Kr=!0:Bs(bt.otherEvent,St.otherEvent)===1?mr.push(St.otherEvent,bt.otherEvent):mr.push(bt.otherEvent,St.otherEvent),Ur&&Kr||Ur?(St.type=R,bt.type=St.inOut===bt.inOut?U:K,Ur&&!Kr&&Us(mr[1].otherEvent,mr[0].point,ms),2):Kr?(Us(mr[0],mr[1].point,ms),3):mr[0]!==mr[3].otherEvent?(Us(mr[0],mr[1].point,ms),Us(mr[1],mr[2].point,ms),3):(Us(mr[0],mr[1].point,ms),Us(mr[3].otherEvent,mr[2].point,ms),3)}function nr(bt,St){if(bt===St)return 0;if(Ws(bt.point,bt.otherEvent.point,St.point)!==0||Ws(bt.point,bt.otherEvent.point,St.otherEvent.point)!==0)return Qe(bt.point,St.point)?bt.isBelow(St.otherEvent.point)?-1:1:bt.point[0]===St.point[0]?bt.point[1]St.contourId?1:-1:Bs(bt,St)===1?1:-1}var Ys=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function $r(bt,St,ms,Gs){var hr,mr=bt+1,Ur=St[bt].point,Kr=St.length;for(mrGs;)mr--;return mr}Ys.prototype.isExterior=function(){return this.holeOf==null};var fr=Ir,jr=Ir;function Ir(bt,St){if(!(this instanceof Ir))return new Ir(bt,St);if(this.data=bt||[],this.length=this.data.length,this.compare=St||ra,this.length>0)for(var ms=(this.length>>1)-1;ms>=0;ms--)this._down(ms)}function ra(bt,St){return btSt?1:0}Ir.prototype={push:function(bt){this.data.push(bt),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var bt=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),bt}},peek:function(){return this.data[0]},_up:function(bt){for(var St=this.data,ms=this.compare,Gs=St[bt];bt>0;){var hr=bt-1>>1,mr=St[hr];if(ms(Gs,mr)>=0)break;St[bt]=mr,bt=hr}St[bt]=Gs},_down:function(bt){for(var St=this.data,ms=this.compare,Gs=this.length>>1,hr=St[bt];bt=0)break;St[bt]=Kr,bt=mr}St[bt]=hr}},fr.default=jr;var Qs=Math.max,Lr=Math.min,jn=0;function Ca(bt,St,ms,Gs,hr,mr){var Ur,Kr,zn,Yn,ta,wa;for(Ur=0,Kr=bt.length-1;Ur0?wa.left=!0:ta.left=!0;var un=zn[0],_n=zn[1];hr[0]=Lr(hr[0],un),hr[1]=Lr(hr[1],_n),hr[2]=Qs(hr[2],un),hr[3]=Qs(hr[3],_n),Gs.push(ta),Gs.push(wa)}}var Ia=[];function Hn(bt,St,ms){typeof bt[0][0][0]=="number"&&(bt=[bt]),typeof St[0][0][0]=="number"&&(St=[St]);var Gs=function(_n,Za,ti){var si=null;return _n.length*Za.length==0&&(ti===te?si=Ia:ti===ie?si=_n:ti!==se&&ti!==de||(si=_n.length===0?Za:_n)),si}(bt,St,ms);if(Gs)return Gs===Ia?null:Gs;var hr=[1/0,1/0,-1/0,-1/0],mr=[1/0,1/0,-1/0,-1/0],Ur=function(_n,Za,ti,si,Ni){var zi,Ii,li,xi,Qn,Ea,go=new fr(null,Bs);for(li=0,xi=_n.length;lisi[2]||si[0]>ti[2]||ti[1]>si[3]||si[1]>ti[3])&&(Ni===te?zi=Ia:Ni===ie?zi=_n:Ni!==se&&Ni!==de||(zi=_n.concat(Za))),zi}(bt,St,hr,mr,ms))return Gs===Ia?null:Gs;for(var Kr=function(_n){var Za,ti,si=function(li){var xi,Qn,Ea,go,on=[];for(Qn=0,Ea=li.length;Qn0){var Gi=ja[al];if(Gi.holeOf!=null){var ln=Gi.holeOf;ja[ln].holeIds.push(Di),Vi.holeOf=ln,Vi.depth=ja[al].depth}else ja[al].holeIds.push(Di),Vi.holeOf=al,Vi.depth=ja[al].depth+1}else Vi.holeOf=null,Vi.depth=ja[al].depth}else Vi.holeOf=null,Vi.depth=0;return Vi}(si[Za],zi,li),Qn=function(on){Ni[on]=!0,on=si.length)&&si[Ea];);zi.push(xi)}};for(Za=0,ti=si.length;Zago||zi===ie&&on.point[0]>si[2])break;if(on.left){li=Ii=Qn.insert(on),Ii=Ii!==(xi=Qn.minNode())?Qn.prev(Ii):null,li=Qn.next(li);var ja=Ii?Ii.key:null;if(fe(on,ja,zi),li&&Vs(on,li.key,_n)===2&&(fe(on,ja,zi),fe(li.key,on,zi)),Ii&&Vs(Ii.key,on,_n)===2){var Di=Ii;fe(ja,(Di=Di!==xi?Qn.prev(Di):null)?Di.key:null,zi),fe(on,ja,zi)}}else li=Ii=Qn.find(on=on.otherEvent),Ii&&li&&(Ii=Ii!==xi?Qn.prev(Ii):null,li=Qn.next(li),Qn.remove(on),li&&Ii&&Vs(Ii.key,li.key,_n))}return Ea}(Ur,0,0,hr,mr,ms)),zn=[],Yn=0;Yn * @license MIT * @preserve */function WF(x,d,p,b){const C=[],E=b===0?(L,R,U,K,te,se)=>{L.push(new ns(se,U+(se-R)/(K-R)*(te-U)))}:(L,R,U,K,te,se)=>{L.push(new ns(R+(se-U)/(te-U)*(K-R),se))};for(const L of x){const R=[];for(const U of L){if(U.length<=2)continue;const K=[];for(let ie=0;ied&&E(K,de,fe,Te,ze,d):Fe>p?Qe=d&&E(K,de,fe,Te,ze,d),Qe>p&&Fe<=p&&E(K,de,fe,Te,ze,p)}let te=U[U.length-1];const se=b===0?te.x:te.y;se>=d&&se<=p&&K.push(te),K.length&&(te=K[K.length-1],K[0].x===te.x&&K[0].y===te.y||K.push(K[0]),R.push(K))}R.length&&C.push(R)}return C}function Rdt(x,d){const p=Cpe(x),b=Cpe([d]),C=dCe.intersection(p,b);return C==null?[]:uCe(C)}function Fdt(x,d){let b=Cpe(x,65536);const C=[];for(;d.valid();d.next()){const[E,L]=d.get(),R=E.x*65536,U=E.y*65536,K=L.x*65536,te=L.y*65536,se=K-R,ie=te-U,de=Math.hypot(se,ie);if(de===0)continue;const fe=Math.trunc(ie/de*3),Te=-Math.trunc(se/de*3);C.push([[[R,U],[K,te],[K+fe,te+Te],[R+fe,U+Te],[R,U]]])}return C.length>0&&(b=dCe.diff(b,C)),uCe(b,1/65536)}function Cpe(x,d=1){return[x.map(p=>p.map(b=>[b.x*d,b.y*d]))]}function uCe(x,d=1){return x.map(p=>p.map((b,C)=>{const E=b.map(L=>new ns(L[0]*d,L[1]*d).round());return C>0&&E.reverse(),E}))}class Mpe{constructor(d,p){this.layoutVertexArray=new Dy,this.indexArray=new Gl,this.lineIndexArray=new xm,this.triangleSegments=new No,this.lineSegments=new No,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,p&&(this.elevatedLayoutVertexArray=new ug)}update(d,p,b,C,E,L,R,U){this.programConfigurations.updatePaintArrays(d,p,E,b,C,L,R,U)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,wdt.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,jdt.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,p,b,C,E,L,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,p,b,C,E,L,void 0,R)}}class Tpe{constructor(d){this.zoom=d.zoom,this.pixelRatio=d.pixelRatio,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(p=>p.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(p=>p.isStateDependent()).map(p=>p.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,p){}updateAppearances(d,p,b,C){}populate(d,p,b,C){this.hasPattern=kpe("fill",this.layers,this.pixelRatio,p);const E=this.layers[0].layout.get("fill-sort-key"),L=[];for(const{feature:R,id:U,index:K,sourceLayerIndex:te}of d){const se=this.layers[0]._featureFilter.needGeometry,ie=Ht(R,se);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),ie,b))continue;const de=E?E.evaluate(ie,{},b,p.availableImages):void 0,fe={id:U,properties:R.properties,type:R.type,sourceLayerIndex:te,index:K,geometry:se?ie.geometry:Dt(R,b,C),patterns:{},sortKey:de};L.push(fe)}E&&L.sort((R,U)=>R.sortKey-U.sortKey);for(const R of L){const{geometry:U,index:K,sourceLayerIndex:te}=R;if(this.hasPattern){const se=Spe("fill",this.layers,R,this.zoom,this.pixelRatio,p);this.patternFeatures.push(se)}else this.addFeature(R,U,K,b,{},p.availableImages,p.brightness,p.elevationFeatures);p.featureIndex.insert(d[K].feature,U,K,te,this.index)}}update(d,p,b,C,E,L,R){this.bufferData.update(d,p,b,C,E,L,R,this.worldview),this.elevationBufferData.update(d,p,b,C,E,L,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,p,b,C,E,L,R,this.worldview)}addFeatures(d,p,b,C,E,L){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,p,b,C,L,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,p,b,C,E,L=[],R,U){const K=hP(p,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,K,C,b,U):this.addGeometry(K,this.bufferData),this.bufferData.populatePaintArrays(d,b,E,L,C,R,this.worldview),this.elevationBufferData.populatePaintArrays(d,b,E,L,C,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,p,b,C,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(p,b,C,E,this.worldview))}addElevatedRoadFeature(d,p,b,C,E){const L=new Array,R=pi.getElevationFeature(d,E);if(!R)return void this.addGeometry(p,this.bufferData);{const K=this.clipPolygonsToTile(p,1);K.length>0&&L.push({polygons:K,elevationFeature:R,elevationTileID:b})}const U={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},b),featureIndex:C};for(const K of L)if(K.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new ym(K.elevationTileID,this.layers,this.zoom,this.lut));const se=K.elevationFeature.isTunnel();let ie=0;d.properties.hasOwnProperty(Jt)&&(ie=+d.properties[Jt]);for(const de of K.polygons)this.elevatedStructures.addPortalCandidates(K.elevationFeature.id,de,se,K.elevationFeature,ie)}K.elevationFeature.constantHeight==null&&(K.polygons=this.prepareElevatedPolygons(K.polygons,K.elevationFeature,K.elevationTileID));const te=new Ti(b,K.elevationTileID);this.addElevatedGeometry(K.polygons,te,K.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,C,U)}}addElevatedGeometry(d,p,b,C,E,L){const R={elevation:b,elevationSampler:p,bias:C,index:E,featureInfo:L},[U,K]=this.addGeometry(d,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:U,max:K}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,U),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,K))}addGeometry(d,p,b){let C=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,L=null;b&&(L=b.elevationSampler.constantElevation(b.elevation,b.bias),L!=null&&(C=L,E=L));const R=(U,K,te)=>{if(b!=null)if(K.push(U),L!=null)p.elevatedLayoutVertexArray.emplaceBack(L),te.push(L);else{const se=b.elevationSampler.pointElevation(U,b.elevation,b.bias);p.elevatedLayoutVertexArray.emplaceBack(se),te.push(se),C=Math.min(C,se),E=Math.max(E,se)}};for(const U of d){let K=0;for(const nt of U)K+=nt.length;const te=p.triangleSegments.prepareSegment(K,p.layoutVertexArray,p.indexArray),se=te.vertexLength,ie=[],de=[],fe=[],Te=[],ze=[],Fe=p.layoutVertexArray.length;for(const nt of U){if(nt.length===0)continue;nt!==U[0]&&de.push(ie.length/2);const ct=p.lineSegments.prepareSegment(nt.length,p.layoutVertexArray,p.lineIndexArray),kt=ct.vertexLength;b&&ze.push(p.layoutVertexArray.length-Fe),R(nt[0],fe,Te),p.layoutVertexArray.emplaceBack(nt[0].x,nt[0].y),p.lineIndexArray.emplaceBack(kt+nt.length-1,kt),ie.push(nt[0].x),ie.push(nt[0].y);for(let yt=1;yt0&&b&&this.elevationMode==="hd-road-base"){const nt=b.elevation.isTunnel(),ct=b.elevation.safeArea,kt=this.elevatedStructures.addVertices(fe,Te);this.elevatedStructures.addTriangles(Qe,kt,nt);const yt=ze.length;if(yt>0){for(let Mt=0;Mt=b&&de.max.x<=E&&de.min.y>=C&&de.max.y<=L?U:K).push(ie)}if(U.length===d.length)return d;const te=[new ns(b,C),new ns(E,C),new ns(E,L),new ns(b,L),new ns(b,C)],se=U;for(const ie of K)se.push(...Rdt(ie,te));return se}}let hCe,mCe,pCe,fCe;Cr(Tpe,"FillBucket",{omit:["layers","patternFeatures"]}),Cr(Mpe,"FillBufferData"),Cr(ym,"ElevatedStructures");class KF{constructor(d,p,b,C){if(this.triangleCount=p.length/3,this.min=new ns(0,0),this.max=new ns(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,L]=[d[0].clone(),d[0].clone()];for(let se=1;sese.cellIdx-ie.cellIdx||se.triIdx-ie.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 b=By(d.x-this.min.x,this.xScale,this.cellsX),C=By(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[C*this.cellsX+b];if(E){this._lazyInitLookup();for(let L=0;Lthis.max.x||this.min.x>p.x||d.y>this.max.y||this.min.y>p.y)return;this._lazyInitLookup();const C=By(d.x-this.min.x,this.xScale,this.cellsX),E=By(p.x-this.min.x,this.xScale,this.cellsX),L=By(d.y-this.min.y,this.yScale,this.cellsY),R=By(p.y-this.min.y,this.yScale,this.cellsY);for(let U=L;U<=R;U++)for(let K=C;K<=E;K++){const te=this.cells[U*this.cellsX+K];if(te)for(let se=0;sep.fqid),this.index=d.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.footprints=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,p){for(const b of this.footprints)p.push({footprint:b,id:d})}updateAppearances(d,p,b,C){}populate(d,p,b,C){const E=[];for(const{feature:L,id:R,index:U,sourceLayerIndex:K}of d){const te=this.layers[0]._featureFilter.needGeometry,se=Ht(L,te);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),se,b))continue;const ie={id:R,properties:L.properties,type:L.type,sourceLayerIndex:K,index:U,geometry:te?se.geometry:Dt(L,b,C),patterns:{}};E.push(ie)}for(const L of E){const{geometry:R,index:U,sourceLayerIndex:K}=L;this.addFeature(L,R,U,b,{},p.availableImages,p.brightness),p.featureIndex.insert(d[U].feature,R,U,K,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,p,b,C,E,L,R){}destroy(){}addFeature(d,p,b,C,E,L=[],R){for(const U of hP(p,2)){const K=[],te=[],se=[],ie=new ns(1/0,1/0),de=new ns(-1/0,-1/0);for(const ze of U)if(ze.length!==0){ze!==U[0]&&se.push(te.length/2);for(let Fe=0;FeL===C)===void 0}(b,x.clipScope)}function ZF(x,d){return x.x-d.x||x.y-d.y}function vCe(x,d){return ZF(x.min,d.min)===0&&ZF(x.max,d.max)===0}function Ape(x,d){return!(x.min.x>d.max.x||x.max.xd.max.y||x.max.ynew ns((U.x+E.x*sr)*R-L.x*sr,(U.y+E.y*sr)*R-L.y*sr))}return Epe(p,C,x.indices,0,x.indices.length,0,0)}function wCe(x,d,p,b){const C=Math.pow(2,b.z-p.z);return new ns((x+p.x*sr)*C-b.x*sr,(d+p.y*sr)*C-b.y*sr)}function jCe(x,d){const p=[];d.grid.queryPoint(x,p);const b=d.indices,C=d.vertices;for(let E=0;E0&&(b.length>1&&p.push(b),b=[])}return b.length>1&&p.push(b),p}const Ipe=Ut.types,Kdt=["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"],Zdt=["fill-extrusion-flood-light-ground-radius"],Ydt=Math.pow(2,13),Qdt=Math.pow(2,15)-1,kCe=new ns(0,1),Nv=2147483648,SCe=7,CCe=450;function pP(x,d,p,b,C,E,L,R){x.emplaceBack((d<<1)+L,(p<<1)+E,(Math.floor(b*Ydt)<<1)+C,Math.round(R))}function fP(x,d,p){x.emplaceBack(d.x*sr,d.y*sr,p?1:0)}function QF(x,d,p,b,C,E){x.emplaceBack(d.x,d.y,(p.x<<1)+b,(p.y<<1)+C,E)}function xP(x,d,p){x.emplaceBack(d.x,d.y,d.z,p[0]*16384,p[1]*16384,p[2]*16384)}class MCe{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class TCe{constructor(){this.centroidXY=new ns(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 ns(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ns(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new ns(this.max.x-this.min.x,this.max.y-this.min.y)}}class ACe{constructor(){this.acc=new ns(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(d,p){d.min.x===Number.MAX_VALUE&&(d.min.x=d.max.x=p.x,d.min.y=d.max.y=p.y)}appendEdge(d,p,b){this.accCount++,this.acc._add(p);let C=!!this.borders;p.xd.max.x&&(d.max.x=p.x,C=!0),p.yd.max.y&&(d.max.y=p.y,C=!0),((p.x===0||p.x===sr)&&p.x===b.x)!=((p.y===0||p.y===sr)&&p.y===b.y)&&this.processBorderOverlap(p,b),C&&this.checkBorderIntersection(p,b)}checkBorderIntersection(d,p){p.x<0!=d.x<0&&this.addBorderIntersection(0,Xr(p.y,d.y,(0-p.x)/(d.x-p.x))),p.x>sr!=d.x>sr&&this.addBorderIntersection(1,Xr(p.y,d.y,(sr-p.x)/(d.x-p.x))),p.y<0!=d.y<0&&this.addBorderIntersection(2,Xr(p.x,d.x,(0-p.y)/(d.y-p.y))),p.y>sr!=d.y>sr&&this.addBorderIntersection(3,Xr(p.x,d.x,(sr-p.y)/(d.y-p.y)))}addBorderIntersection(d,p){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 b=this.borders[d];pb[1]&&(b[1]=p)}processBorderOverlap(d,p){if(d.x===p.x){if(d.y===p.y)return;const b=d.x===0?0:1;this.addBorderIntersection(b,p.y),this.addBorderIntersection(b,d.y)}else{const b=d.y===0?2:3;this.addBorderIntersection(b,p.x),this.addBorderIntersection(b,d.x)}}centroid(){return this.accCount===0?new ns(0,0):new ns(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,p)=>d+ +(p[0]!==Number.MAX_VALUE),0):0}}function ECe(x,d){const p=x.add(d)._unit(),b=je(x.x*p.x+x.y*p.y,-1,1);var C,E,L;return C=Math.acos(b),Math.min(4,Math.max(-4,Math.tan(C)))/4*Qdt*((E=x).x*(L=d).y-E.y*L.x<0?-1:1)}const Xdt=[x=>x.x<0,x=>x.x>sr,x=>x.y<0,x=>x.y>sr];function Jdt(x,d,p,b){const C=[4];if(b===0)return C;p._mult(b);const E=x.sub(p),L=d.sub(p),R=[x,d,E,L];for(let U=0;U<4;U++)for(const K of R)if(Xdt[U](K)){C.push(U);break}return C}class Lpe{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new q6,this.indexArray=new Gl,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut},p=>Zdt.includes(p)),this._segments=new No,this.hiddenByLandmarkVertexArray=new HC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new No}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,p,b,C=!1){const E=d.length;if(E>2){let L=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[L].length);let U;L!==this._segments.get().length-1&&(L++,this._segmentToGroundQuads[L]=[],this._segmentToRegionTriCounts[L]=[0,0,0,0,0]);{const K=d[0],te=d[1];U=ECe(K.sub(d[E-1])._perp()._unit(),te.sub(K)._perp()._unit())}for(let K=0;KC.region-E.region);for(let b=0;bU+K,0);let R=0;for(let U=0;U<=4;U++){const K=L[U];if(K!==0){let te=this.regionSegments[U];te||(te=this.regionSegments[U]=new No);const se={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+R,vertexLength:E.vertexLength,primitiveLength:K};te.get().push(se)}R+=K}for(let U=0;U0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,Vdt.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 p=this.regionSegments[d];p&&p.destroy()}}}}class XF{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(p=>p.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 Gl,this.footprintVertices=new Dy,this.footprintSegments=[],this.layoutVertexArray=new wb,this.centroidVertexArray=new zF,this.wallVertexArray=new j2,this.indexArray=new Gl,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut},p=>Kdt.includes(p)),this.segments=new No,this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.groundEffect=new Lpe(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,p){}updateAppearances(d,p,b,C){}populate(d,p,b,C){this.features=[],this.hasPattern=kpe("fill-extrusion",this.layers,this.pixelRatio,p),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(b),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:L,index:R,sourceLayerIndex:U}of d){const K=this.layers[0]._featureFilter.needGeometry,te=Ht(E,K);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),te,b))continue;const se={id:L,sourceLayerIndex:U,index:R,geometry:K?te.geometry:Dt(E,b,C),properties:E.properties,type:E.type,patterns:{}},ie=this.layoutVertexArray.length,de=Ipe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:Spe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,p)});else if(this.wallMode)for(const fe of se.geometry)for(const Te of NCe(fe,de))this.addFeature(E.id,se,[Te],R,b,{},p.availableImages,C,p.brightness);else this.addFeature(E.id,se,se.geometry,R,b,{},p.availableImages,C,p.brightness);p.featureIndex.insert(E,se.geometry,R,U,this.index,ie)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,p,b,C,E,L){for(const{featureId:R,feature:U}of this.features){const K=Ipe[U.type]==="Polygon",{geometry:te}=U;if(this.wallMode)for(const se of te)for(const ie of NCe(se,K))this.addFeature(R,U,[ie],U.index,p,b,C,E,L);else this.addFeature(R,U,te,U.index,p,b,C,E,L)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,p,b,C,E,L,R){this.programConfigurations.updatePaintArrays(d,p,E,b,C,L,R,this.worldview),this.groundEffect.update(d,p,E,b,C,L,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,Gdt),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,Udt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,Hdt.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,qdt.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,p,b,C,E,L,R,U,K){const te=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(p,{})/this.tileToMeter,se=[new ns(0,0),new ns(sr,sr)],ie=U.projection,de=ie.name==="globe",fe=this.wallMode||Ipe[p.type]==="Polygon",Te=new ACe;Te.centroidDataIndex=this.centroidData.length;const ze=new TCe;ze.buildingId=d,p.properties&&p.properties.hasOwnProperty("building_id")&&(ze.buildingId=p.properties.building_id);const Fe=this.layers[0].paint.get("fill-extrusion-base").evaluate(p,{},E)<=0,Qe=this.layers[0].paint.get("fill-extrusion-height").evaluate(p,{},E);let nt;if(ze.height=Qe,ze.vertexArrayOffset=this.layoutVertexArray.length,ze.groundVertexArrayOffset=this.groundEffect.vertexArray.length,de&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new zC),this.wallMode){if(de)return void gr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(b.length!==1)return;nt=function(Gt){const us=Gt[0].x===Gt[Gt.length-1].x&&Gt[0].y===Gt[Gt.length-1].y;(function(jr){let Ir=0;const ra=jr.length;for(let Qs=0;Qs=0})(Gt)||(Gt=Gt.reverse());const Cs={geometry:[],joinNormals:[],indices:[]},Hs=[],Ws=[],Bs=[];let Us=Gt.length;for(;Us>=2&&Gt[Us-1].equals(Gt[Us-2]);)Us--;if(Us<(us?3:2))return Cs;let cs,as,Vs,nr,Ys,$r=0;for(;$r0;let jn="miter";const Ca=2;jn==="miter"&&Qs>Ca&&(jn="bevel"),jn==="bevel"&&(Qs>100&&(jn="flipbevel"),Qs{const ms=new ns(Hn.x,Hn.y),Gs=new ns(Hn.x,Hn.y);ms.x+=Pi.x*St,ms.y+=Pi.y*St,Gs.x-=Pi.x*Math.max(bt,1),Gs.y-=Pi.y*Math.max(bt,1),Bs.push(Pi),Hs.push(ms),Ws.push(Gs)};if(jn==="miter")Ir._mult(Qs),Ia(cs,Ir,0,0);else if(jn==="flipbevel")Ir=Ys.mult(-1),Ia(cs,Ir,0,0),Ia(cs,Ir.mult(-1),0,0);else{const Hn=-Math.sqrt(Qs*Qs-1),Pi=Lr?Hn:0,bt=Lr?0:Hn;as&&Ia(cs,nr,Pi,bt),Vs&&Ia(cs,Ys,Pi,bt)}}Cs.geometry=[...Hs,...Ws.reverse(),Hs[0]],Cs.joinNormals=[...Bs,...Bs.reverse(),Bs[Bs.length-1]];const fr=Cs.geometry.length-1;for(let jr=0;jrGt<(us.length-1)/2||Gt===us.length-1,kt=this.wallMode?[b]:hP(b,500);for(let Gt=kt.length-1;Gt>=0;Gt--){const us=kt[Gt];(us.length===0||(yt=us[0]).every(Ss=>Ss.x<=0)||yt.every(Ss=>Ss.x>=sr)||yt.every(Ss=>Ss.y<=0)||yt.every(Ss=>Ss.y>=sr))&&kt.splice(Gt,1)}var yt;let Mt;if(de)Mt=FCe(kt,se,E);else{Mt=[];for(const Gt of kt)Mt.push({polygon:Gt,bounds:se})}const Rt=fe?this.edgeRadius:0,Bt=Rt>0&&this.zoom<17,rs=(Gt,us)=>{if(Gt.length===0)return!1;const Ss=Gt[Gt.length-1];return us.x===Ss.x&&us.y===Ss.y};for(const{polygon:Gt,bounds:us}of Mt){let Ss=0,Cs=0;for(const Us of Gt)fe&&!Us[0].equals(Us[Us.length-1])&&Us.push(Us[0]),Cs+=fe?Us.length-1:Us.length;const Hs=this.segments.prepareSegment((fe?5:4)*Cs,this.layoutVertexArray,this.indexArray);ze.footprintSegIdx<0&&(ze.footprintSegIdx=this.footprintSegments.length),ze.polygonSegIdx<0&&(ze.polygonSegIdx=this.polygonSegments.length);const Ws={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Bs=new MCe;if(Bs.vertexOffset=this.footprintVertices.length,Bs.indexOffset=3*this.footprintIndices.length,Bs.ringIndices=[],fe){const Us=[],cs=[];Ss=Hs.vertexLength;for(let Vs=0;Vs4&&DCe(cs[cs.length-2],cs[0],cs[1]),Vs=Rt?eut(cs[cs.length-2],cs[0],cs[1],Rt):0;const nr=[];let Ys,$r,fr;$r=cs[1].sub(cs[0])._perp()._unit();let jr=!0;for(let Ir=1,ra=0;Ir0?1:0,Pi=Qs.dist(Lr);if(ra+Pi>32768&&(ra=0),Rt){fr=jn.sub(Lr)._perp()._unit();let Gs=ICe(Qs,Lr,jn,PCe($r,fr),Rt);isNaN(Gs)&&(Gs=0);const hr=Lr.sub(Qs)._unit();Qs=Qs.add(hr.mult(Vs))._round(),Lr=Lr.add(hr.mult(-Gs))._round(),Vs=Gs,$r=fr,Fe&&this.zoom>=17&&(rs(nr,Qs)||nr.push(Qs),rs(nr,Lr)||nr.push(Lr))}const bt=Hs.vertexLength,St=cs.length>4&&DCe(Qs,Lr,jn);let ms=OCe(ra,as,jr);if(pP(this.layoutVertexArray,Qs.x,Qs.y,Ia,Hn,0,0,ms),pP(this.layoutVertexArray,Qs.x,Qs.y,Ia,Hn,0,1,ms),this.wallMode){const Gs=ct(Ir-1,cs),hr=nt.joinNormals[Ir-1];fP(this.wallVertexArray,hr,Gs),fP(this.wallVertexArray,hr,Gs)}if(ra+=Pi,ms=OCe(ra,St,!jr),as=St,pP(this.layoutVertexArray,Lr.x,Lr.y,Ia,Hn,0,0,ms),pP(this.layoutVertexArray,Lr.x,Lr.y,Ia,Hn,0,1,ms),this.wallMode){const Gs=ct(Ir,cs),hr=nt.joinNormals[Ir];fP(this.wallVertexArray,hr,Gs),fP(this.wallVertexArray,hr,Gs)}if(Hs.vertexLength+=4,this.indexArray.emplaceBack(bt+0,bt+1,bt+2),this.indexArray.emplaceBack(bt+1,bt+3,bt+2),Hs.primitiveLength+=2,Rt){const Gs=Ss+(Ir===1?cs.length-2:Ir-2),hr=Ir===1?Ss:Gs+1;if(this.indexArray.emplaceBack(bt+1,Gs,bt+3),this.indexArray.emplaceBack(Gs,hr,bt+3),Hs.primitiveLength+=2,Ys===void 0&&(Ys=bt),!Dpe(jn,cs[Ir],us)){const mr=Ir===cs.length-1?Ys:Hs.vertexLength;this.indexArray.emplaceBack(bt+2,bt+3,mr),this.indexArray.emplaceBack(bt+3,mr+1,mr),this.indexArray.emplaceBack(bt+3,hr,mr+1),Hs.primitiveLength+=3}jr=!jr}if(de){const Gs=this.layoutVertexExtArray,hr=ie.projectTilePoint(Qs.x,Qs.y,E),mr=ie.projectTilePoint(Lr.x,Lr.y,E),Ur=ie.upVector(E,Qs.x,Qs.y),Kr=ie.upVector(E,Lr.x,Lr.y);xP(Gs,hr,Ur),xP(Gs,hr,Ur),xP(Gs,mr,Kr),xP(Gs,mr,Kr)}}fe&&(Ss+=cs.length-1),Fe&&Rt&&this.zoom>=17&&(nr.length!==0&&rs(nr,nr[0])&&nr.pop(),this.groundEffect.addData(nr,us,te,Rt>0))}this.footprintSegments.push(Bs),Ws.triangleCount=this.indexArray.length-Ws.triangleArrayOffset,this.polygonSegments.push(Ws),++ze.footprintSegLen,++ze.polygonSegLen}if(ze.vertexCount=this.layoutVertexArray.length-ze.vertexArrayOffset,ze.groundVertexCount=this.groundEffect.vertexArray.length-ze.groundVertexArrayOffset,ze.vertexCount!==0){if(ze.centroidXY=Te.borders?kCe:this.encodeCentroid(Te,ze),this.centroidData.push(ze),Te.borders){this.featuresOnBorder.push(Te);const Gt=this.featuresOnBorder.length-1;for(let us=0;usthis.featuresOnBorder[p].borders[d][0]-this.featuresOnBorder[b].borders[d][0])}splitToSubtiles(){const d=[];for(let R=0;Rsr),te=2*K+(+(U.min.x+U.max.x>sr)^K);for(let se=0;seR.triangleSegmentIdx===U.triangleSegmentIdx?R.subtile-U.subtile:R.triangleSegmentIdx-U.triangleSegmentIdx);let b=0,C=0,E=0;for(const R of d){if(R.triangleSegmentIdx!==b)break;E++}const L=d.length;for(;C!==d.length;){b=d[C].triangleSegmentIdx;let R=0,U=C,K=C;for(let te=U;te0&&this.triangleSubSegments.push({segment:de,min:se,max:ie}),U=K;for(let fe=U;fe[Te[0]*(1-Fe[0])+ze[0]*Fe[0],Te[1]*(1-Fe[1])+ze[1]*Fe[1]],de=[],fe=[];for(const Te of this.triangleSubSegments){de[0]=Te.min.x/sr,de[1]=Te.min.y/sr,fe[0]=Te.max.x/sr,fe[1]=Te.max.y/sr;const ze=ie(te,se,de),Fe=ie(te,se,fe);if(new Fr([ze[0],ze[1],E],[Fe[0],Fe[1],L]).intersectsPrecise(b)===0){K&&(C.segments.push(K),K=void 0);continue}const Qe=Te.segment;K&&K.vertexOffset!==Qe.vertexOffset&&(C.segments.push(K),K=void 0),K?(K.vertexLength+=Qe.vertexLength,K.primitiveLength+=Qe.primitiveLength):K={vertexOffset:Qe.vertexOffset,primitiveLength:Qe.primitiveLength,vertexLength:Qe.vertexLength,primitiveOffset:Qe.primitiveOffset,sortKey:void 0,vaos:{}}}return K&&C.segments.push(K),C}encodeCentroid(d,p){const b=d.centroid(),C=p.span(),E=Math.min(7,Math.round(C.x*this.tileToMeter/10)),L=Math.min(7,Math.round(C.y*this.tileToMeter/10));return new ns(je(b.x,1,sr-1)<<3|E,je(b.y,1,sr-1)<<3|L)}encodeBorderCentroid(d){if(!d.borders)return new ns(0,0);const p=d.borders,b=Number.MAX_VALUE;if(p[0][0]!==b||p[1][0]!==b){const C=p[0][0]!==b?0:1;return new ns(6|(p[0][0]!==b?0:65528),(p[C][0]+p[C][1])/2<<3|6)}{const C=p[2][0]!==b?2:3;return new ns((p[C][0]+p[C][1])/2<<3|6,6|(p[2][0]!==b?0:65528))}}showCentroid(d){const p=this.centroidData[d.centroidDataIndex];p.flags&=2147483647,p.centroidXY.x=0,p.centroidXY.y=0,this.writeCentroidToBuffer(p)}writeCentroidToBuffer(d){this.groundEffect.updateHiddenByLandmark(d);const p=d.vertexArrayOffset,b=d.vertexCount+d.vertexArrayOffset,C=d.flags&Nv?kCe:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(p);if(this.centroidVertexArray.geta_centroid_pos1(p)!==C.y||E!==C.x){for(let L=p;LU.max.x||U.min.x>L.max.x||L.min.y>U.max.y||U.min.y>L.max.y||L.footprint.buildingIds.has(U.buildingId)&&(U.flags|=Nv);else for(const U of this.centroidData)if(!(U.flags&Nv||L.min.x>U.max.x||U.min.x>L.max.x||L.min.y>U.max.y||U.min.y>L.max.y))for(let K=0;Kp!=de>p&&d<(this.footprintVertices.int16[2*(te+L.vertexOffset)+0]-se)*(p-ie)/(de-ie)+se&&(C=!C)}R=U}}return C}getHeightAtTileCoord(d,p){let b=Number.NEGATIVE_INFINITY,C=!0;const E=4*(d+sr)*sr+(p+sr);if(this.partLookup.hasOwnProperty(E)){const L=this.partLookup[E];return L?{height:L.height,hidden:!!(L.flags&Nv)}:void 0}for(const L of this.centroidData)d>L.max.x||L.min.x>d||p>L.max.y||L.min.y>p||L.height<=b||this.footprintContainsPoint(d,p,L)&&(b=L.height,this.partLookup[E]=L,C=!!(L.flags&Nv));if(b!==Number.NEGATIVE_INFINITY)return{height:b,hidden:C};this.partLookup[E]=void 0}}function PCe(x,d){const p=x.add(d)._unit();return x.x*p.x+x.y*p.y}function eut(x,d,p,b){const C=d.sub(x)._perp()._unit(),E=p.sub(d)._perp()._unit();return ICe(x,d,p,PCe(C,E),b)}function ICe(x,d,p,b,C){const E=Math.sqrt(1-b*b);return Math.min(x.dist(d)/3,d.dist(p)/3,C*E/b)}function Dpe(x,d,p){return x.xp[1].x&&d.x>p[1].x||x.yp[1].y&&d.y>p[1].y}function LCe(x,d){return x.xd[1].x||x.yd[1].y}function DCe(x,d,p){if(x.x<0||x.x>=sr||d.x<0||d.x>=sr||p.x<0||p.x>=sr)return!1;const b=p.sub(d),C=b.perp(),E=x.sub(d);return(b.x*E.x+b.y*E.y)/Math.sqrt((b.x*b.x+b.y*b.y)*(E.x*E.x+E.y*E.y))>-.866&&C.x*E.x+C.y*E.y<0}function OCe(x,d,p){const b=d?2|x:-3&x;return p?1|b:-2&b}function RCe(){const x=Math.PI/32,d=Math.tan(x),p=T;return p*Math.sqrt(1+2*d*d)-p}function FCe(x,d,p){const b=1<{for(const Rt of yt)fe.push({polygon:Rt,bounds:Mt})},ze=Math.ceil(Math.log2(te)),Fe=Math.ceil(Math.log2(se)),Qe=ze-Fe,nt=[];for(let yt=0;yt0?0:1);for(let yt=0;ytMt+1?kt.push({polygons:Cs,bounds:Ws,depth:Mt+1}):Te(Cs,Ws)}if(Hs.length){const Ws=[new ns(Rt===0?Ss:Bt.x,Rt===1?Ss:Bt.y),rs];nt.length>Mt+1?kt.push({polygons:Hs,bounds:Ws,depth:Mt+1}):Te(Hs,Ws)}}return fe}(x,d,Math.ceil((E-C)/11.25),Math.ceil((L-R)/11.25),1,(U,K,te)=>{if(U===0)return .5*(K+te);{const se=we((p.y+K/sr)/b);return(ee(.5*(we((p.y+te/sr)/b)+se))*b-p.y)*sr}})}function tut(x,d,p,b,C,E){const L=Math.pow(2,b.z-C.z);for(let R=0;R=U[L]&&(R=d,U=x),R[L]C&&qCe(R,U,L,C),R[L]E&&qCe(U,R,L,E)}}function JF(x,d,p,b,C,E){const L=[];for(let R=0;R=b&&fe.x>=b||(de.x>=b?de=new ns(b,de.y+(b-de.x)/(fe.x-de.x)*(fe.y-de.y))._round():fe.x>=b&&(fe=new ns(b,de.y+(b-de.x)/(fe.x-de.x)*(fe.y-de.y))._round()),de.y>=C&&fe.y>=C||(de.y>=C?de=new ns(de.x+(C-de.y)/(fe.y-de.y)*(fe.x-de.x),C)._round():fe.y>=C&&(fe=new ns(de.x+(C-de.y)/(fe.y-de.y)*(fe.x-de.x),C)._round()),K&&de.equals(K[K.length-1])||(K=[de],L.push(K),E&&E.push({progress:{min:ze+VCe(Fe,Qe,de)*Te,max:1},parentIndex:R,prevPoint:Fe,nextPoint:Qe})),K.push(fe),E&&(E[E.length-1].progress.max=ze+VCe(Fe,Qe,fe)*Te,E[E.length-1].nextPoint=Qe)))))}if(E&&se>0)for(let ie=te;ieK.t-te.t);let L=0,R=0,U=[];for(b.push(U);L!==x.length;){if(R===E.length){for(;L!==x.length;)U.length!==0&&U[U.length-1].equals(x[L])||U.push(x[L]),L++;break}E[R].t<=L?(U.length!==0&&U[U.length-1].equals(E[R].point)||U.push(E[R].point),Math.trunc(E[R].t),R++):(U.length!==0&&U[U.length-1].equals(x[L])||U.push(x[L]),L++)}}function VCe(x,d,p){return x.x!==d.x?(p.x-x.x)/(d.x-x.x):x.y!==d.y?(p.y-x.y)/(d.y-x.y):0}function gP(x,d){return x.x*d.x+x.y*d.y}function HCe(x,d){if(x.length===1){let p=0;const b=d[p++];let C;for(;!C||b.equals(C);)if(C=d[p++],!C)return 1/0;for(;p{Ss[0]=Cs,Ss[1]=Hs,Ss[2]=Ws,Ss[3]=1},us=RCe();de>0&&(de+=us),fe+=us;for(const Ss of ie){const Cs=[],Hs=[];for(const Ws of Ss){const Bs=Ws.x+Te.x,Us=Ws.y+Te.y,cs=se.projection.projectTilePoint(Bs,Us,kt),as=se.projection.upVector(kt,Ws.x,Ws.y);let Vs=de,nr=fe;if(Fe){const Ys=KCe(Bs,Us,de,fe,Fe,Qe,nt,ct);Vs+=Ys.base,nr+=Ys.top}de!==0?Gt(Bt,cs.x+as[0]*Rt*Vs,cs.y+as[1]*Rt*Vs,cs.z+as[2]*Rt*Vs):Gt(Bt,cs.x,cs.y,cs.z),Gt(rs,cs.x+as[0]*Rt*nr,cs.y+as[1]*Rt*nr,cs.z+as[2]*Rt*nr),dt(Bt,Bt,ze),dt(rs,rs,ze),Cs.push(new I2(Bt[0],Bt[1],Bt[2])),Hs.push(new I2(rs[0],rs[1],rs[2]))}yt.push(Cs),Mt.push(Hs)}return[yt,Mt]}(x,d,p,b,C,E,L,R,U,K,te):L?function(se,ie,de,fe,Te,ze,Fe,Qe,nt){const ct=[],kt=[],yt=[0,0,0,1];for(const Mt of se){const Rt=[],Bt=[];for(const rs of Mt){const Gt=rs.x+fe.x,us=rs.y+fe.y,Ss=KCe(Gt,us,ie,de,ze,Fe,Qe,nt);yt[0]=Gt,yt[1]=us,yt[2]=Ss.base,yt[3]=1,tt(yt,yt,Te),yt[3]=Math.max(yt[3],1e-5);const Cs=new I2(yt[0]/yt[3],yt[1]/yt[3],yt[2]/yt[3]);yt[0]=Gt,yt[1]=us,yt[2]=Ss.top,yt[3]=1,tt(yt,yt,Te),yt[3]=Math.max(yt[3],1e-5);const Hs=new I2(yt[0]/yt[3],yt[1]/yt[3],yt[2]/yt[3]);Rt.push(Cs),Bt.push(Hs)}ct.push(Rt),kt.push(Bt)}return[ct,kt]}(d,p,b,C,E,L,R,U,K):function(se,ie,de,fe,Te){const ze=[],Fe=[],Qe=Te[8]*ie,nt=Te[9]*ie,ct=Te[10]*ie,kt=Te[11]*ie,yt=Te[8]*de,Mt=Te[9]*de,Rt=Te[10]*de,Bt=Te[11]*de;for(const rs of se){const Gt=[],us=[];for(const Ss of rs){const Cs=Ss.x+fe.x,Hs=Ss.y+fe.y,Ws=Te[0]*Cs+Te[4]*Hs+Te[12],Bs=Te[1]*Cs+Te[5]*Hs+Te[13],Us=Te[2]*Cs+Te[6]*Hs+Te[14],cs=Te[3]*Cs+Te[7]*Hs+Te[15],as=Ws+Qe,Vs=Bs+nt,nr=Us+ct,Ys=Math.max(cs+kt,1e-5),$r=Ws+yt,fr=Bs+Mt,jr=Us+Rt,Ir=Math.max(cs+Bt,1e-5);Gt.push(new I2(as/Ys,Vs/Ys,nr/Ys)),us.push(new I2($r/Ir,fr/Ir,jr/Ir))}ze.push(Gt),Fe.push(us)}return[ze,Fe]}(d,p,b,C,E)}function KCe(x,d,p,b,C,E,L,R){const U=L*C.getElevationAt(x,d,!0,!0),K=E[0]!==0,te=K?E[1]===0?L*(E[0]/SCe-CCe):L*function(se,ie,de){const fe=Math.floor(ie[0]/8),Te=Math.floor(ie[1]/8),ze=10*(ie[0]-8*fe),Fe=10*(ie[1]-8*Te),Qe=se.getElevationAt(fe,Te,!0,!0),nt=se.getMeterToDEM(de),ct=Math.floor(.5*(ze*nt-1)),kt=Math.floor(.5*(Fe*nt-1)),yt=se.tileCoordToPixel(fe,Te),Mt=2*ct+1,Rt=2*kt+1,Bt=function(Hs,Ws,Bs,Us,cs){return[Hs.getElevationAtPixel(Ws,Bs,!0),Hs.getElevationAtPixel(Ws+cs,Bs,!0),Hs.getElevationAtPixel(Ws,Bs+cs,!0),Hs.getElevationAtPixel(Ws+Us,Bs+cs,!0)]}(se,yt.x-ct,yt.y-kt,Mt,Rt),rs=Math.abs(Bt[0]-Bt[1]),Gt=Math.abs(Bt[2]-Bt[3]),us=Math.abs(Bt[0]-Bt[2])+Math.abs(Bt[1]-Bt[3]),Ss=Math.min(.25,.5*nt*(rs+Gt)/Mt),Cs=Math.min(.25,.5*nt*us/Rt);return Qe+Math.max(Ss*ze,Cs*Fe)}(C,E,R):U;return{base:U+(p===0?-1:p),top:K?Math.max(te+b,U+p+2):U+b}}class rut{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 nut{constructor(){this.tasks={},this.taskQueue=[],qt(["process"],this),this.invoker=new rut(this.process),this.nextId=0}add(d,p){const b=this.nextId++,C=function({type:E,isSymbolTile:L,zoom:R}){return R=R||0,E==="message"?0:E!=="maybePrepare"||L?E!=="parseTile"||L?E==="parseTile"&&L?300-R:E==="maybePrepare"&&L?400-R:500:200-R:100-R}(p);if(C===0){try{d()}finally{}return null}return this.tasks[b]={fn:d,metadata:p,priority:C,id:b},this.taskQueue.push(b),this.invoker.trigger(),{cancel:()=>{delete this.tasks[b]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(b=>!!this.tasks[b]),!this.taskQueue.length)return;const d=this.pick();if(d===null)return;const p=this.tasks[d];if(delete this.tasks[d],this.taskQueue.length&&this.invoker.trigger(),!p)return;p.fn()}finally{}}pick(){let d=null,p=1/0;for(let C=0;C{b&&delete this.callbacks[R],this.target.postMessage({id:R,type:"",targetMapId:C,sourceMapId:this.mapId})}}}receive(d){const p=d.data;if(!p)return;const b=p.id;if(b&&(!p.targetMapId||this.mapId===p.targetMapId))if(p.type===""){const C=this.cancelCallbacks[b];delete this.cancelCallbacks[b],C&&C.cancel()}else if(p.mustQueue||ka(self)){const C=this.callbacks[b],E=this.scheduler.add(()=>this.processTask(b,p),C&&C.metadata||{type:"message"});E&&(this.cancelCallbacks[b]=E)}else this.processTask(b,p)}processTask(d,p){if(delete this.cancelCallbacks[d],p.type===""){const b=this.callbacks[d];delete this.callbacks[d],b&&(p.error?b(Ly(p.error)):b(null,Ly(p.data)))}else{const b=new Set,C=p.hasCallback?(L,R)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:L?og(L):null,data:og(R,b)},b)}:()=>{},E=Ly(p.data);if(this.parent[p.type])this.parent[p.type](p.sourceMapId,E,C);else if(this.parent.getWorkerSource){const L=p.type.split("."),{source:R,scope:U}=E;this.parent.getWorkerSource(p.sourceMapId,L[0],R,U)[L[1]](E,C)}else C(new Error(`Could not find function ${p.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var yP={workerUrl:"",workerClass:null,workerParams:void 0};const Ope="mapboxgl_preloaded_worker_pool";class L2{constructor(d){this.active={},this.name=d}acquire(d,p=L2.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{p.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ope]}numActive(){return Object.keys(this.active).length}}L2.workerCount=2;class a5{constructor(d,p,b="Worker",C=L2.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=Ot();const E=this.workerPool.acquire(this.id,C);for(let L=0;L{this.ready=!0})}broadcast(d,p,b){vt(this.actors,(C,E)=>{C.send(d,p,E)},b=b||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 vP,Rpe;function e7(){return vP||(vP=new L2),vP}a5.Actor=ZCe;const Fpe=4096;class aut{constructor(d){this.module=d,this.memoryStack=this.module.malloc(Fpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const p=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Fpe?-1:(new Int32Array(this.module.heap32.buffer,p,d.length).set(d),p)}createFloatArray(d){const p=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Fpe?-1:(new Float32Array(this.module.heapF32.buffer,p,d.length).set(d),p)}readStringBuffer(d){let p="";for(;this.module.heapU8[d]!==0;)p+=String.fromCharCode(this.module.heapU8[d]),++d;return p}setStyle(d){const p=d.normalScale;this.module.setStyle(p[0],p[1],p[2],d.tileToMeters)}setAOOptions(d,p){this.module.setAOOptions(d?1:0,p)}setMetricOptions(d,p){this.module.setMetricOptions(d?1:0,p)}setStructuralOptions(d){this.module.setStructuralOptions(d?1:0)}setFacadeOptions(d,p){this.module.setFacadeOptions(d,p?1:0)}setFauxFacadeOptions(d,p,b){this.module.setFauxFacadeOptions(d?1:0,p?1:0,b)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,p){this.memoryStackNextFree=this.memoryStack;for(const R of d){const U=this.createIntArray(R.ringIndices),K=this.createFloatArray(R.coordinates);if(U===-1||K===-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,K,U,R.ringIndices.length-1)}for(const R of p){let U;U=R.entrances?JSON.parse(R.entrances):[];const K=this.createFloatArray(U),te=this.createFloatArray(R.coordinates);if(K===-1||te===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,K,U.length,te,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const b=this.module.getMeshCount(),C=new Array(b);for(let R=0;RC.arrayBuffer()).then(C=>{d.buffers[p]=C})}function r5e(x,d){const p=x.json.bufferViews[d];return new Uint8Array(x.buffers[p.buffer],p.byteOffset||0,p.byteLength)}function uut(x,d,p,b){if(x.uri){const C=s5e(x.uri,b);return fetch(C).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[p]=E})}if(x.bufferView!==void 0){const C=r5e(d,x.bufferView),E=new Blob([C],{type:x.mimeType});return createImageBitmap(E).then(L=>{d.images[p]=L})}}function n5e(x,d=0,p){const b={json:null,images:[],buffers:[]};if(new Uint32Array(x,d,1)[0]===e5e){const te=new Uint32Array(x,d);let se=2;const ie=(te[se++]>>2)-3,de=te[se++]>>2;if(se++,b.json=JSON.parse(t5e.decode(te.subarray(se,se+de))),se+=de,se{const te=[],se=R&&R.includes($pe),ie=R&&R.includes(r7);if(se&&te.push(function(){if(!vg)return bP??(bP=function(de){let fe,Te=null;function ze(){fe=new Uint8Array(Te.buffer)}function Fe(){throw new Error("Unexpected Draco error.")}const Qe={a:{a:Fe,d:function(nt,ct,kt){return fe.copyWithin(nt,ct,ct+kt)},c:function(nt){const ct=fe.length,kt=Math.max(nt>>>0,Math.ceil(1.2*ct)),yt=Math.ceil((kt-ct)/65536);try{return Te.grow(yt),ze(),!0}catch{return!1}},b:Fe}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(de,Qe):de.then(nt=>nt.arrayBuffer()).then(nt=>WebAssembly.instantiate(nt,Qe))).then(nt=>{const{Rb:ct,Qb:kt,P:yt,T:Mt,X:Rt,Ja:Bt,La:rs,Qa:Gt,Va:us,Wa:Ss,eb:Cs,jb:Hs,f:Ws,e:Bs,yb:Us,zb:cs,Ab:as,Bb:Vs,Db:nr,Gb:Ys}=nt.instance.exports;Te=Bs;const $r=(()=>{let fr=0,jr=0,Ir=0,ra=0;return Qs=>{Ir&&(ct(ra),ct(fr),jr+=Ir,Ir=fr=0),fr||(jr+=128,fr=kt(jr));const Lr=Qs.length+7&-8;let jn=fr;Lr>=jr&&(Ir=Lr,jn=ra=kt(Lr));for(let Ca=0;Ca{vg=de,bP=void 0}))}()),ie&&te.push(function(){if(Bpe)return;const de=function(fe){let Te;const ze=WebAssembly.instantiateStreaming(fe,{}).then(nt=>{Te=nt.instance,Te.exports.__wasm_call_ctors()}),Fe={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Qe={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:ze,supported:!0,decodeGltfBuffer(nt,ct,kt,yt,Mt,Rt){(function(Bt,rs,Gt,us,Ss,Cs,Hs){const Ws=Bt.exports.sbrk,Bs=us+3&-4,Us=Ws(Bs*Ss),cs=Ws(Cs.length),as=new Uint8Array(Bt.exports.memory.buffer);as.set(Cs,cs);const Vs=rs(Us,us,Ss,cs,Cs.length);if(Vs===0&&Hs&&Hs(Us,Bs,Ss),Gt.set(as.subarray(Us,Us+us*Ss)),Ws(Us-Ws(0)),Vs!==0)throw new Error(`Malformed buffer data: ${Vs}`)})(Te,Te.exports[Qe[Mt]],nt,ct,kt,yt,Te.exports[Fe[Rt]])}}}(fetch(XCe()));return de.ready.then(()=>{Bpe=de})}()),E)for(let de=0;de{if(se&&L)for(const{primitives:de}of L)for(const fe of de)lut(fe,b);if(ie&&L&&U)for(const de of U)cut(de,b);return b})})}function a5e(x){return fetch(x).then(d=>d.arrayBuffer()).then(d=>n5e(d,0,x))}function qpe(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 Upe(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 Vpe{constructor(d,p,b,C){this.context=d,this.format=b,this.useMipmap=C&&C.useMipmap,this.texture=d.gl.createTexture(),this.update(p,{premultiply:C&&C.premultiply})}update(d,p){const b=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:L}=E,{x:R,y:U}=p&&p.position?p.position:{x:0,y:0},K=R+b,te=U+C;!this.size||this.size[0]===K&&this.size[1]===te||(L.bindTexture(L.TEXTURE_2D,null),L.deleteTexture(this.texture),this.texture=L.createTexture(),this.size=null),L.bindTexture(L.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===L.RGBA8&&(!p||p.premultiply!==!1));const se=d instanceof HTMLImageElement||d instanceof HTMLCanvasElement||d instanceof HTMLVideoElement||d instanceof ImageData||ImageBitmap&&d instanceof ImageBitmap;if(!this.size&&K>0&&te>0){const ie=this.useMipmap?Math.floor(Math.log2(Math.max(K,te)))+1:1;L.texStorage2D(L.TEXTURE_2D,ie,this.format,K,te),this.size=[K,te]}this.size&&(se?L.texSubImage2D(L.TEXTURE_2D,0,R,U,qpe(this.format),Upe(this.format),d):"data"in d&&d.data&&L.texSubImage2D(L.TEXTURE_2D,0,R,U,b,C,qpe(this.format),Upe(this.format),d.data)),this.useMipmap&&L.generateMipmap(L.TEXTURE_2D)}bind(d,p,b=!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&&!b?d===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),p!==this.wrapS&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,p),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,p),this.wrapS=p)}bindExtraParam(d,p,b,C,E){const{context:L}=this,{gl:R}=L;R.bindTexture(R.TEXTURE_2D,this.texture),p!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,p),this.magFilter=p),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),b!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,b),this.wrapS=b),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 wP{constructor(d,p){this.context=d,this.texture=p}bind(d,p){const{context:b}=this,{gl:C}=b;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),p!==this.wrapS&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_S,p),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_T,p),this.wrapS=p)}}const hut=_a([{name:"a_pos_3f",components:3,type:"Float32"}]),mut=_a([{name:"a_color_3f",components:3,type:"Float32"}]),put=_a([{name:"a_color_4f",components:4,type:"Float32"}]),fut=_a([{name:"a_uv_2f",components:2,type:"Float32"}]),xut=_a([{name:"a_normal_3f",components:3,type:"Float32"}]),gut=_a([{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"}]),yut=_a([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function i5e(x,d){const p=n7(x.projection,x.zoom,x.width,x.height),b=function(E,L,R,U,K){const te=new v(R.lng-180*Pb,R.lat),se=new v(R.lng+180*Pb,R.lat),ie=E.project(te.lng,te.lat),de=E.project(se.lng,se.lat),fe=-Math.atan2(de.y-ie.y,de.x-ie.x),Te=at.fromLngLat(R);Te.y=je(Te.y,-1+Pb,1-Pb);const ze=Te.toLngLat(),Fe=E.project(ze.lng,ze.lat),Qe=at.fromLngLat(ze);Qe.x+=Pb;const nt=Qe.toLngLat(),ct=E.project(nt.lng,nt.lat),kt=l5e(ct.x-Fe.x,ct.y-Fe.y,fe),yt=at.fromLngLat(ze);yt.y+=Pb;const Mt=yt.toLngLat(),Rt=E.project(Mt.lng,Mt.lat),Bt=l5e(Rt.x-Fe.x,Rt.y-Fe.y,fe),rs=Math.abs(kt.x)/Math.abs(Bt.y),Gt=j([]);q(Gt,Gt,-fe*(1-(K?0:U)));const us=j([]);return I(us,us,[1,1-(1-rs)*U,1]),us[4]=-Bt.x/Bt.y*U,q(us,us,fe),S(us,Gt,us),us}(x.projection,0,x.center,p,d),C=o5e(x);return I(b,b,[C,C,1]),b}function o5e(x){const d=x.projection,p=n7(x.projection,x.zoom,x.width,x.height),b=Hpe(d,x.center),C=Hpe(d,v.convert(d.center));return Math.pow(2,b*p+(1-p)*C)}function n7(x,d,p,b,C=1/0){const E=x.range;if(!E)return 0;const L=Math.min(C,Math.max(p,b)),R=Math.log2(L/1024);return $e(E[0]+R,E[1]+R,d)}const Pb=1/4e4;function Hpe(x,d){const p=je(d.lat,-Ne,Ne),b=new v(d.lng-180*Pb,p),C=new v(d.lng+180*Pb,p),E=x.project(b.lng,p),L=x.project(C.lng,p),R=at.fromLngLat(b),U=at.fromLngLat(C),K=L.x-E.x,te=L.y-E.y,se=U.x-R.x,ie=U.y-R.y,de=Math.sqrt((se*se+ie*ie)/(K*K+te*te));return Math.log2(de)}function l5e(x,d,p){const b=Math.cos(p),C=Math.sin(p);return{x:x*b-d*C,y:x*C+d*b}}function c5e(x,d,p){j(x),q(x,x,xr(d[2])),P(x,x,xr(d[0])),O(x,x,xr(d[1])),I(x,x,p),S(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function a7(x,d,p,b,C,E,L,R){const U=[p[0]-d[0],p[1]-d[1],0],K=[b[0]-d[0],b[1]-d[1],0];if(ce(U)<1e-12||ce(K)<1e-12)return rt(x);const te=qe([],U,K);ke(te,te),he(K,b,d),U[2]=(E-C)*R,K[2]=(L-C)*R;const se=U;return qe(se,U,K),ke(se,se),cr(x,te,se)}function i7(x,d,p=!1){const b=Ab(d.zoom),C=function(E,L,R){const U=L.worldSize,K=[E[12],E[13],E[14]],te=we(K[1]/U),se=le(K[0]/U),ie=j([]),de=ae(1,te)*U,fe=ae(1,0)*U*Ie(te,L.zoom),Te=1/bpe(U);let ze=fe*Te;if(R){const ct=n7(L.projection,L.zoom,L.width,L.height,1024);ze=Te*L.projection.pixelSpaceConversion(L.center.lat,U,ct)}const Fe=Cb(te,se);oe(Fe,Fe,_e([],ke([],Fe),de*ze*K[2]));const Qe=function(ct){const kt=[ct[0],ct[1],ct[2]];let yt=[0,1,0];const Mt=qe([],yt,kt);return qe(yt,kt,Mt),Ae(yt)===0&&(yt=[0,1,0],qe(Mt,kt,yt)),ke(Mt,Mt),ke(yt,yt),ke(kt,kt),[Mt[0],Mt[1],Mt[2],0,yt[0],yt[1],yt[2],0,kt[0],kt[1],kt[2],0,ct[0],ct[1],ct[2],1]}(Fe);I(ie,ie,[ze,ze,ze*de]),M(ie,ie,[-K[0],-K[1],-K[2]]);const nt=S([],L.globeMatrix,Qe);return S(nt,nt,ie),S(nt,nt,E),nt}(x,d,p);if(b>0){const E=function(L,R){const U=R.worldSize,K=ae(1,0)*U*Ie(R.center.lat,R.zoom)/bpe(U),te=ae(1,R.center.lat)*U,se=j([]);O(se,se,xr(R.center.lng)),P(se,se,xr(R.center.lat)),M(se,se,[0,0,Gd]),I(se,se,[K,K,K*te]);const ie=R.point;return M(se,se,[-ie.x,-ie.y,0]),S(se,se,L),S(se,R.globeMatrix,se)}(x,d);return function(L,R,U){const K=(fe,Te,ze)=>{const Fe=ce(fe),Qe=ce(Te),nt=yg(fe,Te,ze);return _e(nt,nt,1/ce(nt)*Xr(Fe,Qe,ze))},te=K([L[0],L[1],L[2]],[R[0],R[1],R[2]],U),se=K([L[4],L[5],L[6]],[R[4],R[5],R[6]],U),ie=K([L[8],L[9],L[10]],[R[8],R[9],R[10]],U),de=yg([L[12],L[13],L[14]],[R[12],R[13],R[14]],U);return[te[0],te[1],te[2],0,se[0],se[1],se[2],0,ie[0],ie[1],ie[2],0,de[0],de[1],de[2],1]}(C,E,b)}return C}function Gpe(x,d,p,b){const C=Fr.projectAabbCorners(b,p);let E=Number.MAX_VALUE;for(let R=0;R0||ze===0&&fe[0]*Te[0]+fe[1]*Te[1]>=0&&fe[0]*fe[0]+fe[1]*fe[1]>Te[0]*Te[0]+Te[1]*Te[1])&&(te=de)}se=te}while(se!==K);return U.length>0&&U.push(U[0]),U}(C);if(Xa(x,L))return E}const D2=64,c5={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function o7(x,d,p,b,C,E,L,R,U,K=!1){const te=p.zoom,se=p.project(b),ie=Ie(b.lat,te),de=1/ie;j(x),M(x,x,[se.x+L[0]*de,se.y+L[1]*de,L[2]]);let fe=1,Te=1;const ze=p.worldSize;if(K){if(p.projection.name==="mercator"){let ct=0;p.elevation&&(ct=p.elevation.getAtPointOrZero(new at(se.x/ze,se.y/ze),0));const kt=tt([],[se.x,se.y,ct,1],p.projMatrix)[3]/p.cameraToCenterDistance;fe=kt,Te=kt*Ie(p.center.lat,te)}else if(p.projection.name==="globe"){const ct=i7(x,p),kt=[0,0,0,1];tt(kt,kt,S([],p.projMatrix,ct));const yt=kt[3]/p.cameraToCenterDistance,Mt=Ab(te),Rt=p.projection.pixelsPerMeter(b.lat,ze)*Ie(b.lat,te),Bt=p.projection.pixelsPerMeter(p.center.lat,ze)*Ie(p.center.lat,te);fe=yt/Xr(Rt,Re(p.center.lat),Mt),Te=yt*ie/Rt,fe*=Bt,Te*=Bt}}else fe=de;I(x,x,[fe,fe,Te]);const Fe=[...x],Qe=d.orientation,nt=[];if(c5e(nt,[Qe[0]+(C?C[0]:0),Qe[1]+(C?C[1]:0),Qe[2]+(C?C[2]:0)],E),S(x,Fe,nt),R&&p.elevation){let ct=0;const kt=[];if(U&&p.elevation){ct=function(Mt,Rt,Bt,rs,Gt){const us=Rt.elevation;if(!us)return 0;const Ss=Fr.projectAabbCorners(Bt,rs),Cs=ae(1,Gt.lat)*Rt.worldSize,Hs=function(jr,Ir){const ra=[0,0,1],Qs=[{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 Lr of Qs){const jn=jr[Lr.corners[0]],Ca=jr[Lr.corners[1]],Ia=jr[Lr.corners[2]],Hn=[Ca[0]-jn[0],Ca[1]-jn[1],Ir*(Ca[2]-jn[2])],Pi=qe(Hn,Hn,[Ia[0]-jn[0],Ia[1]-jn[1],Ir*(Ia[2]-jn[2])]);ke(Pi,Pi),Lr.dotProductWithUp=Oe(Pi,ra)}return Qs.sort((Lr,jn)=>Lr.dotProductWithUp-jn.dotProductWithUp),Qs[0].corners}(Ss,Cs),Ws=Ss[Hs[0]],Bs=Ss[Hs[1]],Us=Ss[Hs[2]],cs=Ss[Hs[3]],as=us.getAtPointOrZero(new at(Ws[0]/Rt.worldSize,Ws[1]/Rt.worldSize),0),Vs=us.getAtPointOrZero(new at(Bs[0]/Rt.worldSize,Bs[1]/Rt.worldSize),0),nr=us.getAtPointOrZero(new at(Us[0]/Rt.worldSize,Us[1]/Rt.worldSize),0),Ys=us.getAtPointOrZero(new at(cs[0]/Rt.worldSize,cs[1]/Rt.worldSize),0),$r=(as+Ys)/2,fr=(Vs+nr)/2;return $r>fr?Vs=d.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function vut(x,d,p){x.indexBuffer=d.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=d.createVertexBuffer(x.vertexArray,hut.members,!1,!0),x.normalArray&&(x.normalBuffer=d.createVertexBuffer(x.normalArray,xut.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=d.createVertexBuffer(x.texcoordArray,fut.members,!1,!0)),x.colorArray&&(x.colorBuffer=d.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?mut:put).members,!1,!0)),x.featureArray&&(x.pbrBuffer=d.createVertexBuffer(x.featureArray,yut.members,!0)),x.segments=No.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const b=x.material;b.pbrMetallicRoughness.baseColorTexture&&jP(b.pbrMetallicRoughness.baseColorTexture,d),b.pbrMetallicRoughness.metallicRoughnessTexture&&jP(b.pbrMetallicRoughness.metallicRoughnessTexture,d),b.normalTexture&&jP(b.normalTexture,d),b.occlusionTexture&&jP(b.occlusionTexture,d,p),b.emissionTexture&&jP(b.emissionTexture,d)}function Wpe(x,d,p){if(x.meshes)for(const b of x.meshes)vut(b,d,p);if(x.children)for(const b of x.children)Wpe(b,d,p)}function l7(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)l7(d)}function Kpe(x){if(x.meshes)for(const p of x.meshes)p.vertexBuffer&&(p.vertexBuffer.destroy(),p.indexBuffer.destroy(),p.normalBuffer&&p.normalBuffer.destroy(),p.texcoordBuffer&&p.texcoordBuffer.destroy(),p.colorBuffer&&p.colorBuffer.destroy(),p.pbrBuffer&&p.pbrBuffer.destroy(),p.segments.destroy(),p.material&&((d=p.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 p of x.children)Kpe(p)}function O2(x,d){const p=x.json.bufferViews[d.bufferView],b=s7[d.componentType];return new b(x.buffers[p.buffer],(d.byteOffset||0)+(p.byteOffset||0),d.count*(p.byteStride&&p.byteStride!==_P[d.type]*b.BYTES_PER_ELEMENT?p.byteStride/b.BYTES_PER_ELEMENT:_P[d.type]))}function Zpe(x,d,p,b){const C=s7[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),L=x.json.bufferViews[d.bufferView],R=L.byteStride?L.byteStride/C.BYTES_PER_ELEMENT:_P[d.type],U=p.float32,K=U.length/p.capacity;for(let te=0,se=0;te0){for(let ze=0;ze0){E.texcoordArray=new Qf;const ie=d.json.accessors[C.TEXCOORD_0];E.texcoordArray.resize(ie.count);const de=O2(d,ie);Zpe(d,ie,E.texcoordArray,de)}if(C._FEATURE_ID_RGBA4444!==void 0){const ie=d.json.accessors[C._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=O2(d,ie))}C._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(O2(d,d.json.accessors[C._FEATURE_RGBA4444]).buffer));const se=x.material;return E.material=function(ie,de){const{emissiveFactor:fe=[0,0,0],alphaMode:Te="OPAQUE",alphaCutoff:ze=.5,normalTexture:Fe,occlusionTexture:Qe,emissiveTexture:nt,doubleSided:ct,name:kt}=ie,{baseColorFactor:yt=[1,1,1,1],metallicFactor:Mt=1,roughnessFactor:Rt=1,baseColorTexture:Bt,metallicRoughnessTexture:rs}=ie.pbrMetallicRoughness||{},Gt=Qe?de[Qe.index]:void 0;if(Qe&&Qe.extensions&&Qe.extensions.KHR_texture_transform&&Gt){const us=Qe.extensions.KHR_texture_transform;Gt.offsetScale=[us.offset[0],us.offset[1],us.scale[0],us.scale[1]]}return{name:kt,pbrMetallicRoughness:{baseColorFactor:new Wr(...yt),metallicFactor:Mt,roughnessFactor:Rt,baseColorTexture:Bt?de[Bt.index]:void 0,metallicRoughnessTexture:rs?de[rs.index]:void 0},doubleSided:ct,emissiveFactor:new Wr(...fe),alphaMode:Te,alphaCutoff:ze,normalTexture:Fe?de[Fe.index]:void 0,occlusionTexture:Gt,emissionTexture:nt?de[nt.index]:void 0,defined:ie.defined===void 0}}(se!==void 0?d.json.materials[se]:{defined:!1},p),E}function u5e(x,d,p){const{matrix:b,rotation:C,translation:E,scale:L,mesh:R,extras:U,children:K,name:te}=x,se={};if(se.name=te,se.localMatrix=b||function(ie,de,fe,Te){var ze=de[0],Fe=de[1],Qe=de[2],nt=de[3],ct=ze+ze,kt=Fe+Fe,yt=Qe+Qe,Mt=ze*ct,Rt=ze*kt,Bt=ze*yt,rs=Fe*kt,Gt=Fe*yt,us=Qe*yt,Ss=nt*ct,Cs=nt*kt,Hs=nt*yt,Ws=Te[0],Bs=Te[1],Us=Te[2];return ie[0]=(1-(rs+us))*Ws,ie[1]=(Rt+Hs)*Ws,ie[2]=(Bt-Cs)*Ws,ie[3]=0,ie[4]=(Rt-Hs)*Bs,ie[5]=(1-(Mt+us))*Bs,ie[6]=(Gt+Ss)*Bs,ie[7]=0,ie[8]=(Bt+Cs)*Us,ie[9]=(Gt-Ss)*Us,ie[10]=(1-(Mt+rs))*Us,ie[11]=0,ie[12]=fe[0],ie[13]=fe[1],ie[14]=fe[2],ie[15]=1,ie}([],C||[0,0,0,1],E||[0,0,0],L||[1,1,1]),se.globalMatrix=w(se.localMatrix),R!==void 0){se.meshes=p[R];const ie=se.anchor=[0,0];for(const de of se.meshes){const{min:fe,max:Te}=de.aabb;ie[0]+=fe[0]+Te[0],ie[1]+=fe[1]+Te[1]}ie[0]=Math.floor(ie[0]/se.meshes.length/2),ie[1]=Math.floor(ie[1]/se.meshes.length/2)}if(U&&(U.id&&(se.id=U.id),U.lights&&(se.lights=function(ie){if(!ie.length)return[];const de=function(Qe){const nt=atob(Qe),ct=new Uint8Array(nt.length);for(let kt=0;kt1&&b[b.length-1].equals(b[0])&&b.pop();let C=0;for(let L=0;L0&&b.reverse();const E=r5(b.flatMap(L=>[L.x,L.y]),[]);return E.length===0?null:{vertices:b,indices:E}}function jut(x,d){const p=[],b=[];let C=0;const E=[];for(const L of x){C=p.length;const R=L.vertexArray.float32,U=L.indexArray.uint16;for(let K=0;K0&&([b[L+1],b[L+2]]=[b[L+2],b[L+1]])}return{vertices:p,indices:b}}function Ype(x){const d=function(U,K){const te=[],se=WebGL2RenderingContext;if(U.json.textures)for(const ie of U.json.textures){const de={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};ie.sampler!==void 0&&Object.assign(de,U.json.samplers[ie.sampler]),te.push({image:K[ie.source],sampler:de,uploaded:!1})}return te}(x,x.images),p=function(U,K){const te=[];for(const se of U.json.meshes){const ie=[];for(const de of se.primitives)ie.push(but(de,U,K));te.push(ie)}return te}(x,d),{scenes:b,scene:C,nodes:E}=x.json,L=b?b[C||0].nodes:[...E.keys()],R=[];for(const U of L)R.push(u5e(E[U],x,p));return function(U,K,te){const se={},ie=new Set;for(let de=0;de0){const de=Array.from(ie.values()).sort((fe,Te)=>fe-Te);for(let fe=de.length-1;fe>=0;fe--)U.splice(de[fe],1)}}(R,L,x.json.nodes),R}function Nut(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const d=x.vertexArray.float32,p=x.aabb.min[0]-1,b=x.aabb.min[1]-1,C=D2/(x.aabb.max[0]-p+2),E=D2/(x.aabb.max[1]-b+2);for(let L=0;Lx.heightmap[K*D2+U]&&(x.heightmap[K*D2+U]=R)}}function h5e(x,d,p,b,C){p.reserve(p.length+4*x.length),b.reserve(b.length+10*x.length),C.reserve(C.length+10*x.length);let E=b.length;for(const L of x){const R=Math.min(10,Math.max(4,1.3*L.height))*d,U=[-L.normal[1],L.normal[0],0],K=Math.min(.29,.1*L.width/L.depth),te=L.width-2*L.depth*d*(K+.01),se=Be([],L.pos,U,te/2),ie=Be([],L.pos,U,-te/2),de=[se[0],se[1],se[2]+L.height],fe=[ie[0],ie[1],ie[2]+L.height],Te=Be([],L.normal,U,K);_e(Te,Te,R);const ze=Be([],L.normal,U,-K);_e(ze,ze,R),oe(Te,se,Te),oe(ze,ie,ze),se[2]+=.1,ie[2]+=.1,b.emplaceBack(Te[0],Te[1],Te[2]),b.emplaceBack(ze[0],ze[1],ze[2]),b.emplaceBack(se[0],se[1],se[2]),b.emplaceBack(ie[0],ie[1],ie[2]),b.emplaceBack(de[0],de[1],de[2]),b.emplaceBack(fe[0],fe[1],fe[2]),b.emplaceBack(se[0],se[1],se[2]),b.emplaceBack(ie[0],ie[1],ie[2]),b.emplaceBack(Te[0],Te[1],Te[2]),b.emplaceBack(ze[0],ze[1],ze[2]);const Fe=te/R/2;C.emplaceBack(-Fe-K,-1,Fe,.8),C.emplaceBack(Fe+K,-1,Fe,.8),C.emplaceBack(-Fe,0,Fe,1.3),C.emplaceBack(Fe,0,Fe,1.3),C.emplaceBack(Fe+K,-.8,Fe,.7),C.emplaceBack(Fe+K,-.8,Fe,.7),C.emplaceBack(0,0,Fe,1.3),C.emplaceBack(0,0,Fe,1.3),C.emplaceBack(Fe+K,-1.2,Fe,.8),C.emplaceBack(Fe+K,-1.2,Fe,.8),p.emplaceBack(6+E,4+E,8+E),p.emplaceBack(7+E,9+E,5+E),p.emplaceBack(0+E,1+E,2+E),p.emplaceBack(1+E,3+E,2+E),E+=10}}function kut(x,d){const p={};p.indexArray=new Gl,p.vertexArray=new fm,p.colorArray=new Oy,h5e(x,d,p.indexArray,p.vertexArray,p.colorArray);const b={defined:!0};b.emissiveFactor=Wr.black;const C={};return C.baseColorFactor=Wr.white,b.pbrMetallicRoughness=C,p.material=b,p.aabb=new Fr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),p}const m5e=_a([{name:"a_pos_3f",components:3,type:"Float32"}]),Sut=_a([{name:"a_normal_3",components:3,type:"Int16"}]),Cut=_a([{name:"a_centroid_3",components:3,type:"Int16"}]),p5e=_a([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Mut=_a([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Tut=_a([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Aut=_a([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Eut=_a([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Put=_a([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),f5e=Ut.types,c7=32767;function Iut(x,d){const p=sr+d;for(const b of x)for(const C of b)if(C.x<-d||C.x>p||C.y<-d||C.y>p)return!1;return!0}function Lut(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 Qpe{constructor(){this.layoutVertexArray=new fm,this.layoutAttenuationArray=new Oy,this.layoutColorArray=new xm,this.indexArray=new Gl,this.indexArrayForConflation=new Gl,this.segmentsBucket=new No}}class Xpe{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new No,this.entranceBloom=new Qpe;const p=66560;this.layoutVertexArray=new fm,this.layoutVertexArray.reserve(p),this.layoutNormalArray=new _b,this.layoutNormalArray.reserve(p),this.layoutCentroidArray=new _b,this.layoutCentroidArray.reserve(p),this.layoutColorArray=new xm,this.layoutColorArray.reserve(p),this.layoutFloodLightDataArray=new Ry,this.layoutFloodLightDataArray.reserve(p),this.layoutAOArray=new HC,this.layoutAOArray.reserve(p),this.indexArray=new Gl,this.indexArray.reserve(66560),this.indexArrayForConflation=new Gl,this.segmentsBucket=new No,this.entranceBloom=new Qpe,d&&(this.layoutFacadePaintArray=new xm,this.layoutFacadeDataArray=new bv,this.layoutFacadeVerticalRangeArray=new xm)}reserve(d,p,b){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(p),b&&(this.layoutFacadePaintArray.reserveForAdditional(d),this.layoutFacadeDataArray.reserveForAdditional(d),this.layoutFacadeVerticalRangeArray.reserveForAdditional(d))}}class x5e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Qf,this.footprintsIndices=new Ry,this.footprintsMin=new ns(1/0,1/0),this.footprintsMax=new ns(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Xpe(!1),this.buildingWithFacade=new Xpe(!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(p=>p.fqid),this.index=d.index,this.hasPattern=!1,this.worldview=d.worldview,this.lut=d.lut,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.projection=d.projection,this.groundEffect=new Lpe(d),this.groundEffect.groundRadiusArray=new ug,this.hasAppearances=null}updateFootprints(d,p){const b=new KF([],[],1),C={vertices:[],indices:new Uint32Array(0),grid:b,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};p.push({footprint:C,id:d})}updateAppearances(d,p,b,C){}prepare(){return function(){if(t7!=null||YCe!=null)return null;if(l5!=null)return l5;const d=fetch(ya.BUILDING_GEN_URL);return l5=function(p){let b,C,E,L,R;function U(){b=new Uint8Array(R.buffer),C=new Int16Array(R.buffer),E=new Int32Array(R.buffer),L=new Float32Array(R.buffer)}function K(){throw new Error("Unexpected BuildingGen error.")}const te=()=>{},se={a:{a:K,f:function(ie){const de=b.length,fe=Math.max(ie>>>0,Math.ceil(1.2*de)),Te=Math.ceil((fe-de)/65536);try{return R.grow(Te),U(),!0}catch{return!1}},g:K,b:te,c:te,d:te,e:te}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(p,se):p.then(ie=>ie.arrayBuffer()).then(ie=>WebAssembly.instantiate(ie,se))).then(ie=>{const de=ie.instance.exports;return(0,de.g)(),R=de.f,U(),new aut({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:b,heap16:C,heap32:E,heapF32:L})})}(d).then(p=>(l5=null,t7=p,t7)).catch(p=>{gr("Could not load building-gen"),l5=null,YCe=p}),l5}()}populate(d,p,b,C){const E=iut();if(!E)return;const L=Ve(b);this.tileToMeter=L,this.brightness=p.brightness,E.setStyle({normalScale:[1,-1,L],tileToMeters:L}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const R=new Map,U=new Map;let K=0;for(const{feature:Fe}of d){if(f5e[Fe.type]!=="LineString"){R.set(Fe.id,Fe.properties.source_id);continue}const Qe=this.layers[0]._featureFilter.needGeometry;if(Qe&&!this.layers[0]._featureFilter.filter(new Yi(this.zoom),Fe,b))continue;const nt=Ht(Fe,Qe);if(!Qe&&!this.layers[0]._featureFilter.filter(new Yi(this.zoom),nt,b))continue;const ct=Qe?nt.geometry:Dt(Fe,b,C),kt=[];for(const Bt of ct)for(const rs of Bt)kt.push(rs.x),kt.push(rs.y);const yt={coordinates:kt,crossPerc:Fe.properties.cross_perc,distanceToRoad:Fe.properties.distance_to_road,entrances:Fe.properties.entrances,sourceId:0},Mt=Fe.properties.source_id;let Rt=U.get(Mt);Rt||(Rt=[],U.set(Mt,Rt)),Rt.push(yt),++K}this.maxHeight=0;const te=new Array,se=new Set,ie=Fe=>{Fe!=null&&se.add(Fe)},de=(Fe,Qe)=>{Fe!=null&&te.push({buildingId:Fe,footprintIndex:Qe})},fe=64*(d.length-K),Te=fe/2;this.buildingWithFacade.reserve(fe,Te,!0),this.buildingWithoutFacade.reserve(2*fe,2*Te,!1),this.footprintsIndices.reserve(16*(d.length-K)),this.footprintsVertices.reserve(8*(d.length-K));for(const{feature:Fe,id:Qe,index:nt,sourceLayerIndex:ct}of d){if(f5e[Fe.type]==="LineString")continue;const kt=this.layers[0]._featureFilter.needGeometry;if(kt&&!this.layers[0]._featureFilter.filter(new Yi(this.zoom),Fe,b))continue;let yt=null;if(Fe.properties&&Fe.properties.hasOwnProperty("building_id")&&(yt=Fe.properties.building_id,se.has(yt)))continue;const Mt=Ht(Fe,kt);if(!kt&&!this.layers[0]._featureFilter.filter(new Yi(this.zoom),Mt,b))continue;const Rt=kt?Mt.geometry:Dt(Fe,b,C),Bt=hP(Rt,500);let rs=!1;for(const ln of Bt)if(ln.length!==1){rs=!0;break}if(rs){ie(yt);continue}if(!Iut(Rt,163)){ie(yt);continue}const Gt=this.layers[0],us=Lut(Gt.layout.get("building-roof-shape").evaluate(Fe,{},b)),Ss=Gt.layout.get("building-base").evaluate(Fe,{},b),Cs=Gt.layout.get("building-height").evaluate(Fe,{},b),Hs=Gt.layout.get("building-flood-light-ground-radius").evaluate(Fe,{},b),Ws=Gt.paint.get("building-ambient-occlusion-intensity"),Bs=Hs/this.tileToMeter;Fe.properties["building-part"]="roof";const Us=Gt.paint.get("building-color").evaluate(Fe,{},this.canonical).toPremultipliedRenderColor(this.lut),cs=Gt.paint.get("building-emissive-strength").evaluate(Fe,{},this.canonical);Fe.properties["building-part"]="wall";const as=Gt.paint.get("building-color").evaluate(Fe,{},this.canonical).toPremultipliedRenderColor(this.lut),Vs=Gt.paint.get("building-emissive-strength").evaluate(Fe,{},this.canonical);Fe.properties["building-part"]="window";const nr=Gt.paint.get("building-color").evaluate(Fe,{},this.canonical).toPremultipliedRenderColor(this.lut),Ys=Gt.paint.get("building-emissive-strength").evaluate(Fe,{},this.canonical);Fe.properties["building-part"]="door";const $r=Gt.paint.get("building-color").evaluate(Fe,{},this.canonical).toPremultipliedRenderColor(this.lut),fr=Gt.paint.get("building-emissive-strength").evaluate(Fe,{},this.canonical);let jr=Gt.layout.get("building-flood-light-wall-radius").evaluate(Fe,{},b);jr=je(jr,0,2048);const Ir=jr/2048*c7,ra=R.get(Qe),Qs=U.get(ra)||[],Lr=Qs.length!==0&&Gt.layout.get("building-facade").evaluate(Fe,{},b);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Lr,!1,1);let jn=0,Ca=0,Ia=0,Hn=0,Pi=0,bt=0,St=0,ms=0,Gs=0,hr=0,mr=0;if(Lr){let ln=Math.round(Gt.layout.get("building-facade-floors").evaluate(Fe,{},b));if(Ss===0){ln=Math.max(1,ln-(Qs.length>0?1:0));let ki=4;if(Cs>100){const lo=[10,13,15];ki=lo[Fe.id?Fe.id%lo.length:0]}else Cs<=10&&(ki=3);E.setFacadeOptions(ki,!0),Pi=(Cs<15?1.3:1.61803)*ki/L}else Pi=Ss/L;bt=Cs/L,Pi=Math.min(Pi,bt),Ia=Gt.layout.get("building-facade-unit-width").evaluate(Fe,{},b)/L,Hn=(bt-Pi)/ln,E.setFauxFacadeOptions(!0,!0,Ia);const Co=Gt.layout.get("building-facade-window").evaluate(Fe,{},b);jn=Co[0],Ca=Co[1],St=Math.floor(65535*Math.min(1,Pi/sr)),ms=Math.floor(65535*Math.min(1,bt/sr)),Gs=Math.floor(255*jn)<<8|Math.floor(255*Ca),hr=Math.floor(65535*Math.min(1,Ia/sr)),mr=Math.floor(65535*Math.min(1,Hn/sr))}const Ur=Array(Bt.length),Kr={x:1/0,y:1/0},zn={x:-1/0,y:-1/0},Yn={x:0,y:0};let ta=0;for(let ln=0;ln0){const ki=[],lo=Array(Co.length+1);lo[0]=0;for(let Zl=0;Zlsr||Kr.y<0||zn.y>sr)&&this.featuresOnBorder.push({featureId:Fe.id,footprintIndex:this.footprints.length});{const ln=r5(Di,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+ln.length),this.footprintsIndices.uint16.set(ln,on),this.buildingIds.add(yt??Fe.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Vi.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Vi.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Qi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Qi.y);const Co={footprintVertexOffset:ja,footprintVertexLength:this.footprintsVertices.length-ja,footprintIndexOffset:on,footprintIndexLength:this.footprintsIndices.length-on,min:Vi,max:Qi,hiddenFlags:0,indicesOffset:xi,indicesLength:go,bloomIndicesOffset:Ni,bloomIndicesLength:zi,groundEffectVertexOffset:al,groundEffectVertexLength:Gi,hasFauxFacade:Lr,height:Qn,promoteId:Qe,feature:Mt,parts:ti,buildingBloom:si},ki=this.footprints.length;Fe.id!==void 0&&this.featureFootprintLookup.set(Fe.id,ki),de(yt,ki),this.footprints.push(Co)}this.programConfigurations.populatePaintArrays(un.layoutVertexArray.length,Fe,nt,{},p.availableImages,b,p.brightness),this.groundEffect.addPaintPropertiesData(Fe,nt,{},p.availableImages,b,p.brightness),p.featureIndex.insert(Fe,Rt,nt,ct,this.index,Ii)}te.forEach(({buildingId:Fe,footprintIndex:Qe})=>{se.has(Fe)&&(this.footprints[Qe].hiddenFlags|=4)});const ze=new Set;this.buildingIds.forEach((Fe,Qe,nt)=>{se.has(Fe)||ze.add(Fe)}),this.buildingIds=ze,this.groundEffect.prepareBorderSegments()}update(d,p,b,C,E,L,R){this.programConfigurations.updatePaintArrays(d,p,E,b,C,L,R),this.groundEffect.update(d,p,E,b,C,L,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 p=b=>{b.layoutVertexBuffer=d.createVertexBuffer(b.layoutVertexArray,m5e.members),b.layoutNormalBuffer=d.createVertexBuffer(b.layoutNormalArray,Sut.members),b.layoutCentroidBuffer=d.createVertexBuffer(b.layoutCentroidArray,Cut.members),b.layoutFloodLightDataBuffer=d.createVertexBuffer(b.layoutFloodLightDataArray,Put.members),b.layoutFacadeDataArray&&b.layoutFacadeDataArray.length&&(b.layoutFacadeDataBuffer=d.createVertexBuffer(b.layoutFacadeDataArray,Tut.members)),b.layoutFacadeVerticalRangeArray&&b.layoutFacadeVerticalRangeArray.length&&(b.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(b.layoutFacadeVerticalRangeArray,Aut.members)),b.entranceBloom.layoutVertexArray.length&&(b.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(b.entranceBloom.layoutVertexArray,m5e.members),b.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(b.entranceBloom.layoutAttenuationArray,Eut.members)),this.uploadUpdatedColorBuffer(d),this.uploadUpdatedIndexBuffer(d)};this.uploaded||(p(this.buildingWithoutFacade),p(this.buildingWithFacade),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){const d=p=>{p.layoutVertexBuffer&&(p.layoutVertexBuffer.destroy(),p.layoutNormalBuffer.destroy(),p.layoutColorBuffer.destroy(),p.segmentsBucket.destroy(),p.indexBuffer&&p.indexBuffer.destroy(),p.entranceBloom.layoutVertexBuffer&&(p.entranceBloom.layoutVertexBuffer.destroy(),p.entranceBloom.layoutColorBuffer.destroy(),p.entranceBloom.layoutAttenuationBuffer.destroy(),p.entranceBloom.indexBuffer.destroy(),p.entranceBloom.segmentsBucket.destroy()))};d(this.buildingWithoutFacade),d(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(d,p,b=!0){let C=!1;const E=b?p:0,L=0|(b?-1:~p);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of d){const U=this.footprints[R],K=U.hiddenFlags&L|E;U.hiddenFlags!==K&&(U.hiddenFlags=K,C=!0,this.groundEffect.updateHiddenByLandmarkRange(U.groundEffectVertexOffset,U.groundEffectVertexLength,U.hiddenFlags!==0))}return C&&(this.indexArrayForConflationUploaded=!1),C}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const p=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))};p(this.buildingWithoutFacade),p(this.buildingWithFacade);for(const C of this.footprints){const E=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,L=C.indicesOffset+C.indicesLength;if(C.hiddenFlags!==0){for(let U=C.indicesOffset;U{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))};b(this.buildingWithoutFacade),b(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(d){const p=b=>{b.layoutColorBuffer?b.layoutColorBuffer.updateData(b.layoutColorArray):b.layoutColorBuffer=d.createVertexBuffer(b.layoutColorArray,p5e.members,!0),b.layoutFacadePaintArray&&(b.layoutFacadePaintBuffer?b.layoutFacadePaintBuffer.updateData(b.layoutFacadePaintArray):b.layoutFacadePaintBuffer=d.createVertexBuffer(b.layoutFacadePaintArray,Mut.members,!0)),b.entranceBloom.layoutColorBuffer?b.entranceBloom.layoutColorBuffer.updateData(b.entranceBloom.layoutColorArray):b.entranceBloom.layoutColorBuffer=d.createVertexBuffer(b.entranceBloom.layoutColorArray,p5e.members,!0)};p(this.buildingWithoutFacade),p(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(d,p){const b=d.paint.get("building-ambient-occlusion-intensity");for(const C of this.footprints){if(4&C.hiddenFlags)continue;const E=p[C.promoteId],L=C.feature;L.properties["building-part"]="roof";const R=d.paint.get("building-color").evaluate(L,E,this.canonical).toPremultipliedRenderColor(this.lut),U=d.paint.get("building-emissive-strength").evaluate(L,E,this.canonical);L.properties["building-part"]="wall";const K=d.paint.get("building-color").evaluate(L,E,this.canonical).toPremultipliedRenderColor(this.lut),te=d.paint.get("building-emissive-strength").evaluate(L,E,this.canonical);L.properties["building-part"]="window";const se=d.paint.get("building-color").evaluate(L,E,this.canonical).toPremultipliedRenderColor(this.lut),ie=d.paint.get("building-emissive-strength").evaluate(L,E,this.canonical);L.properties["building-part"]="door";const de=d.paint.get("building-color").evaluate(L,E,this.canonical).toPremultipliedRenderColor(this.lut),fe=d.paint.get("building-emissive-strength").evaluate(L,E,this.canonical),Te=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Fe of C.parts){let Qe,nt=R;Fe.part===1?(nt=R,Qe=U):Fe.part===0?(nt=K,Qe=te):Fe.part===2?(nt=se,Qe=ie):Fe.part===3&&(nt=de,Qe=fe),Qe=je(Qe,0,1);for(let ct=0;ctL.max.x||U.max.xL.max.y||U.max.yR.max.x||R.min.x>d||p>R.max.y||R.min.y>p||R.height<=b||Dut(L,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(b=R.height,this.footprintLookup[E]=R,C=R.hiddenFlags!==0);if(b!==Number.NEGATIVE_INFINITY)return{height:b,hidden:C};this.footprintLookup[E]=void 0}}function Dut(x,d,p){for(let b=0;b1&&(U=d[++R]);const te=Math.abs(K-U.left),se=Math.abs(K-U.right),ie=Math.min(te,se);let de;const fe=E/b*(C+1);if(U.isDash){const Te=C-Math.abs(fe);de=Math.sqrt(ie*ie+Te*Te)}else de=C-Math.sqrt(ie*ie+fe*fe);this.image.data[L+K]=Math.max(0,Math.min(255,de+128))}}}addRegularDash(d,p){for(let U=d.length-1;U>=0;--U){const K=d[U],te=d[U+1];K.zeroLength?d.splice(U,1):te&&te.isDash===K.isDash&&(te.left=K.left,d.splice(U,1))}const b=d[0],C=d[d.length-1];b.isDash===C.isDash&&(b.left=C.left-this.width,C.right=b.right+this.width);const E=this.width*this.nextRow;let L=0,R=d[L];for(let U=0;U1&&(R=d[++L]);const K=Math.abs(U-R.left),te=Math.abs(U-R.right),se=Math.min(K,te);this.image.data[E+U]=Math.max(0,Math.min(255,(R.isDash?se:-se)+p+128))}}addDash(d,p){const b=this.getKey(d,p);if(this.positions[b])return this.positions[b];const C=p==="round",E=C?7:0,L=2*E+1;if(this.nextRow+L>this.height)return gr("LineAtlas out of space"),null;d.length===0&&d.push(1);let R=0;for(let te=0;tep.fqid),this.index=d.index,this.projection=d.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(p=>{this.gradients[p.id]={}}),this.layoutVertexArray=new FC,this.layoutVertexArray2=new fm,this.patternVertexArray=new fm,this.indexArray=new Gl,this.programConfigurations=new Vp(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new No,this.maxLineLength=0,this.zOffsetVertexArray=new fm,this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.tessellationStep=d.tessellationStep?d.tessellationStep:sr/64,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,p){}updateAppearances(d,p,b,C){}populate(d,p,b,C){this.hasPattern=kpe("line",this.layers,this.pixelRatio,p);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ve(b);const L=this.layers[0].layout.get("line-elevation-reference");if(L==="hd-road-markup")this.elevationType="road";else{const ie=this.layers[0].layout.get("line-z-offset"),de=ie.isConstant()&&!ie.constantOr(0);this.elevationType=L!=="sea"&&L!=="ground"&&de?"none":"offset",this.elevationType==="offset"&&L==="none"&&gr(`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 U=[];for(const{feature:ie,id:de,index:fe,sourceLayerIndex:Te}of d){const ze=this.layers[0]._featureFilter.needGeometry,Fe=Ht(ie,ze);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),Fe,b))continue;const Qe=E?E.evaluate(Fe,{},b):void 0,nt={id:de,properties:ie.properties,type:ie.type,sourceLayerIndex:Te,index:fe,geometry:ze?Fe.geometry:Dt(ie,b,C),patterns:{},sortKey:Qe};U.push(nt)}E&&U.sort((ie,de)=>ie.sortKey-de.sortKey);const{lineAtlas:K,featureIndex:te}=p,se=this.addConstantDashes(K);for(const ie of U){const{geometry:de,index:fe,sourceLayerIndex:Te}=ie;if(se&&this.addFeatureDashes(ie,K),this.hasPattern){const ze=Spe("line",this.layers,ie,this.zoom,this.pixelRatio,p);this.patternFeatures.push(ze)}else this.addFeature(ie,de,fe,b,K.positions,p.availableImages,p.brightness,p.elevationFeatures);te.insert(d[fe].feature,de,fe,Te,this.index)}}addConstantDashes(d){let p=!1;for(const b of this.layers){const C=b.paint.get("line-dasharray").value,E=b.layout.get("line-cap").value;if(C.kind!=="constant"||E.kind!=="constant")p=!0;else{const L=E.value,R=C.value;if(!R)continue;d.addDash(R,L)}}return p}addFeatureDashes(d,p){const b=this.zoom;for(const C of this.layers){const E=C.paint.get("line-dasharray").value,L=C.layout.get("line-cap").value;if(E.kind==="constant"&&L.kind==="constant")continue;let R,U;if(E.kind==="constant"){if(R=E.value,!R)continue}else R=E.evaluate({zoom:b},d);U=L.kind==="constant"?L.value:L.evaluate({zoom:b},d),p.addDash(R,U),d.patterns[C.id]=[p.getKey(R,U)]}}update(d,p,b,C,E,L,R,U){this.programConfigurations.updatePaintArrays(d,p,E,b,C,L,R,U)}addFeatures(d,p,b,C,E,L){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,p,b,C,L,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,$ut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,Uut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Fut.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,zut),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,p){let b,C;if(p&&p>0?(b=`mapbox_clip_start_${p}`,C=`mapbox_clip_end_${p}`):(b="mapbox_clip_start",C="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(b)&&d.properties.hasOwnProperty(C))return{start:+d.properties[b],end:+d.properties[C]}}addFeature(d,p,b,C,E,L,R,U){const K=this.layers[0].layout,te=K.get("line-join").evaluate(d,{}),se=K.get("line-cap").evaluate(d,{}),ie=K.get("line-miter-limit"),de=K.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const fe=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=K.get("line-z-offset").value;const Te=this.layers[0].paint.get("line-width").value;if(Te.kind!=="constant"&&Te.isLineProgressConstant===!1&&(this.variableWidthValue=Te),this.elevationType==="road"){const ze=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,p,C,U,te,se,ie,de)){const[Fe,Qe]=this.clipRuntimeLinesToTile(p,1);for(let nt=0;nt0?kt.parentIndex:null)}this.fillNonElevatedRoadSegment(ze)}}else for(let ze=0;ze0?ze:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,b,E,L,C,R,void 0,this.worldview)}computeSegNextDir(d,p){return d.nextPoint.sub(p.at(-2)).unit()}computeSegPrevDir(d,p){return p[1].sub(d.prevPoint).unit()}clipLinesToTile(d,p){return JF(d,-p,-p,sr+p,sr+p)}clipRuntimeLinesToTile(d,p){const b=[];return[JF(d,-p,-p,sr+p,sr+p,b),b]}addElevatedRoadFeature(d,p,b,C,E,L,R,U){const K=[],te=pi.getElevationFeature(d,C);if(te){const se=this.clipLinesToTile(p,1),ie=this.prepareElevatedLines(se,te,b);for(const de of ie)K.push({geometry:de,elevation:te,elevationTileID:b,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(K.length===0)return!1;for(const se of K){const ie=this.layoutVertexArray.length;this.addLine(se.geometry,d,b,E,L,R,U);const de=new Ti(b,se.elevationTileID);if(se.elevation)for(let fe=ie;fe>1,this.layoutVertexArray.int16[6*fe+1]>>1),ze=de.pointElevation(Te,se.elevation,.05);this.updateHeightRange(ze),this.zOffsetVertexArray.emplaceBack(ze,0,0)}else this.fillNonElevatedRoadSegment(ie)}return!0}prepareElevatedLines(d,p,b){if(p.constantHeight!=null)return d;const C=[],E=1/Ve(b);for(const L of d)sut(L,new ei(p,E),0,C);return C}fillNonElevatedRoadSegment(d){for(let p=d;p0,ie=U&&U.progress.max<1;if(this.lineClips){let Bt={min:this.lineClips.start,max:this.lineClips.end},rs=1;if(U){const Ss=this.lineClips.end-this.lineClips.start;Bt=function(Cs,Hs,Ws){return{min:Ei(Cs.min,Hs,Ws),max:Ei(Cs.max,Hs,Ws)}}(U.progress,{min:0,max:1},Bt),Ss>0&&(rs=(Bt.max-Bt.min)/Ss)}const Gt=+p.properties.mapbox_clip_feature_len,us=+p.properties.mapbox_clip_seg_len;if(Number.isNaN(Gt)||Number.isNaN(us)){for(let Cs=0;Cs=2&&d[fe-1].equals(d[fe-2]);)fe--;let Te=0;for(;Te0,cs=this.overscaling<=16?15*sr/(512*this.overscaling):0;if(rs&&Gt==="round"){if(HsL&&(Gt="bevel"),Gt==="bevel"&&(Hs>2&&(Gt="flipbevel"),Hs2*cs){const nr=Fe.sub(Fe.sub(Qe)._mult(cs/as)._round());this.updateDistance(Qe,nr),this.addCurrentVertex(nr,ct,0,0,ze,Rt),Qe=nr}this.updateDistance(Qe,Fe),Ss._mult(Hs),this.addCurrentVertex(Fe,Ss,0,0,ze,Rt);const Vs=Fe.dist(nt);if(Vs>2*cs){const nr=Fe.add(nt.sub(Fe)._mult(cs/Vs)._round());this.updateDistance(Fe,nr),this.addCurrentVertex(nr,kt,0,0,ze,Rt),Fe=nr}}else Ss._mult(Hs),this.addCurrentVertex(Fe,Ss,0,0,ze,Rt);else if(Gt==="flipbevel"){if(Hs>100)Ss=kt.mult(-1);else{const as=Hs*ct.add(kt).mag()/ct.sub(kt).mag();Ss._perp()._mult(as*(Us?-1:1))}this.addCurrentVertex(Fe,Ss,0,0,ze,Rt),this.addCurrentVertex(Fe,Ss.mult(-1),0,0,ze,Rt)}else if(Gt==="bevel"||Gt==="fakeround"){Rt!=null&&Qe&&this.addCurrentVertex(Fe,Mt||ct,-1,-1,ze,Rt);const as=Fe.dist(Qe)<=2*cs&&Gt!=="bevel",Vs=Ss.mult(Us?1:-1);Vs._mult(Hs);const nr=kt.mult(Us?-1:1),Ys=ct.mult(Us?-1:1),$r=this.evaluateLineProgressFeatures(this.distance);if(Rt==null&&(this.addHalfVertex(Fe,Vs.x,Vs.y,!1,!Us,0,ze,$r),as||this.addHalfVertex(Fe,Vs.x+2*Ys.x,Vs.y+2*Ys.y,!1,Us,0,ze,$r)),Gt==="fakeround"){const fr=Math.round(180*Ws/Math.PI/20);this.addHalfVertex(Fe,Ys.x,Ys.y,!1,Us,0,ze,$r);for(let jr=0;jr1){this.lineSoFar=d.w;const Te=(p.x-d.x)/se,ze=(p.y-d.y)/se,Fe=(p.z-d.z)/se,Qe=(p.w-d.w)/se;for(let nt=1;nt=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,te),U.primitiveLength++),L?this.e2=te:this.e1=te,K!=null&&this.zOffsetVertexArray.emplaceBack(K.zOffset,K.variableWidth,K.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,p){this.prevDistance=this.distance,this.distance+=d.dist(p),this.updateScaledDistance()}}function efe(x,d,p){return x.xp||x.yp}let b5e,_5e;function w5e(x,d,p){return d*(sr/(x.tileSize*Math.pow(2,p-x.tileID.overscaledZ)))}Cr(Jpe,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const j5e=(x,d,p)=>(1-p)*x+p*d;function N5e(x,d){return 1/w5e(x,1,d.tileZoom)}function k5e(x,d,p,b){return x.translatePosMatrix(b||d.tileID.projMatrix,d,p.paint.get("line-translate"),p.paint.get("line-translate-anchor"))}const S5e=x=>{const d=[];C5e(x)&&d.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&d.push("RENDER_LINE_GRADIENT");const p=x.paint.get("line-trim-offset");p[0]===0&&p[1]===0||d.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&d.push("RENDER_LINE_BORDER");const b=x.layout.get("line-join").constantOr("miter")==="none",C=!!x.paint.get("line-pattern").constantOr(1);return b&&C&&d.push("LINE_JOIN_NONE"),d};function C5e(x){const d=x.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let tfe;const M5e=()=>tfe||(tfe={layout:b5e||(b5e=new Oo({"line-cap":new lr(Kt.layout_line["line-cap"]),"line-join":new lr(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 lr(Kt.layout_line["line-sort-key"]),"line-z-offset":new lr(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:_5e||(_5e=new Oo({"line-opacity":new lr(Kt.paint_line["line-opacity"]),"line-color":new lr(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 lr(Kt.paint_line["line-width"]),"line-gap-width":new lr(Kt.paint_line["line-gap-width"]),"line-offset":new lr(Kt.paint_line["line-offset"]),"line-blur":new lr(Kt.paint_line["line-blur"]),"line-dasharray":new lr(Kt.paint_line["line-dasharray"]),"line-pattern":new lr(Kt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Xs(Kt.paint_line["line-pattern-cross-fade"]),"line-gradient":new gv(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 lr(Kt.paint_line["line-emissive-strength"]),"line-border-width":new lr(Kt.paint_line["line-border-width"]),"line-border-color":new lr(Kt.paint_line["line-border-color"]),"line-occlusion-opacity":new Xs(Kt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"})}))},tfe);class Wut extends lr{possiblyEvaluate(d,p){return p=new Yi(Math.floor(p.zoom),{now:p.now,fadeDuration:p.fadeDuration,transition:p.transition,worldview:p.worldview}),super.possiblyEvaluate(d,p)}evaluate(d,p,b,C){return p=Object.assign({},p,{zoom:Math.floor(p.zoom)}),super.evaluate(d,p,b,C)}}let NP;function T5e(x,d){return d>0?d+2*x:x}const Kut=_a([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Zut=_a([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Yut=_a([{name:"a_projected_pos",components:4,type:"Float32"}],4);_a([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Qut=_a([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Xut=_a([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Jut=_a([{name:"a_texb",components:2,type:"Uint16"}]),eht=_a([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),tht=_a([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);_a([{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 A5e=_a([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),sht=_a([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);_a([{name:"triangle",components:3,type:"Uint16"}]),_a([{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"}]),_a([{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"}]),_a([{type:"Float32",name:"offsetX"}]),_a([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Pc=24;function rht(x,d,p){return x.sections.forEach(b=>{b.text=function(C,E,L){const R=E.layout.get("text-transform").evaluate(L,{});return R==="uppercase"?C=C.toLocaleUpperCase():R==="lowercase"&&(C=C.toLocaleLowerCase()),dg.applyArabicShaping&&(C=dg.applyArabicShaping(C)),C}(b.text,d,p)}),x}const kP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function nht(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function aht(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const sfe=4294967296,E5e=1/sfe,P5e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let d7=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,p=this.length){for(;this.pos>3,E=this.pos;this.type=7&b,x(C,d,this),this.pos===E&&this.skip(b)}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)*sfe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*sfe;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 p,b;return b=d[this.pos++],p=127&b,b<128?p:(b=d[this.pos++],p|=(127&b)<<7,b<128?p:(b=d[this.pos++],p|=(127&b)<<14,b<128?p:(b=d[this.pos++],p|=(127&b)<<21,b<128?p:(b=d[this.pos],p|=(15&b)<<28,function(C,E,L){const R=L.buf;let U,K;if(K=R[L.pos++],U=(112&K)>>4,K<128||(K=R[L.pos++],U|=(127&K)<<3,K<128)||(K=R[L.pos++],U|=(127&K)<<10,K<128)||(K=R[L.pos++],U|=(127&K)<<17,K<128)||(K=R[L.pos++],U|=(127&K)<<24,K<128)||(K=R[L.pos++],U|=(1&K)<<31,K<128))return d5(C,U,E);throw new Error("Expected varint not more than 10 bytes")}(p,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&&P5e?P5e.decode(this.buf.subarray(d,x)):function(p,b,C){let E="",L=b;for(;L239?4:R>223?3:R>191?2:1;if(L+ie>C)break;ie===1?R<128&&(se=R):ie===2?(U=p[L+1],(192&U)==128&&(se=(31&R)<<6|63&U,se<=127&&(se=null))):ie===3?(U=p[L+1],K=p[L+2],(192&U)==128&&(192&K)==128&&(se=(15&R)<<12|(63&U)<<6|63&K,(se<=2047||se>=55296&&se<=57343)&&(se=null))):ie===4&&(U=p[L+1],K=p[L+2],te=p[L+3],(192&U)==128&&(192&K)==128&&(192&te)==128&&(se=(15&R)<<18|(63&U)<<12|(63&K)<<6|63&te,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,ie=1):se>65535&&(se-=65536,E+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),E+=String.fromCharCode(se),L+=ie}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 p=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,p){let b,C;if(d>=0?(b=d%4294967296|0,C=d/4294967296|0):(b=~(-d%4294967296),C=~(-d/4294967296),4294967295^b?b=b+1|0:(b=0,C=C+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");p.realloc(10),function(E,L,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)}(b,0,p),function(E,L){const R=(7&E)<<4;L.buf[L.pos++]|=R|((E>>>=3)?128:0),E&&(L.buf[L.pos++]=127&E|((E>>>=7)?128:0),E&&(L.buf[L.pos++]=127&E|((E>>>=7)?128:0),E&&(L.buf[L.pos++]=127&E|((E>>>=7)?128:0),E&&(L.buf[L.pos++]=127&E|((E>>>=7)?128:0),E&&(L.buf[L.pos++]=127&E)))))}(C,p)}(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(b,C,E){for(let L,R,U=0;U55295&&L<57344){if(!R){L>56319||U+1===C.length?(b[E++]=239,b[E++]=191,b[E++]=189):R=L;continue}if(L<56320){b[E++]=239,b[E++]=191,b[E++]=189,R=L;continue}L=R-55296<<10|L-56320|65536,R=null}else R&&(b[E++]=239,b[E++]=191,b[E++]=189,R=null);L<128?b[E++]=L:(L<2048?b[E++]=L>>6|192:(L<65536?b[E++]=L>>12|224:(b[E++]=L>>18|240,b[E++]=L>>12&63|128),b[E++]=L>>6&63|128),b[E++]=63&L|128)}return E}(this.buf,x,this.pos);const p=this.pos-d;p>=128&&I5e(d,p,this),this.pos=d-1,this.writeVarint(p),this.pos+=p}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 p=0;p=128&&I5e(p,b,this),this.pos=p-1,this.writeVarint(b),this.pos+=b}writeMessage(x,d,p){this.writeTag(x,2),this.writeRawMessage(d,p)}writePackedVarint(x,d){d.length&&this.writeMessage(x,iht,d)}writePackedSVarint(x,d){d.length&&this.writeMessage(x,oht,d)}writePackedBoolean(x,d){d.length&&this.writeMessage(x,dht,d)}writePackedFloat(x,d){d.length&&this.writeMessage(x,lht,d)}writePackedDouble(x,d){d.length&&this.writeMessage(x,cht,d)}writePackedFixed32(x,d){d.length&&this.writeMessage(x,uht,d)}writePackedSFixed32(x,d){d.length&&this.writeMessage(x,hht,d)}writePackedFixed64(x,d){d.length&&this.writeMessage(x,mht,d)}writePackedSFixed64(x,d){d.length&&this.writeMessage(x,pht,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 d5(x,d,p){return p?4294967296*d+(x>>>0):4294967296*(d>>>0)+(x>>>0)}function I5e(x,d,p){const b=d<=16383?1:d<=2097151?2:d<=268435455?3:Math.floor(Math.log(d)/(7*Math.LN2));p.realloc(b);for(let C=p.pos-1;C>=x;C--)p.buf[C+b]=p.buf[C]}function iht(x,d){for(let p=0;p=0&&b>=d&&u7[this.text.charCodeAt(b)];b--)p--;this.text=this.text.substring(d,p),this.sectionIndex=this.sectionIndex.slice(d,p)}substring(d,p){const b=new u5;return b.text=this.text.substring(d,p),b.sectionIndex=this.sectionIndex.slice(d,p),b.sections=this.sections,b}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((d,p)=>Math.max(d,this.sections[p].scale),0)}addTextSection(d,p){this.text+=d.text,this.sections.push(SP.forText(d.scale,d.fontStack||p));const b=this.sections.length-1;for(let C=0;C=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function nfe(x,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te=1){const ze=u5.fromFeature(x,C,Te);se===vm.vertical&&ze.verticalizePunctuation(ie);let Fe=[];const Qe=function(Mt,Rt,Bt,rs,Gt,us){if(!Mt)return[];const Ss=[],Cs=function(Us,cs,as,Vs,nr,Ys){let $r=0;for(let fr=0;fr=0;let Ws=0;for(let Us=0;Us0&&si>Hn&&(Hn=si)}else{const Za=Bt[Gs.fontStack];if(!Za)continue;Za[mr]&&(zn=Za[mr]);const ti=Rt[Gs.fontStack];if(!ti)continue;const si=ti.glyphs[mr];if(!si)continue;if(Kr=si.metrics,ta=mr!==8203?Pc:0,Ys){const Ni=ti.ascender!==void 0?Math.abs(ti.ascender):0,zi=ti.descender!==void 0?Math.abs(ti.descender):0,Ii=(Ni+zi)*Ur;Pi-p/2;){if(L--,L<0)return!1;R-=x[L].dist(E),E=x[L]}R+=x[L].dist(x[L+1]),L++;const U=[];let K=0;for(;R

b;)K-=U.shift().angleDelta;if(K>C)return!1;L++,R+=te.dist(se)}return!0}function V5e(x){let d=0;for(let p=0;pK){const fe=(K-U)/de,Te=Xr(se.x,ie.x,fe),ze=Xr(se.y,ie.y,fe),Fe=new kv(Te,ze,0,ie.angleTo(se),te);return!L||U5e(x,Fe,R,L,d)?Fe:void 0}U+=de}}function _ht(x,d,p,b,C,E,L,R,U){const K=H5e(b,E,L),te=G5e(b,C),se=te*L,ie=x[0].x===0||x[0].x===U||x[0].y===0||x[0].y===U;return d-se=0&&ct=0&&kt=0&&ie+K<=te){const yt=new kv(ct,kt,0,Qe,fe);b&&!U5e(x,yt,E,b,C)||de.push(yt)}}se+=Fe}return R||de.length||L||(de=W5e(x,se/2,p,b,C,E,L,!0,U)),de}function K5e(x){let d=0,p=0;for(const L of x)d+=L.w*L.h,p=Math.max(p,L.w);x.sort((L,R)=>R.h-L.h);const b=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),p),h:1/0}];let C=0,E=0;for(const L of x)for(let R=b.length-1;R>=0;R--){const U=b[R];if(!(L.w>U.w||L.h>U.h)){if(L.x=U.x,L.y=U.y,E=Math.max(E,L.y+L.h),C=Math.max(C,L.x+L.w),L.w===U.w&&L.h===U.h){const K=b.pop();K&&R1?fe-1:fe,Zd.copy(se.data,K,{x:0,y:0},{x:Te,y:ze},se.data,b),Zd.copy(se.data,K,{x:0,y:Qe-fe},{x:Te,y:ze-fe},{width:Fe,height:fe},b),Zd.copy(se.data,K,{x:0,y:0},{x:Te,y:ze+Qe},{width:Fe,height:fe},b),Zd.copy(se.data,K,{x:Fe-fe,y:0},{x:Te-fe,y:ze},{width:fe,height:Qe},b),Zd.copy(se.data,K,{x:0,y:0},{x:Te+Fe,y:ze},{width:fe,height:Qe},b),Zd.copy(se.data,K,{x:Fe-fe,y:Qe-fe},{x:Te-fe,y:ze-fe},{width:fe,height:fe},b),Zd.copy(se.data,K,{x:0,y:Qe-fe},{x:Te+Fe,y:ze-fe},{width:fe,height:fe},b),Zd.copy(se.data,K,{x:0,y:0},{x:Te+Fe,y:ze+Qe},{width:fe,height:fe},b),Zd.copy(se.data,K,{x:Fe-fe,y:0},{x:Te-fe,y:ze+Qe},{width:fe,height:fe},b)}this.lut=b,this.image=K,this.iconPositions=C,this.patternPositions=E}addImages(d,p,b,C){for(const[E,L]of d.entries()){const{bin:R,imagePosition:U,imageVariant:K}=cfe(E,L,b);p.set(E,U),C.push(R),L.hasRenderCallback&&this.haveRenderCallbacks.push(K.id)}}patchUpdatedImages(d,p,b){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(C=>d.hasImage(C,b)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,b);for(const C of d.getUpdatedImages(b)){for(const E of this.iconPositions.keys()){const L=rg.parse(E);if(Js.isEqual(L.id,C)){const R=d.getImage(C,b);this.patchUpdatedImage(this.iconPositions.get(E),R,p,null)}}for(const E of this.patternPositions.keys()){const L=rg.parse(E);if(Js.isEqual(L.id,C)){const R=d.getImage(C,b);this.patchUpdatedImage(this.patternPositions.get(E),R,p,this.lut)}}}}patchUpdatedImage(d,p,b,C=null){if(!d||!p||d.version===p.version)return;d.version=p.version;const[E,L]=d.tl,R=d.sdf;if(this.lut||R){const U={width:p.data.width,height:p.data.height},K=new Zd(U);Zd.copy(p.data,K,{x:0,y:0},{x:0,y:0},U,C,R),b.update(K,{position:{x:E,y:L}})}else b.update(p.data,{position:{x:E,y:L}})}}Cr(CP,"ImagePosition"),Cr(Z5e,"ImageAtlas");const MP=1e20;function Y5e(x,d,p,b,C,E,L,R,U){for(let K=d;K-1);U++,E[U]=R,L[U]=K,L[U+1]=MP}for(let R=0,U=0;R{let U=this.entries[E];U||(U=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let K=U.glyphs[L];if(K!==void 0)return void R(null,{stack:E,id:L,glyph:K});if(K=this._tinySDF(U,E,L),K)return U.glyphs[L]=K,void R(null,{stack:E,id:L,glyph:K});const te=Math.floor(L/256);if(256*te>65535)return gr("glyphs > 65535 not supported"),void R(null,{stack:E,id:L,glyph:K});if(U.ranges[te])return void R(null,{stack:E,id:L,glyph:K});let se=U.requests[te];se||(se=U.requests[te]=[],p5.loadGlyphRange(E,te,C,this.requestManager,(ie,de)=>{if(de){U.ascender=de.ascender,U.descender=de.descender;for(const fe in de.glyphs)this._doesCharSupportLocalGlyph(+fe)||(U.glyphs[+fe]=de.glyphs[+fe]);U.ranges[te]=!0}for(const fe of se)fe(ie,de);delete U.requests[te]})),se.push((ie,de)=>{ie?R(ie):de&&R(null,{stack:E,id:L,glyph:de.glyphs[L]||null})})},(E,L)=>{if(E)p(E);else if(L){const R={};for(const{stack:U,id:K,glyph:te}of L)R[U]===void 0&&(R[U]={}),R[U].glyphs===void 0&&(R[U].glyphs={}),R[U].glyphs[K]=te&&{id:te.id,bitmap:te.bitmap.clone(),metrics:te.metrics},R[U].ascender=this.entries[U].ascender,R[U].descender=this.entries[U].descender;p(null,R)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==dfe.none&&(this.localGlyphMode===dfe.all?!!this.localFontFamily:!!this.localFontFamily&&(an["CJK Unified Ideographs"](d)||an["Hangul Syllables"](d)||an.Hiragana(d)||an.Katakana(d)||an["CJK Symbols and Punctuation"](d)||an["CJK Unified Ideographs Extension A"](d)||an["CJK Unified Ideographs Extension B"](d)||an.Osage(d)))}_tinySDF(d,p,b){const C=this.localFontFamily;if(!C||!this._doesCharSupportLocalGlyph(b))return;let E=d.tinySDF;if(!E){let Te="400";/bold/i.test(p)?Te="900":/medium/i.test(p)?Te="500":/light/i.test(p)&&(Te="200"),E=d.tinySDF=new p5.TinySDF({fontFamily:C,fontWeight:Te,fontSize:24*_g,buffer:3*_g,radius:8*_g}),E.fontWeight=Te}if(this.localGlyphs[E.fontWeight][b])return this.localGlyphs[E.fontWeight][b];const L=String.fromCodePoint(b),{data:R,width:U,height:K,glyphWidth:te,glyphHeight:se,glyphLeft:ie,glyphTop:de,glyphAdvance:fe}=E.draw(L);return this.localGlyphs[E.fontWeight][b]={id:b,bitmap:new Eb({width:U,height:K},R),metrics:{width:te/_g,height:se/_g,left:ie/_g,top:de/_g-27,advance:fe/_g,localGlyph:!0}}}}p5.loadGlyphRange=function(x,d,p,b,C){const E=256*d,L=E+255,R=b.transformRequest(b.normalizeGlyphsURL(p).replace("{fontstack}",x).replace("{range}",`${E}-${L}`),eg.Glyphs);Fh(R,(U,K)=>{if(U)C(U);else if(K){const te={},se=function(ie){return new d7(ie).readFields(fht,{})}(K);for(const ie of se.glyphs)te[ie.id]=ie;C(null,{glyphs:te,ascender:se.ascender,descender:se.descender})}})},p5.TinySDF=class{constructor({fontSize:x=24,buffer:d=3,radius:p=8,cutoff:b=.25,fontFamily:C="sans-serif",fontWeight:E="normal",fontStyle:L="normal",lang:R=null}={}){this.buffer=d,this.cutoff=b,this.radius=p,this.lang=R;const U=this.size=x+4*d,K=this._createCanvas(U),te=this.ctx=K.getContext("2d",{willReadFrequently:!0});te.font=`${L} ${E} ${x}px ${C}`,te.textBaseline="alphabetic",te.textAlign="left",te.fillStyle="black",this.gridOuter=new Float64Array(U*U),this.gridInner=new Float64Array(U*U),this.f=new Float64Array(U),this.z=new Float64Array(U+1),this.v=new Uint16Array(U)}_createCanvas(x){const d=document.createElement("canvas");return d.width=d.height=x,d}draw(x){const{width:d,actualBoundingBoxAscent:p,actualBoundingBoxDescent:b,actualBoundingBoxLeft:C,actualBoundingBoxRight:E}=this.ctx.measureText(x),L=Math.ceil(p),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-C))),U=Math.min(this.size-this.buffer,L+Math.ceil(b)),K=R+2*this.buffer,te=U+2*this.buffer,se=Math.max(K*te,0),ie=new Uint8ClampedArray(se),de={data:ie,width:K,height:te,glyphWidth:R,glyphHeight:U,glyphTop:L,glyphLeft:0,glyphAdvance:d};if(R===0||U===0)return de;const{ctx:fe,buffer:Te,gridInner:ze,gridOuter:Fe}=this;this.lang&&(fe.lang=this.lang),fe.clearRect(Te,Te,R,U),fe.fillText(x,Te,Te+L);const Qe=fe.getImageData(Te,Te,R,U);Fe.fill(MP,0,se),ze.fill(0,0,se);for(let nt=0;nt0?Mt*Mt:0,ze[yt]=Mt<0?Mt*Mt:0}}Y5e(Fe,0,0,K,te,K,this.f,this.v,this.z),Y5e(ze,Te,Te,R,U,K,this.f,this.v,this.z);for(let nt=0;nt{const Hs=p7(Gt.stretch-Qe,nt,te,x.left*C),Ws=f7(Gt.fixed-yt,Mt,Gt.stretch,fe),Bs=p7(us.stretch-ct,kt,se,x.top*C),Us=f7(us.fixed-Rt,Bt,us.stretch,Te),cs=p7(Ss.stretch-Qe,nt,te,x.left*C),as=f7(Ss.fixed-yt,Mt,Ss.stretch,fe),Vs=p7(Cs.stretch-ct,kt,se,x.top*C),nr=f7(Cs.fixed-Rt,Bt,Cs.stretch,Te),Ys=new ns(Hs,Bs),$r=new ns(cs,Bs),fr=new ns(cs,Vs),jr=new ns(Hs,Vs),Ir=new ns(Ws/R,Us/R),ra=new ns(as/R,nr/R),Qs=d*Math.PI/180;if(Qs){const Pi=Math.sin(Qs),bt=Math.cos(Qs),St=[bt,-Pi,Pi,bt];Ys._matMult(St),$r._matMult(St),jr._matMult(St),fr._matMult(St)}const Lr=Gt.stretch+Gt.fixed,jn=Ss.stretch+Ss.fixed,Ca=us.stretch+us.fixed,Ia=Cs.stretch+Cs.fixed,Hn=x.imageSecondary;return{tl:Ys,tr:$r,bl:jr,br:fr,texPrimary:{x:L.paddedRect.x+$y+Lr,y:L.paddedRect.y+$y+Ca,w:jn-Lr,h:Ia-Ca},texSecondary:Hn?{x:Hn.paddedRect.x+$y+Lr,y:Hn.paddedRect.y+$y+Ca,w:jn-Lr,h:Ia-Ca}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ir,pixelOffsetBR:ra,minFontScaleX:Mt/R/te,minFontScaleY:Bt/R/se,isSDF:p}};if(b&&(L.stretchX||L.stretchY)){const Gt=J5e(ie,ze,fe),us=J5e(de,Fe,Te);for(let Ss=0;SsE)&&(E=fe.x),(!de||fe.y>L)&&(L=fe.y)}const U=Math.min(E-b,L-C);let K=U/2;const te=new nC([],kht);if(U===0)return new ns(b,C);for(let de=b;dese.d||!se.d)&&(se=de,p&&console.log("found best %d after %d probes",Math.round(1e4*de.d)/1e4,ie)),de.max-se.d<=d||(K=de.h/2,te.push(new f5(de.p.x-K,de.p.y-K,K,x)),te.push(new f5(de.p.x+K,de.p.y-K,K,x)),te.push(new f5(de.p.x-K,de.p.y+K,K,x)),te.push(new f5(de.p.x+K,de.p.y+K,K,x)),ie+=4)}return p&&(console.log(`num probes: ${ie}`),console.log(`best distance: ${se.d}`)),se.p}function kht(x,d){return d.max-x.max}class f5{constructor(d,p,b,C){this.p=new ns(d,p),this.h=b,this.d=function(E,L){let R=!1,U=1/0;for(let K=0;KE.y!=Te.y>E.y&&E.x<(Te.x-fe.x)*(E.y-fe.y)/(Te.y-fe.y)+fe.x&&(R=!R),U=Math.min(U,Ko(E,fe,Te))}}return(R?1:-1)*Math.sqrt(U)}(this.p,C),this.max=this.d+this.h*Math.SQRT2}}const Sht=Object.keys,hfe=Number.POSITIVE_INFINITY,Cht=Math.sqrt(2);function Ib(x,d,p,b,C){const E=ife(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],L={top:x.top-E[1],bottom:x.bottom+E[3],left:x.left-E[0],right:x.right+E[2],scaled:!1};return b!==void 0&&function(R,U){R.top*=U,R.bottom*=U,R.left*=U,R.right*=U,R.scaled=!0}(L,b),p&&function(R,U){if(!U)return;const K=xr(U),te=new ns(R.left,R.top),se=new ns(R.right,R.top),ie=new ns(R.left,R.bottom),de=new ns(R.right,R.bottom),fe=new ns(0,0);te._rotateAround(K,fe),se._rotateAround(K,fe),ie._rotateAround(K,fe),de._rotateAround(K,fe),R.left=Math.min(te.x,se.x,ie.x,de.x),R.right=Math.max(te.x,se.x,ie.x,de.x),R.top=Math.min(te.y,se.y,ie.y,de.y),R.bottom=Math.max(te.y,se.y,ie.y,de.y)}(L,p),C&&(L.left+=C[0],L.right+=C[0],L.top+=C[1],L.bottom+=C[1]),d?{top:Math.min(d.top,L.top),bottom:Math.max(d.bottom,L.bottom),left:Math.min(d.left,L.left),right:Math.max(d.right,L.right),scaled:d.scaled||L.scaled}:L}function tMe(x,[d,p]){let b=0,C=0;if(p===hfe){d<0&&(d=0);const E=d/Cht;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":b=-E;break;case"top-left":case"bottom-left":b=E;break;case"left":b=d;break;case"right":b=-d}}else{switch(d=Math.abs(d),p=Math.abs(p),x){case"top-right":case"top-left":case"top":C=p-7;break;case"bottom-right":case"bottom-left":case"bottom":C=7-p}switch(x){case"top-right":case"bottom-right":case"right":b=-d;break;case"top-left":case"bottom-left":case"left":b=d}}return[b,C]}function Mht(x,d,p,b,C,E,L,R,U,K,te,se,ie,de){const fe=x.layers[0],Te=fe.appearances;if(Te.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const ze={iconBBox:null,iconVerticalBBox:null},Fe={textBBox:null,textVerticalBBox:null},{baseIconRotate:Qe,baseTextRotate:nt,iconScaleFactor:ct}=function(yt,Mt,Rt){const Bt=yt.get("icon-rotate").evaluate(Mt,{},Rt),rs=yt.get("text-rotate").evaluate(Mt,{},Rt),[Gt,us]=yt.get("icon-size-scale-range");return{baseIconRotate:Bt,baseTextRotate:rs,iconScaleFactor:je(1,Gt,us)}}(b,C,E);d&&(ze.iconBBox=Ib(d,ze.iconBBox,Qe,L),p)&&(ze.iconVerticalBBox=Ib(p,ze.iconVerticalBBox,Qe+90,L));const kt=g7(se.horizontal);kt&&(Fe.textBBox=Ib(kt,Fe.textBBox,nt,1,de)),se.vertical&&(Fe.textVerticalBBox=Ib(se.vertical,Fe.textVerticalBBox,nt+90,1,de));for(const yt of Te)yt.hasIconProperties()&&Tht(ze,x,fe,yt,C,E,R,Qe,L,U,d,K,ct,te),yt.hasTextProperties()&&Aht(Fe,fe,yt,C,E,de,nt,ie,kt,se.vertical);return{iconBBox:ze.iconBBox,iconVerticalBBox:ze.iconVerticalBBox,textBBox:Fe.textBBox,textVerticalBBox:Fe.textVerticalBBox}}function Tht(x,d,p,b,C,E,L,R,U,K,te,se,ie,de){const{appearanceIconOffset:fe,appearanceIconRotate:Te,appearanceIconSize:ze}=function(ct,kt,yt,Mt,Rt,Bt,rs,Gt){const us=ct.hasProperty("icon-offset")?kt.getAppearanceValueAndResolveTokens(ct,"icon-offset",yt,Mt,[]):null,Ss=us&&Array.isArray(us)?us:Rt,Cs=ct.hasProperty("icon-rotate")?kt.getAppearanceValueAndResolveTokens(ct,"icon-rotate",yt,Mt,[]):null,Hs=typeof Cs=="number"?Cs:Bt,Ws=ct.hasProperty("icon-size")?kt.getAppearanceValueAndResolveTokens(ct,"icon-size",yt,Mt,[]):null;return{appearanceIconOffset:Ss,appearanceIconRotate:Hs,appearanceIconSize:typeof Ws=="number"?Ws*Gt.iconScaleFactor:rs}}(b,p,C,E,L,R,U,K);let Fe=null,Qe=null,nt=null;b.hasProperty("icon-image")?nt=function(ct,kt,yt,Mt,Rt,Bt,rs){let Gt=null;const us=kt.getAppearanceValueAndResolveTokens(yt,"icon-image",Mt,Rt,[]);if(us){const Ss=ct.getResolvedImageFromTokens(us),Cs=yt.getUnevaluatedProperty("icon-size"),Hs=TP(Ss,h5(ct.zoom,Cs,ct.worldview),Cs,Rt,ct.zoom,Mt,ct.pixelRatio,rs,ct.worldview);Gt=Bt.get(Hs.iconPrimary.toString())}return Gt}(d,p,b,C,E,se,ie):te&&(nt=te.imagePrimary),nt&&(Fe=h7(nt,null,fe,de),d.allowVerticalPlacement&&(Qe=h7(nt,null,fe,de))),Fe&&(x.iconBBox=Ib(Fe,x.iconBBox,Te,ze)),Qe&&(x.iconVerticalBBox=Ib(Qe,x.iconVerticalBBox,Te+90,ze))}function Aht(x,d,p,b,C,E,L,R,U,K){const{appearanceTextOffset:te,appearanceTextRotate:se,appearanceTextSize:ie}=function(fe,Te,ze,Fe,Qe,nt,ct){const kt=fe.hasProperty("text-offset")?Te.getAppearanceValueAndResolveTokens(fe,"text-offset",ze,Fe,[]):null,yt=kt&&Array.isArray(kt)?[kt[0]*Pc,kt[1]*Pc]:Qe,Mt=fe.hasProperty("text-rotate")?Te.getAppearanceValueAndResolveTokens(fe,"text-rotate",ze,Fe,[]):null,Rt=typeof Mt=="number"?Mt:nt,Bt=fe.hasProperty("text-size")?Te.getAppearanceValueAndResolveTokens(fe,"text-size",ze,Fe,[]):null;return{appearanceTextOffset:yt,appearanceTextRotate:Rt,appearanceTextSize:typeof Bt=="number"?Bt:ct}}(p,d,b,C,E,L,R),de=ie/R;U&&(x.textBBox=Ib(U,x.textBBox,se,de,te)),K&&(x.textVerticalBBox=Ib(K,x.textVerticalBBox,se+90,de,te))}function x7(x,d,p,b,C,E,L,R,U){if(!d||!d.usvg)return;const K=q5e(b),te=q5e(C),se=E!=="both"&&E!=="width"||!B5e(b)?1:te.width/K.width,ie=E!=="both"&&E!=="height"||!$5e(b)?1:te.height/K.height;p.scaleSelf(se,ie);const de=p.toString();L.set(de,p),R.set(de,d);const{imagePosition:fe}=cfe(de,d,R2);U.set(de,fe)}function sMe(x,d,p,b,C,E,L,R,U){if(!x)return;const K=function(te,se,ie,de,fe,Te){if(te.kind==="camera")return te.maxSize;if(te.kind==="composite"){const ze=se.possiblyEvaluate(new Yi(te.maxZoom,{worldview:Te}),ie).evaluate(fe,{},ie),Fe=se.possiblyEvaluate(new Yi(te.minZoom,{worldview:Te}),ie).evaluate(fe,{},ie);return Math.max(ze,Fe)}return se.possiblyEvaluate(new Yi(de,{worldview:Te})).evaluate(fe,{},ie)}(d,p,b,C,E,U);return x.scaleSelf(K*R*L)}function TP(x,d,p,b,C,E,L,R,U){return{iconPrimary:sMe(x.getPrimary(),d,p,b,C,E,L,R,U),iconSecondary:sMe(x.getSecondary(),d,p,b,C,E,L,R,U)}}function Eht(x,d,p){if(!d)return;const b=p.get(x.toString()),C=p.get(d.toString());b&&C&&(b.paddedRect.w===C.paddedRect.w&&b.paddedRect.h===C.paddedRect.h||gr(`Mismatch in icon variant sizes: ${x.toString()} and ${d.toString()}`),b.usvg!==C.usvg&&gr(`Mismatch in icon variant image types: ${x.id} and ${d.id}`))}function rMe(x,d,p,b){if(!x)return;const C=d.get(p.toString());if(x.imagePrimary=C,b){const E=d.get(b.toString());x.imageSecondary=E}}function Pht(x,d){for(const p in x.horizontal)nMe(x.horizontal[p],d);nMe(x.vertical,d)}function nMe(x,d){if(x){for(const p of x.positionedLines)for(const b of p.positionedGlyphs)if(b.image!==null){const C=b.image.toString();b.rect=d.get(C).paddedRect}}}function mfe(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 Iht(x,d,p,b,C,E,L,R,U){const K=g7(E.horizontal)||E.vertical,te=p.get("icon-text-fit-padding").evaluate(b,{},C);let se,ie=d;return d&&U!=="none"&&(x.allowVerticalPlacement&&E.vertical&&(se=ofe(d,E.vertical,U,te,R,L)),K&&(ie=ofe(d,K,U,te,R,L))),{defaultShapedIcon:ie,verticallyShapedIcon:se}}function Lht(x,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe,nt,ct,kt,yt,Mt){let Rt=L.textMaxSize.evaluate(d,{},ie);Rt===void 0?Rt=R*L.textScaleFactor:Rt*=L.textScaleFactor;const Bt=x.layers[0].layout,rs=Pc,Gt=R*L.textScaleFactor/rs,us=g7(p.horizontal)||p.vertical;if(ze!=="none"&&x.appearanceFeatureData&&d.index18&&Vs>2&&(Vs>>=1),Math.max(sr/(512*Vs),1)*Bt.get("symbol-spacing")),Ws=Bt.get("text-padding")*x.tilePixelRatio,Bs=Bt.get("icon-padding")*x.tilePixelRatio,Us=xr(Bt.get("text-max-angle")),cs=Bt.get("icon-rotation-alignment")==="map"&&nt!=="point",as=Hs/2;var Vs;x.hasAnyIconTextFit===!1&&ze!=="none"&&(x.hasAnyIconTextFit=!0);const nr=d.properties?+d.properties[is]:null,Ys=nr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(nr):65535,$r=(fr,jr,Ir)=>{if(jr.x<0||jr.x>=sr||jr.y<0||jr.y>=sr)return;let ra=null;if(Ss){const{x:Qs,y:Lr,z:jn}=de.projectTilePoint(jr.x,jr.y,Ir);ra={anchor:new kv(Qs,Lr,jn,0,void 0),up:de.upVector(Ir,jr.x,jr.y)}}(function(Qs,Lr,jn,Ca,Ia,Hn,Pi,bt,St,ms,Gs,hr,mr,Ur,Kr,zn,Yn,ta,wa,un,_n,Za,ti,si,Ni,zi,Ii,li,xi,Qn,Ea,go,on){const ja=Qs.addToLineVertexArray(Lr,Ca);let Di,Vi,Qi,al,Gi,ln,Co,ki=0,lo=0,Zl=0,Ic=0,kl=-1,Sl=-1;const xc={};let gh=rb("");const Wi=jn?jn.anchor:Lr,Zo=li!=="none";let il=0,Bh=0;if(St._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Pd=St.layout.get("text-offset").evaluate(_n,{},Ni);il=Pd[0]*Pc,Bh=Pd[1]*Pc}else il=St.layout.get("text-radial-offset").evaluate(_n,{},Ni)*Pc,Bh=hfe;if(Qs.allowVerticalPlacement&&Ia.vertical){const Pd=Ia.vertical;if(Kr)ln=pfe(Pd),bt&&(Co=pfe(bt));else{const Hu=St.layout.get("text-rotate").evaluate(_n,{},Ni)+90;Qi=y7(ms,Wi,Lr,Gs,hr,mr,Pd,Ur,Hu,zn,go),bt&&(al=y7(ms,Wi,Lr,Gs,hr,mr,bt,ta,Hu,null,Ea))}}if(Hn){const Pd=Qs.iconSizeData,Hu=St.layout.get("icon-rotate").evaluate(_n,{},Ni),bm=ufe(Hn,Hu,ti,Zo,Za.iconScaleFactor),Ob=bt?ufe(bt,Hu,ti,Zo,Za.iconScaleFactor):void 0;Vi=y7(ms,Wi,Lr,Gs,hr,mr,Hn,ta,Hu,null,Qn);const w5=function(kg,WP,jTe,Gmt,NTe,kTe,Wmt,Kmt){const STe=kg.layers[0],CTe=STe.appearances;let j5=WP.length;if(jTe&&(j5=Math.max(j5,jTe.length)),CTe.length===0)return j5;const[Zmt,Ymt]=Gmt.get("icon-size-scale-range"),Qmt=je(1,Zmt,Ymt);for(const MTe of CTe){const TTe=MTe.getUnevaluatedProperties();if(TTe._values["icon-image"].value!==void 0){const ATe=STe.getAppearanceValueAndResolveTokens(MTe,"icon-image",NTe,kTe,[]);if(ATe){const ETe=kg.getResolvedImageFromTokens(ATe);if(ETe){const PTe=TTe._values["icon-size"],Xmt=TP(ETe,h5(kg.zoom,PTe,kg.worldview),PTe,kTe,kg.zoom,NTe,kg.pixelRatio,Qmt,kg.worldview),Jmt=Wmt.get(Xmt.iconPrimary.toString());j5=Math.max(j5,wht(Jmt,Kmt))}}}}return j5}(Qs,bm,Ob,St.layout,_n,Ni,Qs.iconAtlasPositions,Zo);ki=4*w5;let Ng=null;Pd.kind==="source"?(Ng=[bg*St.layout.get("icon-size").evaluate(_n,{},Ni)*Za.iconScaleFactor],Ng[0]>Sv&&gr(`${Qs.layerIds[0]}: Value for "icon-size" is >= ${AP}. Reduce your "icon-size".`)):Pd.kind==="composite"&&(Ng=[bg*Za.compositeIconSizes[0].evaluate(_n,{},Ni)*Za.iconScaleFactor,bg*Za.compositeIconSizes[1].evaluate(_n,{},Ni)*Za.iconScaleFactor],(Ng[0]>Sv||Ng[1]>Sv)&&gr(`${Qs.layerIds[0]}: Value for "icon-size" is >= ${AP}. Reduce your "icon-size".`)),Qs.addSymbols(Qs.icon,bm,Ng,un,wa,_n,void 0,jn,Lr,ja.lineStartIndex,ja.lineLength,-1,si,Ni,zi,Ii,Qs.symbolInstances.length,w5),kl=Qs.icon.placedSymbolArray.length-1,Ob&&(lo=4*w5,Qs.addSymbols(Qs.icon,Ob,Ng,un,wa,_n,vm.vertical,jn,Lr,ja.lineStartIndex,ja.lineLength,-1,si,Ni,zi,Ii,Qs.symbolInstances.length,w5),Sl=Qs.icon.placedSymbolArray.length-1)}for(const Pd in Ia.horizontal){const Hu=Pd,bm=Ia.horizontal[Hu];Di||(gh=rb(bm.text),Kr?Gi=pfe(bm):Di=y7(ms,Wi,Lr,Gs,hr,mr,bm,Ur,St.layout.get("text-rotate").evaluate(_n,{},Ni),zn,go));const Ob=bm.positionedLines.length===1;if(Zl+=aMe(Qs,jn,Lr,bm,Pi,St,Kr,_n,zn,ja,Ia.vertical?vm.horizontal:vm.horizontalOnly,Ob?Sht(Ia.horizontal):[Hu],xc,kl,Za,si,Ni,Qs.symbolInstances.length,zi),Ob)break}Ia.vertical&&(Ic+=aMe(Qs,jn,Lr,Ia.vertical,Pi,St,Kr,_n,zn,ja,vm.vertical,["vertical"],xc,Sl,Za,si,Ni,Qs.symbolInstances.length,zi));let Yl=-1;const tx=(Pd,Hu)=>Pd?Math.max(Pd,Hu):Hu;Yl=tx(Gi,Yl),Yl=tx(ln,Yl),Yl=tx(Co,Yl);const qy=Yl>-1?1:0;Qs.glyphOffsetArray.length>=65535&&gr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),_n.sortKey!==void 0&&Qs.addToSortKeyRanges(Qs.symbolInstances.length,_n.sortKey),Qs.symbolInstances.emplaceBack(Lr.x,Lr.y,Wi.x,Wi.y,Wi.z,xc.right>=0?xc.right:-1,xc.center>=0?xc.center:-1,xc.left>=0?xc.left:-1,xc.vertical>=0?xc.vertical:-1,kl,Sl,gh,Di!==void 0?Di:Qs.collisionBoxArray.length,Di!==void 0?Di+1:Qs.collisionBoxArray.length,Qi!==void 0?Qi:Qs.collisionBoxArray.length,Qi!==void 0?Qi+1:Qs.collisionBoxArray.length,Vi!==void 0?Vi:Qs.collisionBoxArray.length,Vi!==void 0?Vi+1:Qs.collisionBoxArray.length,al||Qs.collisionBoxArray.length,al?al+1:Qs.collisionBoxArray.length,Gs,Zl,Ic,ki,lo,qy,0,il,Bh,Yl,0,Zo?1:0,xi)})(x,jr,ra,fr,p,b,E,C,x.layers[0],x.collisionBoxArray,d.index,d.sourceLayerIndex,x.index,Ws,Qe,K,0,Bs,cs,Fe,d,L,te,se,ie,fe,Te,ze,Ys,ct,kt,yt)};if(nt==="line")for(const fr of JF(d.geometry,0,0,sr,sr)){const jr=_ht(fr,Hs,Us,p.vertical||us,b,rs,Cs,x.overscaling,sr);for(const Ir of jr)us&&Dht(x,us.text,as,Ir)||$r(fr,Ir,ie)}else if(nt==="line-center"){for(const fr of d.geometry)if(fr.length>1){const jr=bht(fr,Us,p.vertical||us,b,rs,Cs);jr&&$r(fr,jr,ie)}}else if(d.type==="Polygon")for(const fr of hP(d.geometry,0)){const jr=Nht(fr,16);$r(fr[0],new kv(jr.x,jr.y,0,0,void 0),ie)}else if(d.type==="LineString")for(const fr of d.geometry)$r(fr,new kv(fr[0].x,fr[0].y,0,0,void 0),ie);else if(d.type==="Point")for(const fr of d.geometry)for(const jr of fr)$r([jr],new kv(jr.x,jr.y,0,0,void 0),ie)}const AP=255,Sv=AP*bg;function aMe(x,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe){const nt=function(yt,Mt,Rt,Bt,rs,Gt,us,Ss){const Cs=[];if(Mt.positionedLines.length===0)return Cs;const Hs=Bt.layout.get("text-rotate").evaluate(Gt,{})*Math.PI/180,Ws=function(Vs){const nr=Vs[0],Ys=Vs[1],$r=nr*Ys;return $r>0?[nr,-Ys]:$r<0?[-nr,Ys]:nr===0?[Ys,nr]:[Ys,-nr]}(Rt);let Bs=Math.abs(Mt.top-Mt.bottom);for(const Vs of Mt.positionedLines)Bs-=Vs.lineOffset;const Us=Mt.positionedLines.length,cs=Bs/Us;let as=Mt.top-Rt[1];for(let Vs=0;VsSv&&gr(`${x.layerIds[0]}: Value for "text-size" is >= ${AP}. Reduce your "text-size".`)):ct.kind==="composite"&&(kt=[bg*fe.compositeTextSizes[0].evaluate(R,{},ze)*fe.textScaleFactor,bg*fe.compositeTextSizes[1].evaluate(R,{},ze)*fe.textScaleFactor],(kt[0]>Sv||kt[1]>Sv)&&gr(`${x.layerIds[0]}: Value for "text-size" is >= ${AP}. Reduce your "text-size".`)),x.addSymbols(x.text,nt,kt,U,L,R,te,d,p,K.lineStartIndex,K.lineLength,de,Te,ze,Qe,!1,Fe,nt.length);for(const yt of se)ie[yt]=x.text.placedSymbolArray.length-1;return 4*nt.length}function g7(x){for(const d in x)return x[d];return null}function y7(x,d,p,b,C,E,L,R,U,K,te){let se,ie,de,fe;if(se=te?te.top:L.top,ie=te?te.bottom:L.bottom,de=te?te.left:L.left,fe=te?te.right:L.right,ife(L)&&L.collisionPadding){const Te=L.collisionPadding;de-=Te[0],se-=Te[1],fe+=Te[2],ie+=Te[3]}if(U){const Te=new ns(de,se),ze=new ns(fe,se),Fe=new ns(de,ie),Qe=new ns(fe,ie),nt=xr(U);let ct=new ns(0,0);K&&(ct=new ns(K[0],K[1])),Te._rotateAround(nt,ct),ze._rotateAround(nt,ct),Fe._rotateAround(nt,ct),Qe._rotateAround(nt,ct),de=Math.min(Te.x,ze.x,Fe.x,Qe.x),fe=Math.max(Te.x,ze.x,Fe.x,Qe.x),se=Math.min(Te.y,ze.y,Fe.y,Qe.y),ie=Math.max(Te.y,ze.y,Fe.y,Qe.y)}return x.emplaceBack(d.x,d.y,d.z,p.x,p.y,de,se,fe,ie,R,b,C,E),x.length-1}function pfe(x){ife(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 Dht(x,d,p,b){const C=x.compareText;if(d in C){const E=C[d];for(let L=E.length-1;L>=0;L--)if(b.dist(E[L])nt&&(ct(yt,Cs,Rt,Bt,us,Ss),ct(Cs,Mt,us,Ss,rs,Gt))}ct(se,ie,b,E,C,E),ct(ie,de,C,E,C,L),ct(de,fe,C,L,b,L),ct(fe,se,b,L,b,E),Te-=nt,ze-=nt,Fe+=nt,Qe+=nt;const kt=1/Math.max(Fe-Te,Qe-ze);return{scale:kt,x:Te*kt,y:ze*kt,x2:Fe*kt,y2:Qe*kt,projection:d}}function oMe(x,{x:d,y:p},b=0){return new ns(((d-b)*x.scale-x.x)*sr,(p*x.scale-x.y)*sr)}const Oht=j(new Float32Array(16));class Lb{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,p){return{x:0,y:0,z:0}}unproject(d,p){return new v(0,0)}projectTilePoint(d,p,b){return{x:d,y:p,z:0}}locationPoint(d,p,b,C=!0){return d._coordinatePoint(d.locationCoordinate(p,b),C)}pixelsPerMeter(d,p){return ae(1,d)*p}pixelSpaceConversion(d,p,b){return 1}farthestPixelDistance(d){return iMe(d,d.pixelsPerMeter)}pointCoordinate(d,p,b,C){const E=d.horizonLineFromTop(!1),L=new ns(p,Math.max(E,b));return d.rayIntersectionCoordinate(d.pointRayIntersection(L,C))}pointCoordinate3D(d,p,b){const C=new ns(p,b);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,p){if(d.elevation&&d.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(d,p.x,p.y);const b=d.horizonLineFromTop();return p.y0?p<-x5+b&&(p=-x5+b):p>x5-b&&(p=x5-b);const L=E/Math.pow(b7(p),C);let R=L*Math.sin(C*d),U=E-L*Math.cos(C*d);return R=.5*(R/Math.PI+.5),U=.5*(U/Math.PI+.5),{x:R,y:this.southernCenter?U:1-U,z:0}}unproject(d,p){d=(2*d-.5)*Math.PI,this.southernCenter&&(p=1-p),p=(2*(1-p)-.5)*Math.PI;const{n:b,f:C}=this,E=C-p,L=Math.sign(E),R=Math.sign(b)*Math.sqrt(d*d+E*E);let U=Math.atan2(d,Math.abs(E))*L;E*b<0&&(U-=Math.PI*Math.sign(d)*L);const K=je(Wn(U/b)+this.center[0],-180,180),te=je(Wn(2*Math.atan(Math.pow(C/R,1/b))-x5),-Ne,Ne);return new v(K,this.southernCenter?-te:te)}}class lMe extends Lb{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,p){return{x:W(d),y:ee(p),z:0}}unproject(d,p){const b=le(d),C=we(p);return new v(b,C)}}const cMe=xr(Ne);class $ht extends Lb{project(d,p){const b=(p=xr(p))*p,C=b*b;return{x:.5*((d=xr(d))*(.8707-.131979*b+C*(C*(.003971*b-.001529*C)-.013791))/Math.PI+.5),y:1-.5*(p*(1.007226+b*(.015085+C*(.028874*b-.044475-.005916*C)))/Math.PI+1),z:0}}unproject(d,p){d=(2*d-.5)*Math.PI;let b=p=(2*(1-p)-1)*Math.PI,C=25,E=0,L=b*b;do{L=b*b;const K=L*L;E=(b*(1.007226+L*(.015085+K*(.028874*L-.044475-.005916*K)))-p)/(1.007226+L*(.045255+K*(.259866*L-.311325-.005916*11*K))),b=je(b-E,-cMe,cMe)}while(Math.abs(E)>1e-6&&--C>0);L=b*b;const R=je(Wn(d/(.8707+L*(L*(L*L*L*(.003971-.001529*L)-.013791)-.131979))),-180,180),U=Wn(b);return new v(R,U)}}const dMe=xr(Ne);class qht extends Lb{project(d,p){p=xr(p),d=xr(d);const b=Math.cos(p),C=2/Math.PI,E=Math.acos(b*Math.cos(d/2)),L=Math.sin(E)/E,R=.5*(d*C+2*b*Math.sin(d/2)/L)||0,U=.5*(p+Math.sin(p)/L)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*(U/Math.PI+1),z:0}}unproject(d,p){let b=d=(2*d-.5)*Math.PI,C=p=(2*(1-p)-1)*Math.PI,E=25;const L=1e-6;let R=0,U=0;do{const K=Math.cos(C),te=Math.sin(C),se=2*te*K,ie=te*te,de=K*K,fe=Math.cos(b/2),Te=Math.sin(b/2),ze=2*fe*Te,Fe=Te*Te,Qe=1-de*fe*fe,nt=Qe?1/Qe:0,ct=Qe?Math.acos(K*fe)*Math.sqrt(1/Qe):0,kt=.5*(2*ct*K*Te+2*b/Math.PI)-d,yt=.5*(ct*te+C)-p,Mt=.5*nt*(de*Fe+ct*K*fe*ie)+1/Math.PI,Rt=nt*(ze*se/4-ct*te*Te),Bt=.125*nt*(se*Te-ct*te*de*ze),rs=.5*nt*(ie*fe+ct*Fe*K)+.5,Gt=Rt*Bt-rs*Mt;R=(yt*Rt-kt*rs)/Gt,U=(kt*Bt-yt*Mt)/Gt,b=je(b-R,-Math.PI,Math.PI),C=je(C-U,-dMe,dMe)}while((Math.abs(R)>L||Math.abs(U)>L)&&--E>0);return new v(Wn(b),Wn(C))}}class uMe extends Lb{constructor(d){super(d),this.center=d.center||[0,0],this.parallels=d.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(xr(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(d,p){const{scale:b,cosPhi:C}=this;return{x:xr(d)*C*b+.5,y:-Math.sin(xr(p))/C*b+.5,z:0}}unproject(d,p){const{scale:b,cosPhi:C}=this,E=-(p-.5)/b,L=je(Wn((d-.5)/b)/C,-180,180),R=Math.asin(je(E*C,-1,1)),U=je(Wn(R),-Ne,Ne);return new v(L,U)}}class Uht extends lMe{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,p,b){const C=iP(d,p,b);return dt(C,C,VF(Gp(b))),{x:C[0],y:C[1],z:C[2]}}locationPoint(d,p,b){const C=Cb(p.lat,p.lng),E=ke([],C),L=b?d._centerAltitude+b:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(p),d._centerAltitude):d._centerAltitude;Be(C,C,E,ae(1,0)*sr*L);const R=j(new Float64Array(16));return S(R,d.pixelMatrix,d.globeMatrix),dt(C,C,R),new ns(C[0],C[1])}pixelsPerMeter(d,p){return ae(1,0)*p}pixelSpaceConversion(d,p,b){const C=ae(1,d)*p,E=Xr(ae(1,45)*p,C,b);return this.pixelsPerMeter(d,p)/E}createTileMatrix(d,p,b){const C=vpe(Gp(b.canonical));return S(new Float64Array(16),d.globeMatrix,C)}createInversionMatrix(d,p){const{center:b}=d,C=VF(Gp(p));return O(C,C,xr(b.lng)),P(C,C,xr(b.lat)),I(C,C,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(C)}pointCoordinate(d,p,b,C){return Tb(d,p,b,!0)||new at(0,0)}pointCoordinate3D(d,p,b){const C=this.pointCoordinate(d,p,b,0);return[C.x,C.y,C.z]}isPointAboveHorizon(d,p){return!Tb(d,p.x,p.y,!1)}farthestPixelDistance(d){const p=function(C,E){const L=C.cameraToCenterDistance,R=C._centerAltitude*E,U=C._camera,K=C._camera.forward(),te=oe([],_e([],K,-L),[0,0,R]),se=C.worldSize/(2*Math.PI),ie=[0,0,-se],de=C.width/C.height,fe=Math.tan(C.fovAboveCenter),Te=_e([],U.up(),fe),ze=_e([],U.right(),fe*de),Fe=ke([],oe([],oe([],K,Te),ze)),Qe=[];let nt;if(new Pr(te,Fe).closestPointOnSphere(ie,se,Qe)){const ct=oe([],Qe,ie),kt=Ce([],ct,te);nt=Math.cos(C.fovAboveCenter)*ce(kt)}else{const ct=Ce([],te,ie),kt=Ce([],ie,te);ke(kt,kt);const yt=ce(ct)-se;nt=Math.sqrt(yt*(yt+2*se));const Mt=Math.acos(nt/(se+yt))-Math.acos(Oe(K,kt));nt*=Math.cos(Mt)}return 1.01*nt}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),b=Ab(d.zoom);if(b>0){const C=iMe(d,ae(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),L=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Xr(p,C+E*(1-Math.cos(L)),Math.pow(b,10))}return p}upVector(d,p,b){return iP(p,b,d,1)}upVectorScale(d){return{metersToTile:Jf(UF(Gp(d)))}}}function hMe(x){const d=x.parallels,p=!!d&&Math.abs(d[0]+d[1])<.01;switch(x.name){case"mercator":return new lMe(x);case"equirectangular":return new zht(x);case"naturalEarth":return new $ht(x);case"equalEarth":return new Fht(x);case"winkelTripel":return new qht(x);case"albers":return p?new uMe(x):new Rht(x);case"lambertConformalConic":return p?new uMe(x):new Bht(x);case"globe":return new Uht(x)}throw new Error(`Invalid projection name: ${x.name}`)}const Vht=Ut.types,Hht=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function OP(x,d,p,b,C,E,L,R,U,K,te,se,ie){const de=R?Math.min(Sv,Math.round(R[0])):0,fe=R?Math.min(Sv,Math.round(R[1])):0;x.emplaceBack(d,p,Math.round(32*b),Math.round(32*C),E,L,(de<<1)+(U?1:0),0+(fe<<1),16*K,16*te,256*se,256*ie)}function RP(x,d,p){x.emplaceBack(d,p)}function FP(x,d,p,b,C,E,L){x.emplaceBack(d,p,b,C,E,L)}const _7=(x,d,p,b)=>{for(let C=0;C0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,Jut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,Zut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Qut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,Xut.members,!0)),this.opacityVertexBuffer.itemSize=1),(b||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())}}Cr(ffe,"SymbolBuffers");class xfe{constructor(d,p,b){this.layoutVertexArray=new d,this.layoutAttributes=p,this.indexArray=new b,this.segments=new No,this.collisionVertexArray=new H6,this.collisionVertexArrayExt=new Oy}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,eht.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,tht.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Cr(xfe,"CollisionBuffers");class w7{constructor(d){this.collisionBoxArray=d.collisionBoxArray,this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(L=>L.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=j([]),this.placementViewportMatrix=j([]);const p=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=h5(this.zoom,p["text-size"],this.worldview),this.iconSizeData=h5(this.zoom,p["icon-size"],this.worldview);const b=this.layers[0].layout,C=b.get("symbol-sort-key"),E=b.get("symbol-z-order");this.lut=d.lut,this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.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=b.get("text-writing-mode").map(L=>vm[L]),this.stateDependentLayerIds=this.layers.filter(L=>L.isStateDependent()).map(L=>L.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 p=this.layers[0].getAppearances();return!(!p||p.length===0)&&p.some(b=>b.getProperty(d)!=null)}createArrays(){this.text=new ffe(new Vp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new ffe(new Vp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new KC,this.lineVertexArray=new FF,this.symbolInstances=new X6}calculateGlyphDependencies(d,p,b,C,E){for(const L of d){const R=L.codePointAt(0);if(R===void 0)break;if(p[R]=!0,C&&E&&R<=65535){const U=kP[L];U&&(p[U.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,p,b,C,E,L){let R=1;const U=d.getUnevaluatedProperties()._values["icon-size"],K=h5(this.zoom,U,this.worldview),te=m5(K,p);if(K.kind!=="constant"&&K.kind!=="camera"||(R=te.uSize),K.kind==="composite"){const{minZoom:se,maxZoom:ie}=K,de=U.possiblyEvaluate(new Yi(se,{worldview:this.worldview}),C),fe=U.possiblyEvaluate(new Yi(ie,{worldview:this.worldview}),C),Te=de.evaluate(b,{},C,E);R=Te+(fe.evaluate(b,{},C,E)-Te)*te.uSizeT}return K.kind==="source"&&(R=U.possiblyEvaluate(new Yi(this.zoom,{worldview:this.worldview}),C).evaluate(b,{},C,E)),R*L}updateFootprints(d,p){}updateReplacement(d,p){if(p.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=p.updateTime;const b=p.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!YF(this.activeReplacements,b)&&(this.activeReplacements=b,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Bu.build(d):d}populate(d,p,b,C){const E=this.layers[0],L=E.layout,R=this.projection.name==="globe",U=L.get("text-font"),K=L.get("text-field"),te=L.get("icon-image"),[se,ie]=L.get("icon-size-scale-range"),de=je(p.scaleFactor||1,se,ie),fe=(K.value.kind!=="constant"||K.value.value instanceof zu&&!K.value.value.isEmpty()||K.value.value.toString().length>0)&&(U.value.kind!=="constant"||U.value.value.length>0),Te=te.value.kind!=="constant"||!!te.value.value||Object.keys(te.parameters).length>0,ze=this.hasAnyAppearanceProperty("icon-image"),Fe=L.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!fe&&!Te&&!ze)return;const Qe=p.iconDependencies,nt=p.glyphDependencies,ct=p.availableImages,kt=new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),yt=Mt=>{const Rt=Mt.id.toString();Qe.has(Rt)?Qe.get(Rt).push(Mt):Qe.set(Rt,[Mt])};for(const Mt of d){const{feature:Rt,id:Bt,index:rs,sourceLayerIndex:Gt}=Mt,us=E._featureFilter.needGeometry,Ss=Ht(Rt,us);if(!E._featureFilter.filter(kt,Ss,b))continue;if(us||(Ss.geometry=Dt(Rt,b,C)),R&&Rt.type!==1&&b.z<=5){const Vs=Ss.geometry,nr=.98078528056,Ys=($r,fr)=>Oe(iP($r.x,$r.y,b,1),iP(fr.x,fr.y,b,1)){if(!Vs.getProperty("icon-image"))return;const nr=this.getCombinedIconPrimary(Vs,Ws,Ss,b,ct,cs,de);nr&&yt(nr)}),Cs){const Vs=U.evaluate(Ss,{},b).join(","),nr=L.get("text-rotation-alignment")==="map"&&L.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(vm.vertical)>=0;for(const Ys of Cs.sections)if(Ys.image){const $r=Ys.image.getPrimary().scaleSelf(this.pixelRatio),fr=$r.id.toString(),jr=Qe.get(fr)||[];jr.push($r),Qe.set(fr,jr)}else{const $r=y2(Cs.toString()),fr=Ys.fontStack||Vs,jr=nt[fr]=nt[fr]||{};this.calculateGlyphDependencies(Ys.text,jr,nr,this.allowVerticalPlacement,$r)}}}if(L.get("symbol-placement")==="line"&&(this.features=function(Mt){const Rt={},Bt={},rs=[];let Gt=0;function us(Ws){rs.push(Mt[Ws]),Gt++}function Ss(Ws,Bs,Us){const cs=Bt[Ws];return delete Bt[Ws],Bt[Bs]=cs,rs[cs].geometry[0].pop(),rs[cs].geometry[0]=rs[cs].geometry[0].concat(Us[0]),cs}function Cs(Ws,Bs,Us){const cs=Rt[Bs];return delete Rt[Bs],Rt[Ws]=cs,rs[cs].geometry[0].shift(),rs[cs].geometry[0]=Us[0].concat(rs[cs].geometry[0]),cs}function Hs(Ws,Bs,Us){const cs=Us?Bs[0][Bs[0].length-1]:Bs[0][0];return`${Ws}:${cs.x}:${cs.y}`}for(let Ws=0;WsWs.geometry)}(this.features)),L.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",p.elevationFeatures){!this.elevationFeatures&&p.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const Mt of p.elevationFeatures)this.elevationFeatureIdToIndex.set(Mt.id,this.elevationFeatures.length),this.elevationFeatures.push(Mt)}}else L.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Mt,Rt)=>Mt.sortKey-Rt.sortKey)}getCombinedIconPrimary(d,p,b,C,E,L,R){let U,K;const te=d.getUnevaluatedProperties();if(te._values["icon-image"].value!==void 0){const se=p.getAppearanceValueAndResolveTokens(d,"icon-image",b,C,E);U=this.getResolvedImageFromTokens(se)}else{const se=p.getValueAndResolveTokens("icon-image",b,C,E);U=this.getResolvedImageFromTokens(se)}if(U){const se=te._values["icon-size"]||p._unevaluatedLayout._values["icon-size"];K=TP(U,h5(this.zoom,se,this.worldview),se,C,this.zoom,L,this.pixelRatio,R,this.worldview).iconPrimary}return K}updateAppearanceBasedIconTextures(d,p,b,C){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let L=!1,R=0;const U=E.layout,[K,te]=U.get("icon-size-scale-range"),se=je(1,K,te);for(let ie=0;ie=0){const ze=Te.id,Fe=p&&ze!==void 0?p[String(ze)]:void 0,Qe={type:"Point",id:Te.id,properties:Te.properties,geometry:[]},nt=this.layers[0].appearances&&this.layers[0].appearances.find(ct=>ct.isActive({globals:C,feature:Qe,canonical:d,featureState:Fe}));if(Te.activeAppearance===nt){R+=de.numIconVertices;continue}if(nt){Te.activeAppearance=nt;const ct=this.getCombinedIconPrimary(nt,E,Qe,d,b,{sortKey:void 0,text:void 0,icon:null,index:de.featureIndex,sourceLayerIndex:de.featureIndex,geometry:[],properties:Te.properties,type:"Point",id:Te.id},se);if(!ct)continue;const kt=ct.toString(),yt=this.iconAtlasPositions&&this.iconAtlasPositions.get(kt);if(yt){const Mt=E.getAppearanceValueAndResolveTokens(nt,"icon-offset",Qe,d,b),Rt=Mt&&Array.isArray(Mt)?Mt:[0,0];let Bt=h7(yt,void 0,Rt,E.layout.get("icon-anchor").evaluate(Qe,{},d));const rs=E.getAppearanceValueAndResolveTokens(nt,"icon-rotate",Qe,d,b),Gt=typeof rs=="number"?rs:0,us=yt.sdf,Ss=E.layout.get("icon-text-fit").constantOr("none");Ss!=="none"&&Te.textShaping&&Te.iconTextFitPadding&&Te.fontScale&&(Bt=ofe(Bt,Te.textShaping,Ss,Te.iconTextFitPadding,Rt,Te.fontScale));const Cs=this.calculateEffectiveAppearanceIconSize(nt,C.zoom,Qe,d,b,se),Hs=0,Ws=1+(Math.min(Sv,Math.round(Cs*bg))<<1),Bs=ufe(Bt,Gt,us,Ss!=="none",se);Te.isUsingAppearanceVertexData||(Te.isUsingAppearanceVertexData=!0,Te.layoutBasedVertexData=this.icon.getIconVertexData(R,de.numIconVertices));for(let cs=0;cs0&&(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),L=!0),R+=de.numIconVertices,Te.activeAppearance=null;else if(Te.isUsingAppearanceVertexData){const kt=Te.layoutBasedVertexData.length/12;for(let yt=0;yt0||ie>0,ze=de>0,Fe=this.elevationFeatures[U.elevationFeatureIndex];if(Fe){const Qe=new ns(U.tileAnchorX,U.tileAnchorY),nt=.075+Fe.pointElevation(Qe);U.zOffset!==nt&&(p=!0,U.zOffset=nt),nt!==0&&(this.hasAnyZOffset=!0);const ct=Fe.computeSlopeNormal(Qe,C),kt=cr(Ke(),ne(0,0,1),ct);Ue(K,K,kt),Ue(te,te,kt),K[2]*=b,te[2]*=b,K[0]===1&&K[1]===0&&K[2]===0&&te[0]===0&&te[1]===1&&te[2]===0||(E=E||Te,L=L||ze)}if(Te&&(_7(this.text.orientationVertexArray,se,K,te),_7(this.text.orientationVertexArray,ie,K,te)),ze){const{placedIconSymbolIndex:Qe,verticalPlacedIconSymbolIndex:nt}=U;Qe>=0&&_7(this.icon.orientationVertexArray,de,K,te),nt>=0&&_7(this.icon.orientationVertexArray,fe,K,te)}}E||(this.text.orientationVertexArray=void 0),L||(this.icon.orientationVertexArray=void 0),p&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,L,R)=>{b+=L,b>E.length&&E.resize(b);for(let U=-L;U<0;U++)E.emplace(U+b,R)},p=(E,L,R)=>{C+=L,C>E.length&&E.resize(C);for(let U=-L;U<0;U++)E.emplace(U+C,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let b=0,C=0;for(let E=0;E0;if((R>0||U>0)&&(d(this.text.zOffsetVertexArray,R,te),d(this.text.zOffsetVertexArray,U,te)),se){const{placedIconSymbolIndex:ie,verticalPlacedIconSymbolIndex:de}=L;ie>=0&&p(this.icon.zOffsetVertexArray,K,te),de>=0&&p(this.icon.zOffsetVertexArray,L.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,p,b,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(L=>L.appearances&&L.appearances.length>0)),this.icon.upload(d,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(d,p,b,C){return!!(d&&p&&b)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,p,b,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=hMe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,p){const b=this.lineVertexArray.length;if(d.segment!==void 0)for(const{x:C,y:E}of p)this.lineVertexArray.emplaceBack(C,E);return{lineStartIndex:b,lineLength:this.lineVertexArray.length-b}}addSymbols(d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te,ze,Fe,Qe){const nt=d.indexArray,ct=d.layoutVertexArray,kt=d.globeExtVertexArray,yt=d.segments.prepareSegment(4*Qe,ct,nt,this.canOverlap?L.sortKey:void 0),Mt=this.glyphOffsetArray.length,Rt=yt.vertexLength,Bt=this.allowVerticalPlacement&&R===vm.vertical?Math.PI/2:0,rs=L.text&&L.text.sections;for(let Ss=0;Ss=0?p.rightJustifiedTextSymbolIndex:p.centerJustifiedTextSymbolIndex>=0?p.centerJustifiedTextSymbolIndex:p.leftJustifiedTextSymbolIndex>=0?p.leftJustifiedTextSymbolIndex:p.verticalPlacedTextSymbolIndex>=0?p.verticalPlacedTextSymbolIndex:C),L=lfe(this.textSizeData,d,E)/Pc;return this.tilePixelRatio*L}getSymbolInstanceIconSize(d,p,b){const C=this.icon.placedSymbolArray.get(b),E=lfe(this.iconSizeData,d,C);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,p,b,C){d.emplaceBack(p,-b,-b,C),d.emplaceBack(p,b,-b,C),d.emplaceBack(p,b,b,C),d.emplaceBack(p,-b,b,C)}_updateTextDebugCollisionBoxes(d,p,b,C,E,L,R){for(let U=C;U0}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,p){const b=d.placedSymbolArray.get(p),C=b.vertexStartIndex+4*b.numGlyphs;for(let E=b.vertexStartIndex;EC[R]-C[U]||E[U]-E[R]),L}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let d=0;dthis.symbolInstances.get(p).zOffset-this.symbolInstances.get(d).zOffset)}addToSortKeyRanges(d,p){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===p?b.symbolInstanceEnd=d+1:this.sortKeyRanges.push({sortKey:p,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 p of this.symbolInstanceIndexes){const b=this.symbolInstances.get(p);this.featureSortOrder.push(b.featureIndex);const{rightJustifiedTextSymbolIndex:C,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:L,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:U,verticalPlacedIconSymbolIndex:K}=b;C>=0&&this.addIndicesForPlacedSymbol(this.text,C),E>=0&&E!==C&&this.addIndicesForPlacedSymbol(this.text,E),L>=0&&L!==E&&L!==C&&this.addIndicesForPlacedSymbol(this.text,L),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),U>=0&&this.addIndicesForPlacedSymbol(this.icon,U),K>=0&&this.addIndicesForPlacedSymbol(this.icon,K)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(d){const p=this.symbolInstances.get(this.text.symbolInstanceIndices[d]).elevationFeatureIndex;let b;return this.elevationFeatures&&pb in x?String(x[b]):"")}let pMe,fMe,gfe;Cr(w7,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),w7.addDynamicAttributes=g5;class xMe{constructor(d){this.type=d.property.overrides?d.property.overrides.runtimeType:zp,this.defaultValue=d}evaluate(d){if(d.formattedSection){const p=this.defaultValue.property.overrides;if(p&&p.hasOverride(d.formattedSection))return p.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}}Cr(xMe,"FormatSectionOverride",{omit:["defaultValue"]});const yfe=()=>gfe||(gfe={layout:pMe||(pMe=new Oo({"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 lr(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 lr(Kt.layout_symbol["icon-size"]),"icon-size-scale-range":new Xs(Kt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new lr(Kt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new lr(Kt.layout_symbol["icon-text-fit-padding"]),"icon-image":new lr(Kt.layout_symbol["icon-image"]),"icon-image-use-theme":new Xs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new lr(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 lr(Kt.layout_symbol["icon-offset"]),"icon-anchor":new lr(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 lr(Kt.layout_symbol["text-field"]),"text-font":new lr(Kt.layout_symbol["text-font"]),"text-size":new lr(Kt.layout_symbol["text-size"]),"text-size-scale-range":new Xs(Kt.layout_symbol["text-size-scale-range"]),"text-max-width":new lr(Kt.layout_symbol["text-max-width"]),"text-line-height":new lr(Kt.layout_symbol["text-line-height"]),"text-letter-spacing":new lr(Kt.layout_symbol["text-letter-spacing"]),"text-justify":new lr(Kt.layout_symbol["text-justify"]),"text-radial-offset":new lr(Kt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Kt.layout_symbol["text-variable-anchor"]),"text-anchor":new lr(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 lr(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 lr(Kt.layout_symbol["text-transform"]),"text-offset":new lr(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:fMe||(fMe=new Oo({"icon-opacity":new lr(Kt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new lr(Kt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new lr(Kt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new lr(Kt.paint_symbol["text-emissive-strength"]),"icon-color":new lr(Kt.paint_symbol["icon-color"]),"icon-halo-color":new lr(Kt.paint_symbol["icon-halo-color"]),"icon-halo-width":new lr(Kt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new lr(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 lr(Kt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new lr(Kt.paint_symbol["text-occlusion-opacity"]),"text-color":new lr(Kt.paint_symbol["text-color"],{runtimeType:mh,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new lr(Kt.paint_symbol["text-halo-color"]),"text-halo-width":new lr(Kt.paint_symbol["text-halo-width"]),"text-halo-blur":new lr(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 lr(Kt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"})}))},gfe);class j7 extends Uu{constructor(d,p,b,C){super(d,yfe(),p,b,C,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=j([]),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,p){super.recalculate(d,p),this.appearances&&this.appearances.forEach(C=>{C.recalculate(d,p,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 b=this.layout.get("text-writing-mode");if(b){const C=[];for(const E of b)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,p,b,C){return this._saturation===d&&this._contrast===p&&this._brightnessMin===b&&this._brightnessMax===C||(this._colorAdjustmentMatrix=function(E,L,R,U){E=mo(E),L=za(L);const K=_(),te=E/3,se=1-2*te,ie=[se,te,te,0,te,se,te,0,te,te,se,0,0,0,0,1],de=.5-.5*L,fe=U-R;return S(K,[fe,0,0,0,0,fe,0,0,0,0,fe,0,R,R,R,1],[L,0,0,0,0,L,0,0,0,0,L,0,de,de,de,1]),S(K,K,ie),K}(d,p,b,C),this._saturation=d,this._contrast=p,this._brightnessMin=b,this._brightnessMax=C),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,p,b,C){const E=this.layout.get(d).evaluate(p,{},b,C),L=this._unevaluatedLayout._values[d];return L.isDataDriven()||x2(L.value)||!E?E:mMe(p.properties,E)}getAppearanceValueAndResolveTokens(d,p,b,C,E){const L=d.getProperty(p);if(!L)return;const R=L.evaluate(b,{},C,E),U=d.getUnevaluatedProperties()._values[p];return U.isDataDriven()||x2(U.value)||!R||typeof R!="string"?R:mMe(b.properties,R)}createBucket(d){return new w7(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of yfe().paint.overridableProperties){if(!j7.hasPaintOverride(this.layout,d))continue;const p=this.paint.get(d),b=new xMe(p),C=new NC(b,p.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let E=null;E=p.value.kind==="constant"||p.value.kind==="source"?new yb("source",C):new mv("composite",C,p.value.zoomStops,p.value.interpolationType),this.paint._values[d]=new fv(p.property,E,p.parameters)}}_handleOverridablePaintPropertyUpdate(d,p,b){return!(!this.layout||p.isDataDriven()||b.isDataDriven())&&j7.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,p){const b=d.get("text-field"),C=yfe().paint.properties[p];let E=!1;const L=R=>{for(const U of R)if(C.overrides&&C.overrides.hasOverride(U))return void(E=!0)};if(b.value.kind==="constant"&&b.value.value instanceof zu)L(b.value.value.sections);else if(b.value.kind==="source"){const R=K=>{E||(K instanceof ng&&Ec(K.value)===t2?L(K.value.sections):K instanceof Hf?L(K.sections):K.eachChild(R))},U=b.value;U._styleExpression&&R(U._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,p,b){return{config:new Fy(this,{zoom:p,lut:b}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let gMe,yMe,vMe,bMe;var vfe=_a([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function N7(x,d,p,b,C,E,L,R){const U=[x,d,1,p,b,1,C,E,1],K=[L,R,1],te=g([],U),[se,ie,de]=pe(K,K,te);return y(U,U,[se,0,0,0,ie,0,0,0,de])}function _Me(x,d,p,b,C,E,L,R){const U=function(K,te,se,ie,de,fe,Te,ze){const Fe=N7(0,0,1,0,1,1,0,1),Qe=N7(K,te,se,ie,de,fe,Te,ze);return y(Qe,Qe,g([],Fe))}(x,d,p,b,C,E,L,R);return[U[2]/U[8]/sr,U[5]/U[8]/sr]}function k7(x){return[x[0],Math.min(Math.max(x[1],-Ne),Ne)]}class wMe extends As{constructor(d,p,b,C){super(),this.id=d,this.dispatcher=b,this.coordinates=p.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=p,this._dirty=!1}load(d,p){if(this._loaded=p||!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=wy(this.map._requestManager.transformRequest(this.url,eg.Image),(b,C)=>{this._imageRequest=null,this._loaded=!0,b?this.fire(new jy(b)):C&&(this.image=C instanceof HTMLImageElement?Hl.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 wP(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 wP||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 p=d[0][1],b=d[0][1];for(const E of d)E[1]>b&&(b=E[1]),E[1]Ne?this.onNorthPole=!0:C<-Ne&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(at.fromLngLat);this.tileID=function(L){let R=1/0,U=1/0,K=-1/0,te=-1/0;for(const Te of L)R=Math.min(R,Te.x),U=Math.min(U,Te.y),K=Math.max(K,Te.x),te=Math.max(te,Te.y);const se=Math.max(K-R,te-U),ie=Math.max(0,Math.floor(-Math.log2(se))),de=Math.pow(2,ie);let fe=Math.floor((R+K)/2*de);return fe>1&&(fe-=1),new Fi(ie,fe,Math.floor((U+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 wP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const Fe in this.tiles){const Qe=this.tiles[Fe];Qe.state!=="loaded"&&(Qe.state="loaded",Qe.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const p=EP(new Fi(0,0,0),this.map.transform.projection),b=[p.projection.project(this.coordinates[0][0],this.coordinates[0][1]),p.projection.project(this.coordinates[1][0],this.coordinates[1][1]),p.projection.project(this.coordinates[2][0],this.coordinates[2][1]),p.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Fe){const Qe=Fe[1].x-Fe[0].x,nt=Fe[1].y-Fe[0].y,ct=Fe[2].x-Fe[1].x,kt=Fe[2].y-Fe[1].y,yt=Fe[3].x-Fe[2].x,Mt=Fe[3].y-Fe[2].y,Rt=Fe[0].x-Fe[3].x,Bt=Fe[0].y-Fe[3].y,rs=Qe*kt-ct*nt,Gt=ct*Mt-yt*kt,us=yt*Bt-Rt*Mt,Ss=Rt*nt-Qe*Bt;return rs>0&&Gt>0&&us>0&&Ss>0||rs<0&&Gt<0&&us<0&&Ss<0}(b))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const C=EP(this.tileID,this.map.transform.projection),[E,L,R,U]=this.coordinates.map(Fe=>{const Qe=C.projection.project(Fe[0],Fe[1]);return oMe(C,Qe)._round()});this.perspectiveTransform=_Me(E.x,E.y,L.x,L.y,R.x,R.y,U.x,U.y);const K=this._boundsArray=new wb;K.emplaceBack(E.x,E.y,0,0),K.emplaceBack(L.x,L.y,sr,0),K.emplaceBack(U.x,U.y,0,sr),K.emplaceBack(R.x,R.y,sr,sr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(K,vfe.members),this.boundsSegments=No.simpleSegment(0,0,4,2);const te=[],se=[k7((ie=this.coordinates)[0]),k7(ie[1]),k7(ie[2]),k7(ie[3])];var ie;const[de,fe,Te,ze]=function(Fe){let Qe=Fe[0][0],nt=Qe,ct=Fe[0][1],kt=ct;for(let yt=1;ytnt&&(nt=Fe[yt][0]),Fe[yt][1]kt&&(kt=Fe[yt][1]);return[Qe,ct,nt-Qe,kt-ct]}(se);{const Fe=new wb,[Qe,nt,ct,kt]=function(Bs){let Us=Bs[0].x,cs=Us,as=Bs[0].y,Vs=as;for(let nr=1;nrcs&&(cs=Bs[nr].x),Bs[nr].yVs&&(Vs=Bs[nr].y);return[Us,as,cs-Us,Vs-as]}(b),yt=Bs=>[(Bs.x-Qe)/ct,(Bs.y-nt)/kt],[Mt,Rt,Bt,rs]=b.map(yt),Gt=function(Bs,Us,cs,as,Vs,nr,Ys,$r){const fr=N7(0,0,1,0,1,1,0,1);return y(fr,fr,g([],N7(Bs,Us,cs,as,Vs,nr,Ys,$r)))}(Mt[0],Mt[1],Rt[0],Rt[1],Bt[0],Bt[1],rs[0],rs[1]);this.elevatedGlobePerspectiveTransform=_Me(Mt[0],Mt[1],Rt[0],Rt[1],Bt[0],Bt[1],rs[0],rs[1]);const us=(Bs,Us)=>{te.push(Bs.lng);const cs=Math.round((Bs.lng-de)/Te*sr),as=Math.round((Bs.lat-fe)/ze*sr),Vs=yt(Us),nr=pe([],[Vs[0],Vs[1],1],Gt),Ys=Math.round(nr[0]/nr[2]*sr),$r=Math.round(nr[1]/nr[2]*sr);Fe.emplaceBack(cs,as,Ys,$r)},Ss=b[3].x-b[0].x,Cs=b[3].y-b[0].y,Hs=b[2].x-b[1].x,Ws=b[2].y-b[1].y;for(let Bs=0;Bs<65;Bs++){const Us=Bs/64,cs=[b[0].x+Us*Ss,b[0].y+Us*Cs],as=[b[1].x+Us*Hs,b[1].y+Us*Ws],Vs=as[0]-cs[0],nr=as[1]-cs[1];for(let Ys=0;Ys<65;Ys++){const $r=Ys/64,fr={x:cs[0]+Vs*$r,y:cs[1]+nr*$r};us(p.projection.unproject(fr.x,fr.y),fr)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(Fe,vfe.members)}{this.maxLongitudeTriangleSize=0;let Fe=[],Qe=new Gl;const nt=(ct,kt,yt)=>{Qe.emplaceBack(ct,kt,yt);const Mt=te[ct],Rt=te[kt],Bt=te[yt],rs=Math.min(Math.min(Mt,Rt),Bt),Gt=Math.max(Math.max(Mt,Rt),Bt)-rs;Gt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Gt),Fe.push(rs+Gt/2)};for(let ct=0;ct<64;ct++)for(let kt=0;kt<64;kt++){const yt=65*ct+kt,Mt=yt+1,Rt=yt+65,Bt=Rt+1;nt(yt,Rt,Mt),nt(Mt,Rt,Bt)}[Fe,Qe]=function(ct,kt){const yt=Array.from({length:ct.length},(Bt,rs)=>rs);yt.sort((Bt,rs)=>ct[Bt]-ct[rs]);const Mt=[],Rt=new Gl;for(let Bt=0;Bt{L.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:p.segments[0].vertexLength,primitiveLength:ie,sortKey:void 0,vaos:{}})},U=.51*this.maxLongitudeTriangleSize;if(Math.abs(b[0]-C)<=U){const se=ho(b,0,b.length,C+U);return se===b.length||R(se,fl(b,se+1,b.length,C+360-U)-se),L}Csr?C-sr:C,new ns(Math.trunc(C),Math.trunc(b[p+1]))}translationForInstance(d){const p=16*d,b=this.instancedDataArray.float32;return[b[p+4],b[p+5],b[p+6]]}rotationScaleForInstance(d){const p=16*d,b=this.instancedDataArray.float32;return[b[p+7],b[p+8],b[p+9],b[p+10],b[p+11],b[p+12],b[p+13],b[p+14],b[p+15]]}transformForInstance(d){const p=16*d,b=this.instancedDataArray.float32;return[b[p+7],b[p+8],b[p+9],b[p+4],b[p+10],b[p+11],b[p+12],b[p+5],b[p+13],b[p+14],b[p+15],b[p+6],0,0,0,1]}}class wfe{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(p=>p.fqid),this.projection=d.projection,this.index=d.index,this.worldview=d.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.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,p){}updateAppearances(d,p,b,C){}populate(d,p,b,C){this.tileToMeter=Ve(b);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:L,id:R,index:U,sourceLayerIndex:K}of d){const te=R??(L.properties&&L.properties.hasOwnProperty("id")?L.properties.id:void 0),se=Ht(L,E);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom,{worldview:this.worldview,activeFloors:p.activeFloors}),se,b))continue;const ie={id:te,sourceLayerIndex:K,index:U,geometry:E?se.geometry:Dt(L,b,C),properties:L.properties,type:L.type,patterns:{}},de=this.addFeature(ie,ie.geometry,se);de&&p.featureIndex.insert(L,ie.geometry,U,K,this.index,this.instancesPerModel[de].instancedDataArray.length,sr/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const d=this.layers[0].modelManager,p=this.layers[0].scope;let b=0;for(const C of this.modelUris){const E=d.getModel(C,p);if(!E)continue;const L=this.instancesPerModel[C];if(L){const R=.5*Se(E.aabb.max,E.aabb.min)*L.maxScale+L.maxXYTranslationDistance,U=Math.min(sr,Math.max(R/this.tileToMeter,sr/32));b=Math.max(U,b)}}return b}update(d,p,b,C){for(const E in this.instancesPerModel){const L=this.instancesPerModel[E];for(const R in d)L.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(L.features[L.idToFeaturesIndex[R]],d[R],L,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const p in this.instancesPerModel){const b=this.instancesPerModel[p];for(const C of b.features){const E=this.layers[0],L=C.feature,R=this.canonical,U=E.paint.get("model-rotation").evaluate(L,{},R),K=E.paint.get("model-scale").evaluate(L,{},R),te=E.paint.get("model-translation").evaluate(L,{},R);et(C.rotation,U)&&et(C.scale,K)&&et(C.translation,te)||(this.evaluate(C,C.featureStates,b,!0),d=!0)}}return d}updateReplacement(d,p,b,C){if(p.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=p.updateTime;const E=p.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(YF(this.activeReplacements,E))return!1;this.activeReplacements=E;let L=!1;for(const R in this.instancesPerModel){const U=this.instancesPerModel[R],K=U.instancedDataArray;for(const te of U.features){const se=te.instancedDataOffset,ie=te.instancedDataCount;for(let de=0;desr;Te=ze?Te-sr:Te;const Fe=Math.floor(Te),Qe=Math.floor(K.float32[fe+1]);let nt=!1;for(const ct of this.activeReplacements)if(!yCe(ct,b,AMe.Model,C)&&!(ct.min.x>Fe||Fe>ct.max.x||ct.min.y>Qe||Qe>ct.max.y)&&(nt=jCe(wCe(Fe,Qe,d.canonical,ct.footprintTileId.canonical),ct.footprint),nt))break;K.float32[fe]=nt?Te+sr:Te,L=L||nt!==ze}}}return L}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 p in this.instancesPerModel){const b=this.instancesPerModel[p];b.instancedDataArray.length<0||b.instancedDataArray.length===0||(b.instancedDataBuffer?b.instancedDataBuffer.updateData(b.instancedDataArray):b.instancedDataBuffer=d.createVertexBuffer(b.instancedDataArray,gut.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const b in this.instancesPerModel){const C=this.instancesPerModel[b];C.instancedDataArray.length!==0&&C.instancedDataBuffer&&C.instancedDataBuffer.destroy()}const p=this.layers[0].modelManager;if(d&&p&&this.modelUris&&this.modelsRequested)for(const b of this.modelUris)p.removeModel(b,"",!0)}addFeature(d,p,b){const C=this.layers[0],E=C.layout.get("model-id").evaluate(b,{},this.canonical);if(!E)return gr(`modelId is not evaluated for layer ${C.id} and it is not going to get rendered.`),E;(_fe(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new PMe);const L=this.instancesPerModel[E],R=L.instancedDataArray,U=new EMe(b,R.length);for(const K of p)for(const te of K){if(te.x<0||te.x>=sr||te.y<0||te.y>=sr)continue;if(this.lookupDim!==0){const ie=(this.lookupDim-1)/sr,de=this.lookupDim*(te.y*ie|0)+te.x*ie|0;if(this.lookup){if(this.lookup[de]!==0)continue;this.lookup[de]=1}}this.instanceCount++;const se=R.length;R.resize(se+1),L.instancesEvaluatedElevation.push(0),R.float32[16*se]=te.x,R.float32[16*se+1]=te.y}return U.instancedDataCount=L.instancedDataArray.length-U.instancedDataOffset,U.instancedDataCount>0&&(d.id&&(L.idToFeaturesIndex[d.id]=L.features.length),L.features.push(U),this.evaluate(U,{},L,!1)),E}getModelUris(){return this.modelUris}evaluate(d,p,b,C){const E=this.layers[0],L=d.feature,R=this.canonical,U=d.rotation=E.paint.get("model-rotation").evaluate(L,p,R),K=d.scale=E.paint.get("model-scale").evaluate(L,p,R),te=d.translation=E.paint.get("model-translation").evaluate(L,p,R),se=Object.assign({},E.paint.get("model-color").evaluate(L,p,R));se.a=E.paint.get("model-color-mix-intensity").evaluate(L,p,R);const ie=[];this.maxVerticalOffset0?Math.sqrt(de):0;b.maxScale=Math.max(Math.max(b.maxScale,K[0]),Math.max(K[1],K[2])),b.maxXYTranslationDistance=Math.max(b.maxXYTranslationDistance,fe),this.maxScale=Math.max(Math.max(this.maxScale,K[0]),Math.max(K[1],K[2])),c5e(ie,U,K);const Te=Math.round(100*se.a)+se.b/1.05;for(let ze=0;ze10?this.tileToMeter:Ve(R,kt)),nt[Qe+4]=te[0],nt[Qe+5]=te[1],nt[Qe+6]=te[2]+ct,nt[Qe+7]=ie[0],nt[Qe+8]=ie[1],nt[Qe+9]=ie[2],nt[Qe+10]=ie[4],nt[Qe+11]=ie[5],nt[Qe+12]=ie[6],nt[Qe+13]=ie[8],nt[Qe+14]=ie[9],nt[Qe+15]=ie[10],b.instancesEvaluatedElevation[Fe]=te[2]}}}let IMe,LMe;Cr(wfe,"ModelBucket",{omit:["layers"]}),Cr(PMe,"PerModelAttributes"),Cr(EMe,"ModelFeature");class y5{constructor(d,p,b){this._demTile=d,this._dem=this._demTile.dem,this._scale=p,this._offset=b}static create(d,p,b){const C=b||d.findDEMTileFor(p);if(!C||!C.dem)return;const E=C.dem,L=C.tileID,R=1<K.fqid),this.stateDependentLayerIds=this.layers.filter(K=>K.isStateDependent()).map(K=>K.id),this.modelTraits|=c5.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,C&&(this.modelTraits|=c5.HasMapboxMeshFeatures),E&&(this.modelTraits|=c5.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=L,this.worldview=U,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const K of p)this.nodesInfo.push(new FMe(K)),OMe(K,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,p){for(const b of this.getNodesInfo()){const C=b.node;C.footprint&&p.push({footprint:C.footprint,id:d})}}updateAppearances(d,p,b,C){}update(d){const p=Object.keys(d).length!==0;if(p&&!this.stateDependentLayers.length)return;const b=p?this.stateDependentLayers:this.layers;if(!Wt(d,this.states))for(const C of b)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 p=this.getNodesInfo();for(const b of p){const C=b.node;this.uploaded?this.updatePbrBuffer(C):Wpe(C,d,!0)}for(const b of p)l7(b.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(d){let p=!1;if(!d.meshes)return p;for(const b of d.meshes)b.pbrBuffer&&(b.pbrBuffer.updateData(b.featureArray),p=!0);return p}needsReEvaluation(d,p,b){const C=d.transform.projectionOptions,E=d.style.getBrightness(),L=this.brightness!==E;if(!this.uploaded||this.dirty||C.name!==this.projection.name||zP(b.paint.get("model-color").value,L)||zP(b.paint.get("model-color-mix-intensity").value,L)||zP(b.paint.get("model-roughness").value,L)||zP(b.paint.get("model-emissive-strength").value,L)||zP(b.paint.get("model-height-based-emissive-strength-multiplier").value,L)){this.projection=C,this.brightness=E;const R=this.getNodesInfo();for(const U of R)U.state=null;return!0}return!1}evaluateTransform(d,p){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const b=this.getNodesInfo(),C=this.id.canonical;for(const E of b){const L=E.feature;E.evaluatedTranslation=p.paint.get("model-translation").evaluate(L,{},C),E.evaluatedScale=p.paint.get("model-scale").evaluate(L,{},C)}}evaluate(d,p){const b=this.getNodesInfo();for(const C of b){if(!C.node.meshes)continue;const E=C.feature,L=p&&p[E.id];if(Wt(L,C.state))continue;C.state=structuredClone(L);const R=C.node.meshes&&C.node.meshes[0].featureData,U=C.evaluatedColor[2],K=C.evaluatedRMEA[2],te=this.id.canonical;if(C.hasTranslucentParts=!1,R){for(let se=0;se=yt)continue;const Bs=jfe[Ws],Us=Math.abs(Bs);Us>Gt&&(rs=Bs,Gt=Us,us=Hs,Ss=Cs)}if(Gt>.1){const Cs=1-(yt+.5*Math.abs(us*Ss))/fe;let Hs=p._dem.get(Rt,Mt)+rs*Cs;const Ws=p._dem.get(Rt+us,Mt+Ss),Bs=p._dem.get(Rt-us,Mt-Ss,!0);(Hs-Ws)*(Hs-Bs)>0&&(Hs=(Ws+Bs)/2),jfe[Bt]=p._dem.set(Rt,Mt,Hs),F2[Bt]=yt}}}}}R&&(p._demTile.needsDEMTextureUpload=!0,p._dem._timestamp=Hl.now())}setFilter(d){this.filter=d?IC(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Yi(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const p of d)l7(p.node),Kpe(p.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(d,p){if(p.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=p.updateTime;const b=p.getReplacementRegionsForTile(d.toUnwrapped());for(const C of this.getNodesInfo()){const E=C.node.footprint;C.hiddenByReplacement=!!E&&!b.find(L=>L.footprint===E)}}getHeightAtTileCoord(d,p){const b=[],C=[0,0,0],E=j([]);for(const L of this.getNodesInfo()){const R=L.node.meshes[0],U=R.transformedAabb;if(dU.max[0]||p>U.max[1])continue;if(L.node.hidden===!0)return{height:1/0,maxHeight:L.feature.properties.height,hidden:!1,verticalScale:L.evaluatedScale[2]};N(E,L.node.globalMatrix),C[0]=d,C[1]=p,dt(C,C,E);const K=(C[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*D2|0,te=Math.min(63,(C[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*D2|0)*D2+Math.min(63,K),se=R.heightmap[te];if(!(se<0&&L.node.footprint))return L.hiddenByReplacement?void 0:{height:se,maxHeight:L.feature.properties.height,hidden:!1,verticalScale:L.evaluatedScale[2]};if(L.node.footprint.grid.query(new ns(d,p),new ns(d,p),b),b.length>0)return{height:void 0,maxHeight:L.feature.properties.height,hidden:L.hiddenByReplacement,verticalScale:L.evaluatedScale[2]}}}}function zP(x,d){return x instanceof yb&&!x.isLightConstant&&d}function Zht(x,d,p,b,C,E,L,R){let U=(61440&d|(61440&d)>>4)>>8,K=(3840&d|(3840&d)>>4)>>4,te=240&d|(240&d)>>4;p[3]>0&&(U=Xr(U,255*p[0],p[3]),K=Xr(K,255*p[1],p[3]),te=Xr(te,255*p[2],p[3]));const se=U<<8|K,ie=te<<8|Math.floor(255*b[3]),de=function(yt){const Mt=je(yt,0,2);return Math.min(Math.round(.5*Mt*255),255)}(b[2])<<8|15*b[0]<<4|15*b[1],fe=je(C[0],0,1),Te=je(C[1],0,1),ze=je(C[2],0,1),Fe=je(C[3],0,1);let Qe,nt,ct,kt;if(fe!==Te&&L!==E&&Te!==fe){const yt=L-E;nt=1/(yt*(Te-fe)),ct=-(E+yt*fe)/(yt*(Te-fe));const Mt=je(C[4],-1,1);kt=Math.pow(10,Mt),Qe=255*ze<<8|255*Fe}else Qe=65535,nt=0,ct=1,kt=1;if(x.emplaceBack(se,ie,de,Qe,nt,ct,kt),R){const yt=R.length;R.clear();for(let Mt=0;Mt>16&65535,te=E?U>>16&65535:65535&U,se=(15&te)<8?15&te:0,ie=x.evaluatedRMEA[se],de=x.evaluatedColor[se],fe=x.emissionHeightBasedParams[se];let Te;if(R&&se===2&&b.lights&&(Te=new VC,Te.resize(10*b.lights.length)),Zht(L.featureArray,K,de,ie,fe,L.aabb.min[2],L.aabb.max[2],Te),Te&&R){R=!1;const ze=b.meshes[b.lightMeshIndex];ze.featureArray=Te,ze.featureArray._trim()}}L.featureArray._trim(),C++}}Cr(C7,"Tiled3dModelBucket",{omit:["layers"]}),Cr(FMe,"Tiled3dModelFeature");const Qht=["id","tile","layer","source","sourceLayer","state"];class z2{constructor(d,p,b,C,E){this.type="Feature",this._vectorTileFeature=d,this._z=p,this._x=b,this._y=C,this.properties=d?d.properties:{},this.id=E}clone(){const d=new z2(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 p of Qht)this[p]!==void 0&&(d[p]=this[p]);return d}}class B2 extends As{constructor(d,p,b,C){super(),this.id=d,this.type="model",this.models=[],this._loaded=!1,this._options=p,this._modelsInfo=new Map}load(){const d=[];for(const p in this._options.models){const b=this._options.models[p],C=this._modelsInfo.get(p);if(C){const E=C.model;E.position=b.position!=null?new v(b.position[0],b.position[1]):new v(0,0),E.orientation=b.orientation!=null?b.orientation:[0,0,0],C.modelSpec=b,B2.applyModelSpecification(E,b),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=a5e(this.map._requestManager.transformRequest(b.uri,eg.Model).url).then(L=>{if(!L)return;const R=Ype(L),U=new d5e(p,b.uri,b.position,b.orientation,R);B2.applyModelSpecification(U,b),U.computeBoundsAndApplyParent(),this.models.push(U),this._modelsInfo.set(p,{modelSpec:b,model:U})}).catch(L=>{this.fire(new jy(new Error(`Could not load model ${p} from ${b.uri}: ${L.message}`)))});d.push(E)}}Promise.allSettled(d).then(()=>{this._loaded=!0,this.fire(new Xm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(p=>{this._loaded=!0,this.fire(new jy(new Error(`Could not load models: ${p.message}`)))})}static applyModelSpecification(d,p){p.nodeOverrides&&B2.convertNodeOverrides(d,p.nodeOverrides),p.materialOverrides&&B2.convertMaterialOverrides(d,p.materialOverrides),p.nodeOverrideNames&&(d.nodeOverrideNames=[...p.nodeOverrideNames]),p.materialOverrideNames&&(d.materialOverrideNames=[...p.materialOverrideNames]),p.featureProperties&&(d.featureProperties=p.featureProperties)}static convertNodeOverrides(d,p){if(Array.isArray(p)&&p.every(b=>typeof b=="string")){d.nodeOverrideNames=[];for(const b of p)d.nodeOverrideNames.push(b)}else Object.entries(p).forEach(([b,C])=>{const E={orientation:[0,0,0]};if(C.hasOwnProperty("orientation")){const L=C.orientation;L&&(E.orientation=L)}d.nodeOverrides.set(b,E)})}static convertMaterialOverrides(d,p){if(Array.isArray(p)&&p.every(b=>typeof b=="string")){d.materialOverrideNames=[];for(const b of p)d.materialOverrideNames.push(b)}else Object.entries(p).forEach(([b,C])=>{const E={color:new Wr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},L=C["model-color"];L!==void 0&&(E.color.r=L[0],E.color.g=L[1],E.color.b=L[2]);const R=C["model-color-mix-intensity"];R!==void 0&&(E.colorMix=R);const U=C["model-emissive-strength"];U!==void 0&&(E.emissionStrength=U);const K=C["model-opacity"];K!==void 0&&(E.opacity=K),d.materialOverrides.set(b,E)})}onAdd(d){this.map=d,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(d,p){}serialize(){return this._options}setProperty(d,p){return!1}reload(){const d=Up(this.id,this.scope);this.map.style.clearSource(d),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(d){this.models=[];const p=new Map;for(const b in d){const C=d[b];if(this._modelsInfo.has(b)){const E=this._modelsInfo.get(b);E&&E.modelSpec.uri===C.uri&&p.set(b,E)}}this._modelsInfo=p,this._options.models=d,this._loaded=!1,this.load()}}function Nfe(x,d,p,b){const C=1<ct.polygon).flat());const ze=de?R:null,[Fe,Qe]=WCe(E,b,se,te,K,L,ze,ie,fe,E.center.lat,x.tileID.canonical),nt=x.queryGeometry;return GCe(Fe,Qe,nt.isPointQuery()?nt.screenBounds:nt.screenGeometry)}},building:class extends Uu{constructor(x,d,p,b){super(x,{layout:g5e||(g5e=new Oo({visibility:new Xs(Kt.layout_building.visibility),"building-facade":new lr(Kt.layout_building["building-facade"]),"building-facade-floors":new lr(Kt.layout_building["building-facade-floors"]),"building-facade-unit-width":new lr(Kt.layout_building["building-facade-unit-width"]),"building-facade-window":new lr(Kt.layout_building["building-facade-window"]),"building-roof-shape":new lr(Kt.layout_building["building-roof-shape"]),"building-height":new lr(Kt.layout_building["building-height"]),"building-base":new lr(Kt.layout_building["building-base"]),"building-flood-light-wall-radius":new lr(Kt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new lr(Kt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new lr(Kt.layout_building["building-flip-roof-orientation"])})),paint:y5e||(y5e=new Oo({"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 lr(Kt.paint_building["building-color"]),"building-emissive-strength":new lr(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 lr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new lr({type:"string",default:"default","property-type":"data-driven"})}))},d,p,b),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new x5e(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,p,b,C,E,L,R,U){let K=this.layout.get("building-height").evaluate(d,p);const te=this.layout.get("building-base").evaluate(d,p),se=x.tile.getBucket(this).getFootprint(d);if(se){if(se.hiddenFlags!==0)return!1;K=se.height}const[ie,de]=WCe(E,b,te,K,new ns(0,0),L,null,[0,0],1,E.center.lat,x.tileID.canonical),fe=x.queryGeometry;return GCe(ie,de,fe.isPointQuery()?fe.screenBounds:fe.screenGeometry)}},line:class extends Uu{constructor(x,d,p,b){const C=M5e();super(x,C,d,p,b),C.layout&&(this.layout=new xv(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 d2,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(NP)return NP;const p=M5e();return NP=new Wut(p.paint.properties["line-width"].specification),NP.useIntegerZoom=!0,NP})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new Jpe(x)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(x,d,p){const b=S5e(this);return{config:new Fy(this,{zoom:d,lut:p}),defines:b,overrideFog:!1}}queryRadius(x){const d=x,p=T5e(Kd("line-width",this,d),Kd("line-gap-width",this,d)),b=Kd("line-offset",this,d);return p/2+Math.abs(b)+ld(this.paint.get("line-translate"))}queryIntersectsFeature(x,d,p,b,C,E){if(x.queryGeometry.isAboveHorizon)return!1;const L=gm(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*T5e(this.paint.get("line-width").evaluate(d,p),this.paint.get("line-gap-width").evaluate(d,p)),U=this.paint.get("line-offset").evaluate(d,p);return U&&(b=function(K,te){const se=[],ie=new ns(0,0);for(let de=0;de=3){for(let fe=0;fe>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function hmt(x,d,p){x===1?(d.rgb_color=E7(p.readVarint()),d.paint="rgb_color"):x===2?(d.linear_gradient_idx=p.readVarint(),d.paint="linear_gradient_idx"):x===3?(d.radial_gradient_idx=p.readVarint(),d.paint="radial_gradient_idx"):x===5?p.readPackedFloat(d.dasharray):x===6?d.dashoffset=p.readFloat():x===7?d.miterlimit=p.readFloat():x===8?d.opacity=p.readVarint():x===9?d.width=p.readFloat():x===10?d.linecap=p.readVarint():x===11&&(d.linejoin=p.readVarint())}function mmt(x,d,p){x===1?d.transform=A7(p,p.readVarint()+p.pos):x===2?d.spread_method=p.readVarint():x===3?d.stops.push(qMe(p,p.readVarint()+p.pos)):x===4?d.x1=p.readFloat():x===5?d.y1=p.readFloat():x===6?d.x2=p.readFloat():x===7&&(d.y2=p.readFloat())}function qMe(x,d){return x.readFields(pmt,{offset:0,opacity:255,rgb_color:kfe},d)}function pmt(x,d,p){x===1?d.offset=p.readFloat():x===2?d.opacity=p.readVarint():x===3&&(d.rgb_color=E7(p.readVarint()))}function fmt(x,d,p){x===1?d.transform=A7(p,p.readVarint()+p.pos):x===2?d.spread_method=p.readVarint():x===3?d.stops.push(qMe(p,p.readVarint()+p.pos)):x===4?d.cx=p.readFloat():x===5?d.cy=p.readFloat():x===6?d.r=p.readFloat():x===7?d.fx=p.readFloat():x===8?d.fy=p.readFloat():x===9&&(d.fr=p.readFloat())}function xmt(x,d,p){x===1?d.transform=A7(p,p.readVarint()+p.pos):x===2?d.clip_path_idx=p.readVarint():x===3&&d.children.push(T7(p,p.readVarint()+p.pos))}function gmt(x,d,p){x===1?d.left=d.top=p.readFloat():x===2?d.width=d.height=p.readFloat():x===3?d.top=p.readFloat():x===4?d.height=p.readFloat():x===5?d.mask_type=p.readVarint():x===6?d.mask_idx=p.readVarint():x===7&&d.children.push(T7(p,p.readVarint()+p.pos))}class ymt{static calculate(d={},p=[]){const b=new Map,C=new Map;if(Object.keys(d).length===0)return b;p.forEach(E=>{C.set(E.name,E.rgb_color||new Wr(0,0,0))});for(const[E,L]of Object.entries(d))C.has(E)?b.set(C.get(E).toString(),L):console.warn(`Ignoring unknown image variable "${E}"`);return b}}function v5(x,d=255,p){const b=d/255,C=x.toString(),E=p.has(C)?p.get(C).clone():x.clone();return E.a*=b,E.toString()}function $P(x,d){if(!Zm()){const p=document.createElement("canvas");return p.width=x,p.height=d,p}return new OffscreenCanvas(x,d)}let Mfe,qP=null;function Tfe(x,d,p,b,C){for(const E of b.children)UMe(x,d,p,E,C)}function UMe(x,d,p,b,C){b.group?(x.save(),function(E,L,R,U,K){const te=U.mask_idx!=null?R.masks[U.mask_idx]:null,se=U.clip_path_idx!=null?R.clip_paths[U.clip_path_idx]:null;if(U.transform&&(L=b5(U.transform).preMultiplySelf(L)),!function(fe,Te,ze){return fe.opacity!==255||Te||ze}(U,se!=null,te!=null))return void Tfe(E,L,R,U,K);const ie=$P(E.canvas.width,E.canvas.height),de=ie.getContext("2d");Tfe(de,L,R,U,K),se&&YMe(de,L,R,se),te&&QMe(de,L,R,te,K),E.globalAlpha=U.opacity/255,E.drawImage(ie,0,0)}(x,d,p,b.group,C),x.restore()):b.path&&(x.save(),function(E,L,R,U,K){E.setTransform(L),U.paint_order===emt.PAINT_ORDER_FILL_AND_STROKE?(VMe(E,R,U,K),GMe(E,R,U,K)):(GMe(E,R,U,K),VMe(E,R,U,K))}(x,d,p,b.path,C),x.restore())}function VMe(x,d,p,b){const C=p.fill;if(!C)return;const E=C.opacity/255;switch(x.save(),x.beginPath(),XMe(p,x),C.paint){case"rgb_color":x.fillStyle=v5(C.rgb_color,C.opacity,b);break;case"linear_gradient_idx":{const L=d.linear_gradients[C.linear_gradient_idx];L.transform&&x.setTransform(b5(L.transform).preMultiplySelf(x.getTransform())),x.fillStyle=WMe(x,L,E,b);break}case"radial_gradient_idx":{const L=d.radial_gradients[C.radial_gradient_idx];L.transform&&x.setTransform(b5(L.transform).preMultiplySelf(x.getTransform())),x.fillStyle=KMe(x,L,E,b)}}x.fill(HMe(p)),x.restore()}function HMe(x){return x.rule===Sfe.PATH_RULE_NON_ZERO?"nonzero":x.rule===Sfe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function GMe(x,d,p,b){const C=p.stroke;if(!C)return;const E=JMe(p);x.lineWidth=C.width,x.miterLimit=C.miterlimit,x.setLineDash(C.dasharray),x.lineDashOffset=C.dashoffset;const L=C.opacity/255;switch(C.paint){case"rgb_color":x.strokeStyle=v5(C.rgb_color,C.opacity,b);break;case"linear_gradient_idx":x.strokeStyle=WMe(x,d.linear_gradients[C.linear_gradient_idx],L,b,!0);break;case"radial_gradient_idx":x.strokeStyle=KMe(x,d.radial_gradients[C.radial_gradient_idx],L,b,!0)}switch(C.linejoin){case M7.LINE_JOIN_MITER_CLIP:case M7.LINE_JOIN_MITER:x.lineJoin="miter";break;case M7.LINE_JOIN_ROUND:x.lineJoin="round";break;case M7.LINE_JOIN_BEVEL:x.lineJoin="bevel"}switch(C.linecap){case Cfe.LINE_CAP_BUTT:x.lineCap="butt";break;case Cfe.LINE_CAP_ROUND:x.lineCap="round";break;case Cfe.LINE_CAP_SQUARE:x.lineCap="square"}x.stroke(E)}function WMe(x,d,p,b,C=!1){if(d.stops.length===1){const ie=d.stops[0];return v5(ie.rgb_color,ie.opacity*p,b)}const{x1:E,y1:L,x2:R,y2:U}=d;let K=new DOMPoint(E,L),te=new DOMPoint(R,U);if(C){const ie=b5(d.transform);K=ie.transformPoint(K),te=ie.transformPoint(te)}const se=x.createLinearGradient(K.x,K.y,te.x,te.y);for(const ie of d.stops)se.addColorStop(ie.offset,v5(ie.rgb_color,ie.opacity*p,b));return se}function KMe(x,d,p,b,C=!1){if(d.stops.length===1){const Fe=d.stops[0];return v5(Fe.rgb_color,Fe.opacity*p,b)}const E=b5(d.transform),{fx:L,fy:R,fr:U,cx:K,cy:te,r:se}=d;let ie=new DOMPoint(L,R),de=new DOMPoint(K,te),fe=U,Te=se;if(C){ie=E.transformPoint(ie),de=E.transformPoint(de);const Fe=(E.a+E.d)/2;fe=U*Fe,Te=d.r*Fe}const ze=x.createRadialGradient(ie.x,ie.y,fe,de.x,de.y,Te);for(const Fe of d.stops)ze.addColorStop(Fe.offset,v5(Fe.rgb_color,Fe.opacity*p,b));return ze}function ZMe(x,d,p,b){const C=b.transform?b5(b.transform).preMultiplySelf(d):d,E=$P(x.canvas.width,x.canvas.height),L=E.getContext("2d");for(const U of b.children)if(U.group)ZMe(L,C,p,U.group);else if(U.path){const K=U.path,te=new Path2D;te.addPath(JMe(K),C),L.fill(te,HMe(K))}const R=b.clip_path_idx!=null?p.clip_paths[b.clip_path_idx]:null;R&&YMe(L,C,p,R),x.globalCompositeOperation="source-over",x.drawImage(E,0,0)}function YMe(x,d,p,b){const C=$P(x.canvas.width,x.canvas.height);ZMe(C.getContext("2d"),d,p,b),x.globalCompositeOperation="destination-in",x.drawImage(C,0,0)}function QMe(x,d,p,b,C){if(b.children.length===0)return;const E=b.mask_idx!=null?p.masks[b.mask_idx]:null;E&&QMe(x,d,p,E,C);const L=x.canvas.width,R=x.canvas.height,U=$P(L,R),K=U.getContext("2d"),te=b.width,se=b.height,ie=b.left,de=b.top,fe=new Path2D,Te=new Path2D;Te.rect(ie,de,te,se),fe.addPath(Te,d),K.clip(fe);for(const Qe of b.children)UMe(K,d,p,Qe,C);const ze=K.getImageData(0,0,L,R),Fe=ze.data;if(b.mask_type===zMe.MASK_TYPE_LUMINANCE)for(let Qe=0;Qed[L])return null}else{const R=1/b[L];let U=(x[L]-p[L])*R,K=(d[L]-p[L])*R;if(U>K){const te=U;U=K,K=te}if(U>C&&(C=U),KE)return null}return C}function sTe(x,d,p,b,C,E,L,R,U,K,te){const se=b-x,ie=C-d,de=E-p,fe=L-x,Te=R-d,ze=U-p,Fe=te[1]*ze-te[2]*Te,Qe=te[2]*fe-te[0]*ze,nt=te[0]*Te-te[1]*fe,ct=se*Fe+ie*Qe+de*nt;if(Math.abs(ct)<1e-15)return null;const kt=1/ct,yt=K[0]-x,Mt=K[1]-d,Rt=K[2]-p,Bt=(yt*Fe+Mt*Qe+Rt*nt)*kt;if(Bt<0||Bt>1)return null;const rs=Mt*de-Rt*ie,Gt=Rt*se-yt*de,us=yt*ie-Mt*se,Ss=(te[0]*rs+te[1]*Gt+te[2]*us)*kt;return Ss<0||Bt+Ss>1?null:(fe*rs+Te*Gt+ze*us)*kt}function rTe(x,d,p){return(x-d)/(p-d)}function nTe(x,d,p,b,C,E,L,R,U){const K=1<{const Qe=ze?1:0,nt=(de+1)*Te-Qe,ct=fe*Te,kt=(fe+1)*Te-Qe;Fe[0]=de*Te,Fe[1]=ct,Fe[2]=nt,Fe[3]=kt};let se=new eTe(U);const ie=[];for(let de=0;de=1;U/=2){const de=R[R.length-1];se=new eTe(U);for(let fe=0;fe0;){const{idx:fe,t:Te,nodex:ze,nodey:Fe,depth:Qe}=de.pop();if(this.leaves[fe]){nTe(ze,Fe,Qe,d,p,b,C,se,ie);const ct=1<=Ws[2])return Te}continue}let nt=0;for(let ct=0;ct=K[te[Rt]]&&(te.splice(Rt,0,ct),Mt=!0);Mt||(te[nt]=ct),nt++}}for(let ct=0;ct=this.dim+1||p<-1||p>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(p+1)*this.stride+(d+1)}static pack(d,p){const b=[0,0,0,0],C=I7.getUnpackVector(p);let E=Math.floor((d+C[3])/C[2]);return b[2]=E%256,E=Math.floor(E/256),b[1]=E%256,E=Math.floor(E/256),b[0]=E,b}getPixels(){return new eCe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,p,b){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let C=p*this.dim,E=p*this.dim+this.dim,L=b*this.dim,R=b*this.dim+this.dim;switch(p){case-1:C=E-1;break;case 1:E=C+1}switch(b){case-1:L=R-1;break;case 1:R=L+1}const U=-p*this.dim,K=-b*this.dim;for(let te=L;te=1;b--){const C=b===1?1:0,E=b===2?1:0;for(let L=0;L>>1^-(1&x[d]);return x}function Pmt(x,d){switch(d){case"uint32":return x;case"uint16":for(let p=0;p>4|(61440&b)>>8|(240&C)<<4|61440&C,x[p+1]=15&b|(3840&b)>>4|(15&C)<<8|(3840&C)<<4}return x;case"uint8":for(let p=0;p>6|(192&C)>>4|(192&E)>>2|192&L,x[p+1]=(48&b)>>4|(48&C)>>2|48&E|(48&L)<<2,x[p+2]=(12&b)>>2|12&C|(12&E)<<2|(12&L)<<4,x[p+3]=3&b|(3&C)<<2|(3&E)<<4|(3&L)<<6}return x;default:throw new Error(`Invalid pixel format, "${d}"`)}}Cr(I7,"DEMData"),Cr(aTe,"DemMinMaxQuadTree",{omit:["dem"]});var Wp=Uint8Array,UP=Uint16Array,Imt=Int32Array,oTe=new Wp([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]),lTe=new Wp([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]),Lmt=new Wp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cTe=function(x,d){for(var p=new UP(31),b=0;b<31;++b)p[b]=d+=1<>1|(21845&fc)<<1;hTe[fc]=((65280&(_5=(61680&(_5=(52428&_5)>>2|(13107&_5)<<2))>>4|(3855&_5)<<4))>>8|(255&_5)<<8)>>1}var VP=function(x,d,p){for(var b=x.length,C=0,E=new UP(d);C>U]=K;return L},HP=new Wp(288);for(fc=0;fc<144;++fc)HP[fc]=8;for(fc=144;fc<256;++fc)HP[fc]=9;for(fc=256;fc<280;++fc)HP[fc]=7;for(fc=280;fc<288;++fc)HP[fc]=8;var mTe=new Wp(32);for(fc=0;fc<32;++fc)mTe[fc]=5;var Rmt=VP(HP,9),Fmt=VP(mTe,5),Efe=function(x){for(var d=x[0],p=1;pd&&(d=x[p]);return d},wg=function(x,d,p){var b=d/8|0;return(x[b]|x[b+1]<<8)>>(7&d)&p},Pfe=function(x,d){var p=d/8|0;return(x[p]|x[p+1]<<8|x[p+2]<<16)>>(7&d)},zmt=["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"],jg=function(x,d,p){var b=new Error(d||zmt[x]);if(b.code=x,Error.captureStackTrace&&Error.captureStackTrace(b,jg),!p)throw b;return b},Bmt=new Wp(0),$mt=typeof TextDecoder<"u"&&new TextDecoder;try{$mt.decode(Bmt,{stream:!0})}catch{}const qmt={gzip_data:"gzip"};class ex extends Error{constructor(d){super(d),this.name="MRTError"}}const Umt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},pTe={uint32:1,uint16:2,uint8:4},Vmt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Ife;class L7{constructor(d=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=d}getLayer(d){const p=this.layers[d];if(!p)throw new ex(`Layer '${d}' not found`);return p}getHeaderLength(d){const p=new Uint8Array(d),b=new DataView(d);if(p[0]!==13)throw new ex("File is not a valid MRT.");return b.getUint32(1,!0)}parseHeader(d){const p=new Uint8Array(d),b=this.getHeaderLength(d);if(p.length= ${b} but got buffer of length ${p.length}`);const C=new Ife(p.subarray(0,b)).readFields(wmt,{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 ex(`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 fTe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const p=[],b=this.getLayer(d.layerName);for(let C of d.blockIndices){const E=b.dataIndex[C],L=E.firstByte-d.firstByte,R=E.lastByte-d.firstByte;if(b._blocksInProgress.has(C))continue;const U={layerName:b.name,firstByte:L,lastByte:R,pixelFormat:b.pixelFormat,blockIndex:C,blockShape:[E.bands.length].concat(b.bandShape),buffer:b.buffer,codec:E.codec.codec,filters:E.filters.map(K=>K.filter)};b._blocksInProgress.add(C),p.push(U)}return new xTe(p,()=>{p.forEach(C=>b._blocksInProgress.delete(C.blockIndex))},(C,E)=>{if(p.forEach(L=>b._blocksInProgress.delete(L.blockIndex)),C)throw C;E.forEach(L=>{this.getLayer(L.layerName).processDecodedData(L)})})}}class fTe{constructor({version:d,name:p,units:b,tileSize:C,pixelFormat:E,buffer:L,dataIndex:R},U){if(this.version=d,this.version!==1)throw new ex(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=p,this.units=b,this.tileSize=C,this.buffer=L,this.pixelFormat=Umt[E],this.dataIndex=R,this.bandShape=[C+2*L,C+2*L,pTe[this.pixelFormat]],this._decodedBlocks=new P7(U?U.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return pTe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:d})=>d).flat()}processDecodedData(d){const p=d.blockIndex.toString();this._decodedBlocks.get(p)||this._decodedBlocks.put(p,d.data)}getBlockForBand(d){let p=0;switch(typeof d){case"string":for(const[b,C]of this.dataIndex.entries()){for(const[E,L]of C.bands.entries())if(L===d)return{bandIndex:p+E,blockIndex:b,blockBandIndex:E};p+=C.bands.length}break;case"number":for(const[b,C]of this.dataIndex.entries()){if(d>=p&&dthis.cacheSize)throw new ex(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:p,lastByte:b,blockIndices:C}}hasBand(d){const{blockIndex:p}=this.getBlockForBand(d);return p>=0}hasDataForBand(d){const{blockIndex:p}=this.getBlockForBand(d);return p>=0&&!!this._decodedBlocks.get(p.toString())}getBandView(d){const{blockIndex:p,blockBandIndex:b}=this.getBlockForBand(d);if(p<0)throw new ex(`Band not found: ${JSON.stringify(d)}`);const C=this._decodedBlocks.get(p.toString());if(!C)throw new ex(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[p],L=this.bandShape.reduce((K,te)=>K*te,1),R=b*L,U=C.subarray(R,R+L);return{data:U,bytes:new Uint8Array(U.buffer).subarray(U.byteOffset,U.byteOffset+U.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}L7.setPbf=function(x){Ife=x};class xTe{constructor(d,p,b){this.tasks=d,this._onCancel=p,this._onComplete=b,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(d,p){this._finalized||(this._onComplete(d,p),this._finalized=!0)}}L7.performDecoding=function(x,d){const p=new Uint8Array(x);return Promise.all(d.tasks.map(b=>{const{layerName:C,firstByte:E,lastByte:L,pixelFormat:R,blockShape:U,blockIndex:K,filters:te,codec:se}=b,ie=p.subarray(E,L+1),de=new Uint32Array(U[0]*U[1]*U[2]);let fe;if(se!=="gzip_data")throw new ex(`Unhandled codec: ${se}`);return fe=function(Te,ze){if(!globalThis.DecompressionStream&&ze==="gzip_data")return Promise.resolve(((ct=function(Mt){Mt[0]==31&&Mt[1]==139&&Mt[2]==8||jg(6,"invalid gzip data");var Rt=Mt[3],Bt=10;4&Rt&&(Bt+=2+(Mt[10]|Mt[11]<<8));for(var rs=(Rt>>3&1)+(Rt>>4&1);rs>0;rs-=!Mt[Bt++]);return Bt+(2&Rt)}(nt=Te))+8>nt.length&&jg(6,"invalid gzip data"),function(Mt,Rt,Bt,rs){var Gt=Mt.length;if(!Gt||Rt.f&&!Rt.l)return Bt||new Wp(0);var us=!Bt,Ss=us||Rt.i!=2,Cs=Rt.i;us&&(Bt=new Wp(3*Gt));var Hs,Ws,Bs=function(Ii){var li=Bt.length;if(Ii>li){var xi=new Wp(Math.max(2*li,Ii));xi.set(Bt),Bt=xi}},Us=Rt.f||0,cs=Rt.p||0,as=Rt.b||0,Vs=Rt.l,nr=Rt.d,Ys=Rt.m,$r=Rt.n,fr=8*Gt;do{if(!Vs){Us=wg(Mt,cs,1);var jr=wg(Mt,cs+1,3);if(cs+=3,!jr){var Ir=Mt[(ms=4+((cs+7)/8|0))-4]|Mt[ms-3]<<8,ra=ms+Ir;if(ra>Gt){Cs&&jg(0);break}Ss&&Bs(as+Ir),Bt.set(Mt.subarray(ms,ra),as),Rt.b=as+=Ir,Rt.p=cs=8*ra,Rt.f=Us;continue}if(jr==1)Vs=Rmt,nr=Fmt,Ys=9,$r=5;else if(jr==2){var Qs=wg(Mt,cs,31)+257,Lr=wg(Mt,cs+10,15)+4,jn=Qs+wg(Mt,cs+5,31)+1;cs+=14;for(var Ca=new Wp(jn),Ia=new Wp(19),Hn=0;Hn>4)<16)Ca[Hn++]=ms;else{var hr=0,mr=0;for(ms==16?(mr=3+wg(Mt,cs,3),cs+=2,hr=Ca[Hn-1]):ms==17?(mr=3+wg(Mt,cs,7),cs+=3):ms==18&&(mr=11+wg(Mt,cs,127),cs+=7);mr--;)Ca[Hn++]=hr}}var Ur=Ca.subarray(0,Qs),Kr=Ca.subarray(Qs);Ys=Efe(Ur),$r=Efe(Kr),Vs=VP(Ur,Ys),nr=VP(Kr,$r)}else jg(1);if(cs>fr){Cs&&jg(0);break}}Ss&&Bs(as+131072);for(var zn=(1<>4;if((cs+=15&hr)>fr){Cs&&jg(0);break}if(hr||jg(2),wa<256)Bt[as++]=wa;else{if(wa==256){ta=cs,Vs=null;break}var un=wa-254;wa>264&&(un=wg(Mt,cs,(1<<(ti=oTe[Hn=wa-257]))-1)+uTe[Hn],cs+=ti);var _n=nr[Pfe(Mt,cs)&Yn],Za=_n>>4;if(_n||jg(3),cs+=15&_n,Kr=Omt[Za],Za>3){var ti=lTe[Za];Kr+=Pfe(Mt,cs)&(1<fr){Cs&&jg(0);break}Ss&&Bs(as+131072);var si=as+un;if(asHs.length)&&(Ws=Hs.length),new Wp(Hs.subarray(0,Ws))):Bt.subarray(0,as)}(nt.subarray(ct,-8),{i:2},new Wp(((Fe=nt)[(Qe=Fe.length)-4]|Fe[Qe-3]<<8|Fe[Qe-2]<<16|Fe[Qe-1]<<24)>>>0))));var Fe,Qe,nt,ct;const kt=qmt[ze];if(!kt)throw new Error(`Unhandled codec: ${ze}`);const yt=new globalThis.DecompressionStream(kt);return new Response(new Blob([Te]).stream().pipeThrough(yt)).arrayBuffer().then(Mt=>new Uint8Array(Mt))}(ie,se).then(Te=>(function(ze,Fe){ze.readFields(Mmt,Fe)}(new Ife(Te),de),new Vmt[R](de.buffer))),fe.then(Te=>{for(let ze=te.length-1;ze>=0;ze--)switch(te[ze]){case"delta_filter":Amt(Te,U);break;case"zigzag_filter":Emt(Te);break;case"bitshuffle_filter":Pmt(Te,R);break;default:throw new ex(`Unhandled filter "${te[ze]}"`)}return{layerName:C,blockIndex:K,data:Te}}).catch(Te=>{throw Te})}))},Cr(xTe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Cr(L7,"MapboxRasterTile"),Cr(fTe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class gTe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let p=0;p=0&&ie[3]>=0&&K.insert(U,ie[0],ie[1],ie[2],ie[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new d7(this.rawTileData)).layers,this.sourceLayerCoder=new gTe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const d in this.vtLayers)this.vtFeatures[d]=[]}return this.vtLayers}query(d,p){const{tilespaceGeometry:b,transform:C,tileTransform:E,pixelPosMatrix:L,availableImages:R,worldview:U}=p;this.loadVTLayers(),this.serializedLayersCache.clear();const K=p.queryRadius?p.queryRadius:0,te=b.bufferedTilespaceBounds,se=this.grid.query(te.min.x,te.min.y,te.max.x,te.max.y,(Te,ze,Fe,Qe)=>Vu(b.bufferedTilespaceGeometry,Te-K,ze-K,Fe+K,Qe+K));se.sort(Hmt);let ie=null;C.elevation&&se.length>0&&(ie=y5.create(C.elevation,this.tileID));const de={};let fe;for(let Te=0;Te(Qe||(Qe=Dt(nt,this.tileID.canonical,E)),ct.queryIntersectsFeature(b,nt,kt,Qe,this.z,C,L,ie,yt)))}return de}loadMatchingFeature(d,p,b,C,E,L){const{featureIndex:R,bucketIndex:U,sourceLayerIndex:K,layoutVertexArrayOffset:te}=p,se=this.bucketLayerIDs[U],ie=b.layers,de=Object.keys(ie);if(de.length&&!_r(de,se))return;const fe=b.sourceCache,Te=this.sourceLayerCoder.decode(K),ze=this.vtLayers[Te].feature(R),Fe=this.getId(ze,Te);for(let Qe=0;Qe`${R.key}: ${R.message}`).join(", ");return void gr(`Failed to create expression for promoteId: ${L}`)}this.promoteIdExpression=E.value}b=this.promoteIdExpression.evaluate({zoom:0},d)}else b=d.properties[C];typeof b=="boolean"&&(b=Number(b))}return b}}function vTe(x,d,p,b,C){return Xt(x,(E,L)=>{const R=d instanceof xv?d.get(L):null;return R&&R.evaluate?R.evaluate(p,b,void 0,C):R})}function Hmt(x,d){return d-x}Cr(yTe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const bTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Lfe{static from(d){if(!(d instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[p,b]=new Uint8Array(d,0,2);if(p!==219)throw new Error("Data does not appear to be in a KDBush format.");const C=b>>4;if(C!==1)throw new Error(`Got v${C} data when expected v1.`);const E=bTe[15&b];if(!E)throw new Error("Unrecognized array type.");const[L]=new Uint16Array(d,2,1),[R]=new Uint32Array(d,4,1);return new Lfe(R,L,E,d)}constructor(d,p=64,b=Float64Array,C){if(isNaN(d)||d<0)throw new Error(`Unpexpected numItems value: ${d}.`);this.numItems=+d,this.nodeSize=Math.min(Math.max(+p,2),65535),this.ArrayType=b,this.IndexArrayType=d<65536?Uint16Array:Uint32Array;const E=bTe.indexOf(this.ArrayType),L=2*d*this.ArrayType.BYTES_PER_ELEMENT,R=d*this.IndexArrayType.BYTES_PER_ELEMENT,U=(8-R%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${b}.`);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+U,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+L+R+U),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+U,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]=p,new Uint32Array(this.data,4,1)[0]=d)}add(d,p){const b=this._pos>>1;return this.ids[b]=b,this.coords[this._pos++]=d,this.coords[this._pos++]=p,b}finish(){const d=this._pos>>1;if(d!==this.numItems)throw new Error(`Added ${d} items when expected ${this.numItems}.`);return Dfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,p,b,C){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:L,nodeSize:R}=this,U=[0,E.length-1,0],K=[];for(;U.length;){const te=U.pop()||0,se=U.pop()||0,ie=U.pop()||0;if(se-ie<=R){for(let ze=ie;ze<=se;ze++){const Fe=L[2*ze],Qe=L[2*ze+1];Fe>=d&&Fe<=b&&Qe>=p&&Qe<=C&&K.push(E[ze])}continue}const de=ie+se>>1,fe=L[2*de],Te=L[2*de+1];fe>=d&&fe<=b&&Te>=p&&Te<=C&&K.push(E[de]),(te===0?d<=fe:p<=Te)&&(U.push(ie),U.push(de-1),U.push(1-te)),(te===0?b>=fe:C>=Te)&&(U.push(de+1),U.push(se),U.push(1-te))}return K}within(d,p,b){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:C,coords:E,nodeSize:L}=this,R=[0,C.length-1,0],U=[],K=b*b;for(;R.length;){const te=R.pop()||0,se=R.pop()||0,ie=R.pop()||0;if(se-ie<=L){for(let ze=ie;ze<=se;ze++)wTe(E[2*ze],E[2*ze+1],d,p)<=K&&U.push(C[ze]);continue}const de=ie+se>>1,fe=E[2*de],Te=E[2*de+1];wTe(fe,Te,d,p)<=K&&U.push(C[de]),(te===0?d-b<=fe:p-b<=Te)&&(R.push(ie),R.push(de-1),R.push(1-te)),(te===0?d+b>=fe:p+b>=Te)&&(R.push(de+1),R.push(se),R.push(1-te))}return U}}function Dfe(x,d,p,b,C,E){if(C-b<=p)return;const L=b+C>>1;_Te(x,d,L,b,C,E),Dfe(x,d,p,b,L-1,1-E),Dfe(x,d,p,L+1,C,1-E)}function _Te(x,d,p,b,C,E){for(;C>b;){if(C-b>600){const K=C-b+1,te=p-b+1,se=Math.log(K),ie=.5*Math.exp(2*se/3),de=.5*Math.sqrt(se*ie*(K-ie)/K)*(te-K/2<0?-1:1);_Te(x,d,p,Math.max(b,Math.floor(p-te*ie/K+de)),Math.min(C,Math.floor(p+(K-te)*ie/K+de)),E)}const L=d[2*p+E];let R=b,U=C;for(GP(x,d,b,p),d[2*C+E]>L&&GP(x,d,b,C);RL;)U--}d[2*b+E]===L?GP(x,d,b,U):(U++,GP(x,d,U,C)),U<=p&&(b=U+1),p<=U&&(C=U-1)}}function GP(x,d,p,b){Ofe(x,p,b),Ofe(d,2*p,2*b),Ofe(d,2*p+1,2*b+1)}function Ofe(x,d,p){const b=x[d];x[d]=x[p],x[p]=b}function wTe(x,d,p,b){const C=x-p,E=d-b;return C*C+E*E}i.$=X3,i.A=rg,i.B=Up,i.C=2,i.D=a5,i.E=As,i.F=CP,i.G=K5e,i.H=Q3,i.I=Js,i.J=SF,i.K=Br,i.L=ib,i.M=wC,i.N=f2,i.O=mF,i.P=ns,i.Q=x2,i.R=eg,i.S=PC,i.T=Vpe,i.U=Iy,i.V=S7,i.W=L6,i.X=ub,i.Y=db,i.Z=c2,i._=$u,i.a=function(x){return ya.API_CDN_URL_REGEX.test(x)},i.a$=we,i.a0=bn,i.a1=xa,i.a2=Zf,i.a3=class extends S7{},i.a4=jC,i.a5=hF,i.a6=Kt,i.a7=function(x){const d=x.value;return d?bn(d)?_fe(d,!0)?[]:[new S7(x.key,d,`invalid url "${d}"`)]:[new S7(x.key,d,`string expected, "${Br(d)}" found`)]:[]},i.a8=wF,i.a9=Oo,i.aA=je,i.aB=S,i.aC=tt,i.aD=Gd,i.aE=Ri,i.aF=W,i.aG=ot,i.aH=function(x,d){const p={};for(let b=0;b{b(E,L)},d):b(E,L),()=>{}}return C.callbacks.push(b),C.cancel||(C.cancel=p((E,L)=>{C.result=[E,L];for(const R of C.callbacks)this.scheduler?this.scheduler.add(()=>{R(E,L)},d):R(E,L);setTimeout(()=>delete this.entries[x],3e3)})),()=>{C.result||(C.callbacks=C.callbacks.filter(E=>E!==b),C.callbacks.length||(C.cancel(),delete this.entries[x]))}}},i.aL=function(x,d,p){const b=JSON.stringify(x.request);return x.data&&(this.deduped.entries[b]={result:[null,x.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:x.isSymbolTile,zoom:x.tileZoom},C=>{const E=Fh(x.request,(L,R,U)=>{L?C(L):R&&C(null,{rawData:R,vectorTile:p?void 0:new Yt(new d7(R)),responseHeaders:new Map(U.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=Il,i.aO=function(x){Td++,Td>tb&&(x.getActor().send("enforceCacheSizeLimit",eb),Td=0)},i.aP=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.aQ=Ao,i.aR=jMe,i.aS=TMe,i.aT=v,i.aU=wMe,i.aV=function(x,d){const p=document.createElement("video");p.muted=!0,p.onloadstart=function(){d(null,p)};for(let b=0;b{}}},i.aW=wP,i.aX=B2,i.aY=qt,i.aZ=EP,i.a_=le,i.aa=Xs,i.ab=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return Dn(x.expression.evaluate(d))}interpolate(x,d,p){return{x:Xr(x.x,d.x,p),y:Xr(x.y,d.y,p),z:Xr(x.z,d.z,p),azimuthal:Xr(x.azimuthal,d.azimuthal,p),polar:Xr(x.polar,d.polar,p)}}},i.ac=Yi,i.ad=mv,i.ae=at,i.af=dt,i.ag=ce,i.ah=$e,i.ai=xv,i.aj=Ab,i.ak=Xr,i.al=sr,i.am=iv,i.an=xr,i.ao=Wr,i.ap=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return function([p,b]){const C=Dn([1,p,b]);return{x:C.x,y:C.y,z:C.z}}(x.expression.evaluate(d))}interpolate(x,d,p){return{x:Xr(x.x,d.x,p),y:Xr(x.y,d.y,p),z:Xr(x.z,d.z,p)}}},i.aq=function(x,d,p=0,b=!0){const C=new ns(p,p),E=x.sub(C),L=d.add(C),R=[E,new ns(L.x,E.y),L,new ns(E.x,L.y)];return b&&R.push(E.clone()),R},i.ar=function(x,d){const p=[];for(let b=0;b1)return!1;const p=d.getSource().maxzoom,b=1<1)return d;const C=b.getSource().maxzoom,E=1<{const R=this.getAtTileOffset(x,C,E,L),U=b.upVector(x.canonical,C.x,C.y);return _e(U,U,R*b.upVectorScale(x.canonical,d,p).metersToTile),U}}getForTilePoints(x,d,p,b){if(this.isUsingMockSource())return!1;const C=y5.create(this,x,b);return!!C&&(d.forEach(E=>{E[2]=this.exaggeration()*C.getElevationAt(E[0],E[1],p)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const d=this.findDEMTileFor(x);if(!d||!d.dem)return null;const p=d.dem.tree,b=d.tileID,C=1<0&&(b+=(x[C]-0)*(x[C]-0)),d[C]<0&&(b+=(0-d[C])*(0-d[C]));return b},i.c0=jCe,i.c1=afe,i.c2=tMe,i.c3=mfe,i.c4=Lfe,i.c5=_e,i.c6=Ge,i.c7=rt,i.c8=function(x,d,p){p*=.5;var b=d[0],C=d[1],E=d[2],L=d[3],R=Math.sin(p),U=Math.cos(p);return x[0]=b*U+C*R,x[1]=C*U-b*R,x[2]=E*U+L*R,x[3]=L*U-E*R,x},i.c9=it,i.cA=J,i.cB=oi,i.cC=o5e,i.cD=Fi,i.cE=F3e,i.cF=function(x,d,p,b,C,E,L,R,U){if(U.name==="globe")return F3e(x,d,new Fi(p,b,C),!1);const K=EP({z:p,x:b,y:C},U);return new Fr([(E+K.x/K.scale)*d,d*(K.y/K.scale),L],[(E+K.x2/K.scale)*d,d*(K.y2/K.scale),R])},i.cG=function(x,d,p){return x[0]=Math.min(d[0],p[0]),x[1]=Math.min(d[1],p[1]),x[2]=Math.min(d[2],p[2]),x[3]=Math.min(d[3],p[3]),x},i.cH=function(x,d,p){return x[0]=Math.max(d[0],p[0]),x[1]=Math.max(d[1],p[1]),x[2]=Math.max(d[2],p[2]),x[3]=Math.max(d[3],p[3]),x},i.cI=function(x){const d=Math.round((x+45+360)%360/90)%4;return ai[d]},i.cJ=Ne,i.cK=He,i.cL=s5,i.cM=function(x){const d=j(new Float64Array(16));S(d,x.pixelMatrix,x.globeMatrix);const p=[0,np,0],b=[0,ap,0];return dt(p,p,d),dt(b,b,d),[p[0]>0&&p[0]<=x.width&&p[1]>0&&p[1]<=x.height&&!_pe(x,new v(x.center.lat,90)),b[0]>0&&b[0]<=x.width&&b[1]>0&&b[1]<=x.height&&!_pe(x,new v(x.center.lat,-90))]},i.cN=function(x,d){const{scale:p}=x.tileTransform,b=p*sr/(x.tileSize*Math.pow(2,d.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(C,E,L){var R=E[1],U=E[2],K=E[3],te=L[0],se=L[1];return C[0]=E[0]*te,C[1]=R*te,C[2]=U*se,C[3]=K*se,C}(new Float32Array(4),d.inverseAdjustmentMatrix,[b,b])},i.cO=n7,i.cP=Y,i.cQ=i5e,i.cR=function(x){const d=i5e(x,!0);return m([],[d[0],d[1],d[4],d[5]])},i.cS=I,i.cT=pr,i.cU=P,i.cV=function(x){const{x:d,y:p}=x.point,{lng:b,lat:C}=x._center;return $3e(d,p,x.worldSize,b,C)},i.cW=xe,i.cX=Wn,i.cY=So,i.cZ=Ed,i.c_=rp,i.ca=ii,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=X,i.cd=function(x,d,p,b,C){var E=1/Math.tan(d/2);if(x[0]=E/p,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 L=1/(b-C);x[10]=(C+b)*L,x[14]=2*C*b*L}else x[10]=-1,x[14]=-2*b;return x},i.ce=function(x,d,p,b,C,E,L){var R=1/(d-p),U=1/(b-C),K=1/(E-L);return x[0]=-2*R,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=-2*U,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=2*K,x[11]=0,x[12]=(d+p)*R,x[13]=(C+b)*U,x[14]=(L+E)*K,x[15]=1,x},i.cf=ae,i.cg=function(x,d,p){x[4*d+0]=p[0],x[4*d+1]=p[1],x[4*d+2]=p[2],x[4*d+3]=p[3]},i.ch=XC,i.ci=k2,i.cj=Wl,i.ck=Xf,i.cl=C2,i.cm=hMe,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,p){var b=d[0],C=d[1],E=d[2],L=d[3],R=Math.sin(p),U=Math.cos(p);return x[0]=b*U+E*R,x[1]=C*U+L*R,x[2]=b*-R+E*U,x[3]=C*-R+L*U,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],p=x[1],b=x[2],C=x[3];return Math.sqrt(d*d+p*p+b*b+C*C)},i.cs=Ts,i.ct=Ue,i.cu=xl,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=ve,i.d=function(x){return ya.API_TILEJSON_REGEX.test(x)},i.d$=class{constructor(x,d,p,b){this.context=x,this.format=b,this.size=p,this.texture=x.gl.createTexture();const[C,E,L]=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,L,0,qpe(this.format),Upe(this.format),d.data)}bind(x,d){const{context:p}=this,{gl:b}=p;b.bindTexture(b.TEXTURE_3D,this.texture),x!==this.minFilter&&(b.texParameteri(b.TEXTURE_3D,b.TEXTURE_MAG_FILTER,x),b.texParameteri(b.TEXTURE_3D,b.TEXTURE_MIN_FILTER,x),this.minFilter=x),d!==this.wrapS&&(b.texParameteri(b.TEXTURE_3D,b.TEXTURE_WRAP_S,d),b.texParameteri(b.TEXTURE_3D,b.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=B,i.d2=45,i.d3=JC,i.d4=function(x,d,p){const b=Math.sqrt(x*x+d*d+p*p),C=b>0?Math.acos(p/b)*Mr:0;let E=x!==0||d!==0?Math.atan2(-d,-x)*Mr+90:0;return E<0&&(E+=360),[b,E,C]},i.d5=ne,i.d6=Dn,i.d7=Ve,i.d8=oe,i.d9=Fr,i.dA=function(x){return x({pluginStatus:qu,pluginURL:cg}),AC.on("pluginStateChange",x),x},i.dB=S2,i.dC=class extends hg{constructor(x){super(x),this.current=e5}set(x,d,p){if(this.fetchUniformLocation(x,d)){for(let b=0;b<9;b++)if(p[b]!==this.current[b]){this.current=p,this.gl.uniformMatrix3fv(this.location,!1,p);break}}}},i.dD=Aa,i.dE=function(x,d,p){const b=Ab(p.zoom),C=x.style.map._antialias,E=x.terrain&&x.terrain.exaggeration()>0;return b===0&&!C&&!E},i.dF=function(x){const d=x.pixelsPerMeter,p=d/ae(1,x.center.lat),b=j(new Float64Array(16));return M(b,b,[x.point.x,x.point.y,0]),I(b,b,[p,p,d]),Float32Array.from(b)},i.dG=qF,i.dH=function(x){const d=Ne-5;x=je(x,-d,d)/d*90;const p=Math.pow(Math.abs(Math.sin(xr(x))),3);return Math.round(p*(aP.length-1))},i.dI=function(x,d,p,b){const C=d.getNorth(),E=d.getSouth(),L=d.getWest(),R=d.getEast(),U=1<0){const fe=180/b;y(de,de,[fe/K+1,0,0,0,fe/te+1,0,-.5*fe/se,.5*fe/ie,1])}return de[2]=U,de[5]=x.x,de[8]=x.y,de},i.dJ=Gp,i.dK=function(x,d,p){const b=j(new Float64Array(16)),C=(d/(1<({u_matrix:new C2(x),u_texsize:new Xf(x),u_pixels_to_tile_units:new t5(x),u_device_pixel_ratio:new Wl(x),u_width_scale:new Wl(x),u_floor_width_scale:new Wl(x),u_image:new XC(x),u_units_to_pixels:new Xf(x),u_tile_units_to_pixels:new Wl(x),u_alpha_discard_threshold:new Wl(x),u_trim_offset:new Xf(x),u_trim_fade_range:new Xf(x),u_trim_color:new JC(x),u_zbias_factor:new Wl(x),u_tile_to_meter:new Wl(x),u_ground_shadow_factor:new k2(x),u_pattern_transition:new Wl(x)}),i.dX=x=>({u_matrix:new C2(x),u_pixels_to_tile_units:new t5(x),u_device_pixel_ratio:new Wl(x),u_width_scale:new Wl(x),u_floor_width_scale:new Wl(x),u_units_to_pixels:new Xf(x),u_dash_image:new XC(x),u_gradient_image:new XC(x),u_image_height:new Wl(x),u_texsize:new Xf(x),u_tile_units_to_pixels:new Wl(x),u_alpha_discard_threshold:new Wl(x),u_trim_offset:new Xf(x),u_trim_fade_range:new Xf(x),u_trim_color:new JC(x),u_zbias_factor:new Wl(x),u_tile_to_meter:new Wl(x),u_ground_shadow_factor:new k2(x)}),i.dY=x=>({u_camera_to_center_distance:new Wl(x),u_extrude_scale:new t5(x),u_device_pixel_ratio:new Wl(x),u_matrix:new C2(x),u_inv_rot_matrix:new C2(x),u_merc_center:new Xf(x),u_tile_id:new k2(x),u_zoom_transition:new Wl(x),u_up_dir:new k2(x),u_emissive_strength:new Wl(x)}),i.dZ=UC,i.d_=sht,i.da=he,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=a5e,i.dd=Ype,i.de=d5e,i.df=_fe,i.dg=function(x,d){return x.readFields(tmt,{icons:[]},d)},i.dh=e7,i.di=p5,i.dj=dfe,i.dk=sb,i.dl=v2,i.dm=_y,i.dn=rb,i.dp=Ns,i.dq=function(x){const d=x.indexOf(vv);return d>=0?x.slice(0,d):x},i.dr=function(x){return x.indexOf(vv)>=0},i.ds=function(x){const d=x.lastIndexOf(vv);return d>=0?x.slice(d+1):""},i.dt=function(x){const d=[],p=x.id;return p===void 0&&d.push({message:`layers.${p}: missing required property "id"`}),x.render===void 0&&d.push({message:`layers.${p}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&d.push({message:`layers.${p}: property "renderingMode" must be either "2d" or "3d"`}),d},i.du=function(x,d,p,b){return x.type==="custom"?new Kht(x,d):new Jht[x.type](x,d,p,b)},i.dv=Os,i.dw=function(x){const d=x.indexOf(vv);return d>=0?x.slice(d+1):""},i.dx=class extends z2{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=AC,i.dz=tg,i.e=ya,i.e$=re,i.e0=V3e,i.e1=(x,d,p,b,C,E)=>{const L=x.transform,R=L.projection.name==="globe";let U;if(E.paint.get("circle-pitch-alignment")==="map")if(R){const te=B3e(L.zoom,d.canonical)*L._pixelsPerMercatorPixel;U=Float32Array.from([te,0,0,te])}else U=L.calculatePixelsToTileUnitsMatrix(p);else U=new Float32Array([L.pixelsToGLUnits[0],0,0,L.pixelsToGLUnits[1]]);const K={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(L.projection),u_matrix:x.translatePosMatrix(d.projMatrix,p,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Hl.devicePixelRatio,u_extrude_scale:U,u_inv_rot_matrix:ydt,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){K.u_inv_rot_matrix=b,K.u_merc_center=C,K.u_tile_id=[d.canonical.x,d.canonical.y,1<{const te=x.transform,se=te.pitch<15?j5e(.07,.7,je((14-te.zoom)/5,0,1)):.07,ie=p.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:k5e(x,d,p,b),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:L,u_image:0,u_tile_units_to_pixels:N5e(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:p.paint.get("line-trim-fade-range"),u_trim_color:p.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:p.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:U,u_pattern_transition:K}},i.e5=(x,d,p,b,C,E,L,R,U,K)=>{const te=x.transform,se=te.calculatePixelsToTileUnitsMatrix(d),ie=p.paint.get("line-trim-color-use-theme").constantOr("default")==="none",de=te.pitch<15?j5e(.07,.7,je((14-te.zoom)/5,0,1)):.07;return{u_matrix:k5e(x,d,p,b),u_pixels_to_tile_units:se,u_device_pixel_ratio:E,u_width_scale:L,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:C5e(p)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:N5e(d,x.transform),u_alpha_discard_threshold:0,u_trim_offset:U,u_trim_fade_range:p.paint.get("line-trim-fade-range"),u_trim_color:p.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:p.lut).toArray01(),u_zbias_factor:de,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:K}},i.e6=Zt,i.e7=oP,i.e8=be,i.e9=op,i.eA=function(x,d){var p=2*Math.acos(d[3]),b=Math.sin(p/2);return b>c?(x[0]=d[0]/b,x[1]=d[1]/b,x[2]=d[2]/b):(x[0]=1,x[1]=0,x[2]=0),p},i.eB=Nfe,i.eC=o7,i.eD=i7,i.eE=[1,1,1],i.eF=y5,i.eG=lt,i.eH=function(x,d,p,b){var C=d[0],E=d[1],L=d[2],R=d[3];return x[0]=C+b*(p[0]-C),x[1]=E+b*(p[1]-E),x[2]=L+b*(p[2]-L),x[3]=R+b*(p[3]-R),x},i.eI=c5,i.eJ=xm,i.eK=Qf,i.eL=function(x,d,p,b,C,E,L,R,U,K,te,se,ie,de,fe,Te){var ze=new u(16);return ze[0]=x,ze[1]=d,ze[2]=p,ze[3]=b,ze[4]=C,ze[5]=E,ze[6]=L,ze[7]=R,ze[8]=U,ze[9]=K,ze[10]=te,ze[11]=se,ze[12]=ie,ze[13]=de,ze[14]=fe,ze[15]=Te,ze},i.eM=T,i.eN=Nb,i.eO=Z6,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new ns(1/0,1/0),max:new ns(-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 p=bCe(new ns(0,0),new ns(sr,sr),x),b=[];if(d&&!Ape(p,this._globalClipBounds))return b;for(const C of this._activeRegions){if(C.hiddenByOverlap||!Ape(p,C))continue;const E=Wdt(C.min,C.max,x);b.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 b}setSources(x){this._setSources(x.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const p=[];for(const b of d.cache.getVisibleCoordinates()){const C=d.cache.getTile(b).buckets[d.layer];C&&C.updateFootprints(b.toUnwrapped(),p)}return p},getOrder:()=>d.order,getClipMask:()=>d.clipMask,getClipScope:()=>d.clipScope})))}_addSource(x){const d=x.getFootprints();if(d.length===0)return;const p=x.getOrder(),b=x.getClipMask(),C=x.getClipScope();for(const E of d){if(!E.footprint)continue;const L=bCe(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:L.min,max:L.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:p,clipMask:b,clipScope:C})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,p)=>d.priority-p.priority||ZF(d.min,p.min)||ZF(d.max,p.max)||d.order-p.order||d.clipMask-p.clipMask||function(b,C){const E=(L,R)=>L+R;return b.length-C.length||b.reduce(E,"").localeCompare(C.reduce(E,""))}(d.clipScope,p.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let d=0;for(;!x&&d!==this._activeRegions.length;){const p=this._activeRegions[d],b=this._prevRegions[d];x=p.priority!==b.priority||!vCe(p,b)||p.order!==b.order||p.clipMask!==b.clipMask||!Wt(p.clipScope,b.clipScope),this._activeRegions[d].hiddenByOverlap=b.hiddenByOverlap,++d}}if(x){++this._updateTime;for(const p of this._activeRegions)p.order!==mP&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,p.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,p.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,p.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,p.max.y));const d=p=>{const b=this._activeRegions;if(p>=b.length)return p;const C=b[p].priority;for(;p1){let p=0,b=d(p);for(;p!==b;){let C=p;const E=p;for(;C!==b;){const L=this._activeRegions[C];L.hiddenByOverlap=!1;for(let R=0;R=0;d--)this._addSource(x[d]);this._computeReplacement()}},i.eQ=mP,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 p=new Dy,b=new Gl,C=[],E=x+1+2,L=d[0]+1,R=d[0]+1+(1+d.length),U=(K,te,se)=>{let ie=K===E-1?K-2:K===0?K:K-1;return ie+=se?24575:0,[ie,te]};for(let K=0;K0?(ze=2*Math.sqrt(Te+1),x[3]=.25*ze,x[0]=(se-de)/ze,x[1]=(ie-U)/ze,x[2]=(R-K)/ze):L>te&&L>fe?(ze=2*Math.sqrt(1+L-te-fe),x[3]=(se-de)/ze,x[0]=.25*ze,x[1]=(R+K)/ze,x[2]=(ie+U)/ze):te>fe?(ze=2*Math.sqrt(1+te-L-fe),x[3]=(ie-U)/ze,x[0]=(R+K)/ze,x[1]=.25*ze,x[2]=(se+de)/ze):(ze=2*Math.sqrt(1+fe-L-te),x[3]=(R-K)/ze,x[0]=(ie+U)/ze,x[1]=(se+de)/ze,x[2]=.25*ze),x},i.f=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(d,p)=>String.fromCharCode(+("0x"+p))))},i.f0=function([x,d,p]){const b=Math.hypot(x,d,p),C=Math.atan2(x,p),E=.5*Math.PI-Math.acos(-d/b);return new v(Wn(C),Wn(E))},i.f1=We,i.f2=Hpe,i.f3=function(x){const d=x.navigator?x.navigator.userAgent:null;return!!function(p){if(cl==null){const b=p.navigator?p.navigator.userAgent:null;cl=!!p.safari||!(!b||!(/\b(iPad|iPhone|iPod)\b/.test(b)||b.match("Safari")&&!b.match("Chrome")))}return cl}(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){eb=x,tb=d},i.f5=_pe,i.f6=q3e,i.f7=function(x){const d=[0,0,0],p=j(new Float64Array(16));return S(p,x.pixelMatrix,x.globeMatrix),dt(d,d,p),new ns(d[0],d[1])},i.f8=function(){const x=vP;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(Ope),vP=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(){e7().acquire(Ope)},i.fA=I7,i.fB=Ut,i.fC=function(x){let d=0;if(new Uint32Array(x,0,1)[0]!==e5e){const p=new Uint32Array(x,0,7),[,,b,C,E,L]=p;d=p.byteLength+C+E+L+E,(b!==x.byteLength||d>=x.byteLength)&&gr("Invalid b3dm header information.")}return n5e(x,d)},i.fD=function(x,d){const p=Ype(x);for(const b of p){for(const C of b.meshes)Nut(C);b.lights&&(b.lightMeshIndex=b.meshes.length,b.meshes.push(kut(b.lights,d)))}return p},i.fE=C7,i.fF=ka,i.fG=ZCe,i.fH=dg,i.fI=zh,i.fJ=function(x){Vd(),dm!=null&&dm.then(d=>{d.keys().then(p=>{for(let b=0;bgr(C.message))}).catch(p=>gr(p.message))}).catch(d=>gr(d.message))},i.fa=b2,i.fb=function(x,d,p=!1){if(qu===zh.deferred||qu===zh.loading||qu===zh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");cg=Hl.resolveURL(x),qu=zh.deferred,F6=d,TC(),p||_F()},i.fc=function(x){i5=Hl.resolveURL(x),o5||(o5=new a5(e7(),new As)),o5.broadcast("setMeshoptUrl",i5)},i.fd=XCe,i.fe=function(x){zpe=Hl.resolveURL(x),o5||(o5=new a5(e7(),new As)),o5.broadcast("setDracoUrl",zpe)},i.ff=QCe,i.fg=yP,i.fh=function(x){const d=um();if(!d)return;const p=d.delete(J1);x&&p.then(()=>x()).catch(x)},i.fi=L2,i.fj=Cr,i.fk=Eb,i.fl=_g,i.fm=gTe,i.fn=yTe,i.fo=v5e,i.fp=is,i.fq="hd_road_elevation",i.fr=pi,i.fs=Xt,i.ft=jv,i.fu=cfe,i.fv=R2,i.fw=function(x,d,p,b,C,E,L,R=1,U,K,te){x.createArrays(),x.tilePixelRatio=sr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const se=x.layers[0].layout,ie=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[fe,Te]=de.textSizeScaleRange,[ze,Fe]=de.iconSizeScaleRange;de.textScaleFactor=je(de.scaleFactor,fe,Te),de.iconScaleFactor=je(de.scaleFactor,ze,Fe);const Qe=ie["text-size"],nt=ie["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:Bt,maxZoom:rs}=x.textSizeData;de.compositeTextSizes=[Qe.possiblyEvaluate(new Yi(Bt,{worldview:te}),E),Qe.possiblyEvaluate(new Yi(rs,{worldview:te}),E)]}if(x.iconSizeData.kind==="composite"){const{minZoom:Bt,maxZoom:rs}=x.iconSizeData;de.compositeIconSizes=[nt.possiblyEvaluate(new Yi(Bt,{worldview:te}),E),nt.possiblyEvaluate(new Yi(rs,{worldview:te}),E)]}de.layoutTextSize=Qe.possiblyEvaluate(new Yi(L+1,{worldview:te}),E),de.layoutIconSize=nt.possiblyEvaluate(new Yi(L+1,{worldview:te}),E),de.textMaxSize=Qe.possiblyEvaluate(new Yi(18,{worldview:te}),E);const ct=se.get("symbol-placement"),kt=se.get("text-rotation-alignment")==="map"&&ct!=="point",yt=se.get("text-size");let Mt=!1;const Rt=[];for(const Bt of x.features){const rs=se.get("text-font").evaluate(Bt,{},E).join(","),Gt=yt.evaluate(Bt,{},E)*de.textScaleFactor,us=de.layoutTextSize.evaluate(Bt,{},E)*de.textScaleFactor,Ss=de.layoutIconSize.evaluate(Bt,{},E)*de.iconScaleFactor,Cs={horizontal:{},vertical:void 0},Hs=Bt.text;let Ws,Bs=[0,0];if(Hs){const Hn=Hs.toString(),Pi=se.get("text-letter-spacing").evaluate(Bt,{},E)*Pc,bt=se.get("text-line-height").evaluate(Bt,{},E)*Pc,St=O6(Hn)?Pi:0,ms=se.get("text-anchor").evaluate(Bt,{},E),Gs=se.get("text-variable-anchor");if(!Gs){const zn=se.get("text-radial-offset").evaluate(Bt,{},E);if(zn)Bs=tMe(ms,[zn*Pc,hfe]);else{const Yn=se.get("text-offset").evaluate(Bt,{},E);Bs=[Yn[0]*Pc,Yn[1]*Pc]}}let hr=kt?"center":se.get("text-justify").evaluate(Bt,{},E);const mr=ct==="point",Ur=mr?se.get("text-max-width").evaluate(Bt,{},E)*Pc:1/0,Kr=zn=>{x.allowVerticalPlacement&&y2(Hn)&&(Cs.vertical=nfe(Hs,d,p,C,rs,Ur,bt,ms,zn,St,Bs,vm.vertical,!0,us,Gt,U))};if(!kt&&Gs){const zn=hr==="auto"?Gs.map(ta=>mfe(ta)):[hr];let Yn=!1;for(let ta=0;ta=0||!y2(Hn)){const zn=nfe(Hs,d,p,C,rs,Ur,bt,ms,hr,St,Bs,vm.horizontal,!1,us,Gt,U);zn&&(Cs.horizontal[hr]=zn)}Kr(mr?"left":hr)}}let Us,cs,as,Vs,nr,Ys,$r=!1;const fr=se.get("icon-text-fit").evaluate(Bt,{},E);if(Bt.icon&&Bt.icon.hasPrimary()){const Hn=TP(Bt.icon,x.iconSizeData,ie["icon-size"],E,x.zoom,Bt,U,de.iconScaleFactor,te);Us=Hn.iconPrimary,as=Hn.iconSecondary;const Pi=Us.toString();if(cs=b.get(Pi),cs&&(nr=se.get("icon-offset").evaluate(Bt,{},E),Ys=se.get("icon-anchor").evaluate(Bt,{},E),Ws=h7(C.get(Pi),as?C.get(as.toString()):void 0,nr,Ys),$r=cs.sdf,x.sdfIcons===void 0?x.sdfIcons=cs.sdf:x.sdfIcons!==cs.sdf&&gr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(cs.pixelRatio!==x.pixelRatio||se.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),as){const bt=as.toString();Vs=b.get(bt)}}Mt=Mt||!(!Bt.icon||!Bt.icon.hasSecondary());const jr=g7(Cs.horizontal)||Cs.vertical;x.iconsInText||(x.iconsInText=!!jr&&jr.iconsInText);const Ir=us*de.textScaleFactor/Pc,{defaultShapedIcon:ra,verticallyShapedIcon:Qs}=Iht(x,Ws,se,Bt,E,Cs,Ir,nr,fr);fr!=="none"&&Ws&&(B5e(Ws)||$5e(Ws))&&(x7(0,cs,Us,Ws,ra,fr,K,b,C),x7(0,Vs,as,Ws,ra,fr,K,b,C),Qs&&(x7(0,cs,Us,Ws,Qs,fr,K,b,C),x7(0,Vs,as,Ws,Qs,fr,K,b,C))),Ws=ra;const{iconBBox:Lr,iconVerticalBBox:jn,textBBox:Ca,textVerticalBBox:Ia}=Mht(x,Ws,Qs,se,Bt,E,Ss,nr,de,C,Ys,Cs,us,Bs);Rt.push({feature:Bt,shapedTextOrientations:Cs,shapedText:jr,shapedIcon:Ws,iconPrimary:Us,iconSecondary:as,iconOffset:nr,iconAnchor:Ys,verticallyShapedIcon:Qs,layoutTextSize:us,layoutIconSize:Ss,textOffset:Bs,isSDFIcon:$r,iconTextFit:fr,iconCollisionBounds:Lr,iconVerticalCollisionBounds:jn,textCollisionBounds:Ca,textVerticalCollisionBounds:Ia})}return{featureData:Rt,sizes:de,hasAnySecondaryIcon:Mt,textAlongLine:kt,symbolPlacement:ct}},i.fx=Z5e,i.fy=function(x,d,p,b,C,E,L,R,U,K){x.iconAtlasPositions=K.iconPositions;const{featureData:te,hasAnySecondaryIcon:se,sizes:ie,textAlongLine:de,symbolPlacement:fe}=d;for(const Te of te){const{shapedIcon:ze,verticallyShapedIcon:Fe,feature:Qe,shapedTextOrientations:nt,shapedText:ct,layoutTextSize:kt,textOffset:yt,isSDFIcon:Mt,iconPrimary:Rt,iconSecondary:Bt,iconTextFit:rs,iconOffset:Gt,iconCollisionBounds:us,iconVerticalCollisionBounds:Ss,textCollisionBounds:Cs}=Te;rMe(ze,K.iconPositions,Rt,Bt),rMe(Fe,K.iconPositions,Rt,Bt),Pht(nt,K.iconPositions),Eht(Rt,Bt,K.iconPositions),(ct||ze)&&Lht(x,Qe,nt,ze,Fe,U,ie,kt,0,yt,Mt,b,C,L,R,se,rs,Gt,de,fe,us,Ss,Cs)}p&&x.generateCollisionDebugBuffers(E,x.collisionBoxArray,ie.textScaleFactor)},i.fz=Yt,i.g=function(x,d){return tg(Object.assign(x,{method:"GET"}),d)},i.h=function(x){return x.indexOf("mapbox:")===0},i.i=function(x){return ya.API_STYLE_REGEX.test(x)&&!Ac(x)},i.j=po,i.k=pu,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 tg(Object.assign(x,{type:"json"}),d)},i.n=wy,i.o=Hl,i.p=function(x,d){return tg(Object.assign(x,{method:"POST"}),d)},i.q=Zd,i.r=Zm,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 Rpe||(Rpe=new L2("ImageRasterizer")),Rpe},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=gr,i.x=Afe,i.y=jy,i.z=Xm}),o(["./shared"],function(i){function c($t){const je=$t?$t.url.toString():void 0;return je?performance.getEntriesByName(je):[]}function u($t){if(typeof $t=="number"||typeof $t=="boolean"||typeof $t=="string"||$t==null)return JSON.stringify($t);if(Array.isArray($t)){let $e="[";for(const st of $t)$e+=`${u(st)},`;return`${$e}]`}let je="{";for(const $e of Object.keys($t).sort())je+=`${$e}:${u($t[$e])},`;return`${je}}`}function m($t){let je="";for(const $e of i.bx)je+=`/${u($t[$e])}`;return je}class f{constructor(je){this.keyCache={},this._layers={},this._layerConfigs={},je&&this.replace(je)}replace(je,$e){this._layerConfigs={},this._layers={},this.update(je,[],$e)}update(je,$e,st){this._options=st;for(const xt of je)this._layerConfigs[xt.id]=xt,(this._layers[xt.id]=i.du(xt,this.scope,null,this._options)).compileFilter(st),this.keyCache[xt.id]&&delete this.keyCache[xt.id];for(const xt of $e)delete this.keyCache[xt],delete this._layerConfigs[xt],delete this._layers[xt];this.familiesBySource={};const vt=function(xt,Ot){const Zt={};for(let Xt=0;Xtthis._layers[_r.id]),Zt=Ot[0];if(Zt.visibility==="none")continue;const qt=Zt.source||"";let Xt=this.familiesBySource[qt];Xt||(Xt=this.familiesBySource[qt]={});const Os=Zt.sourceLayer||"_geojsonTileLayer";let Ns=Xt[Os];Ns||(Ns=Xt[Os]=[]),Ns.push(Ot)}}}const g=1*i.fl;class y{constructor(je){const $e={},st=[];for(const Zt in je){const qt=je[Zt],Xt=$e[Zt]={};for(const Os in qt.glyphs){const Ns=qt.glyphs[+Os];if(!Ns||Ns.bitmap.width===0||Ns.bitmap.height===0)continue;const _r=Ns.metrics.localGlyph?g:1,Zr={x:0,y:0,w:Ns.bitmap.width+2*_r,h:Ns.bitmap.height+2*_r};st.push(Zr),Xt[Os]=Zr}}const{w:vt,h:xt}=i.G(st),Ot=new i.fk({width:vt||1,height:xt||1});for(const Zt in je){const qt=je[Zt];for(const Xt in qt.glyphs){const Os=qt.glyphs[+Xt];if(!Os||Os.bitmap.width===0||Os.bitmap.height===0)continue;const Ns=$e[Zt][Xt],_r=Os.metrics.localGlyph?g:1;i.fk.copy(Os.bitmap,Ot,{x:0,y:0},{x:Ns.x+_r,y:Ns.y+_r},Os.bitmap)}}this.image=Ot,this.positions=$e}}function _($t,je,$e){$t[je]?$e&&($t[je].center=$e):$t[je]={floorIds:new Set,center:$e||[0,0],floors:{}}}function w($t,je,$e,st){for(const vt of je)_($t,vt),$t[vt].floors[$e]=st,$t[vt].floorIds.add($e)}function j($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,je){return je.every($e=>$t.properties&&$t.properties[$e]!=null)}function M($t){return S($t,["type","id","name"])&&$t.properties.type==="building"}function I($t){return S($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}i.fj(y,"GlyphAtlas");class P{constructor(je){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.lut=je.lut,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.scope=je.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=je.showCollisionBoxes,this.collectResourceTiming=!!je.request&&je.request.collectResourceTiming,this.promoteId=je.promoteId,this.isSymbolTile=je.isSymbolTile,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.projection=je.projection,this.worldview=je.worldview,this.localizableLayerIds=je.localizableLayerIds,this.brightness=je.brightness,this.extraShadowCaster=!!je.extraShadowCaster,this.tessellationStep=je.tessellationStep,this.scaleFactor=je.scaleFactor,this.worldview=je.worldview,this.indoor=je.indoor}parse(je,$e,st,vt,xt,Ot){this.status="parsing",this.data=je,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(je.layers).sort()),qt=new i.fn(this.tileID,this.promoteId);qt.bucketLayerIDs=[];const Xt={},Os=new i.fo(256,256),Ns={featureIndex:qt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Os,availableImages:st,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Un=this.indoor.indoorState.activeFloorsVisible,Vn=function(Dn,ka,jo){const cl=function(ho,za){if(!ho)return i.w("No source layers defined in indoor specification"),za;if(ho.size===0)return za;const mo=ho.difference(za);for(const Ei of mo)i.w(`Missing source layer required in indoor specification: ${Ei}`);return za.intersection(za)}(ka.sourceLayers,new Set(Object.keys(Dn.layers))),ii=ka.indoorState,fl=function(ho,za,mo,Ei){const ya=new Set,po=new Set,Ac=new Set,Wc=new Map,hu={},$f=Vl=>{const hh=Wc.get(Vl)||new Set;for(const Md of ya)if((Wc.get(Md)||new Set).has(Vl)||hh.has(Md))return!0;return!1};for(const Vl of za){const hh=ho.layers[Vl];if(hh)for(let Md=0;Md=mo.maxzoom||mo.visibility==="none")continue;O(za,this.zoom,Ns.brightness,st,this.worldview);const Ei=Xt[mo.id]=mo.createBucket({index:qt.bucketLayerIDs.length,layers:za,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:cl,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:vt,worldview:this.worldview,localizable:fl});qt.bucketLayerIDs.push(za.map(po=>i.B(po.id,po.scope)));let ya=Ei.prepare?Ei.prepare():null;ya!=null?(ya=ya.then(()=>Ei.populate(ii,Ns,this.tileID.canonical,this.tileTransform)),_r.push(ya)):Ei.populate(ii,Ns,this.tileID.canonical,this.tileTransform)}}const gr=()=>{let Un,Vn,Dn,ka,jo,cl;Os.trim();const ii={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},fl=()=>{if(Un)return this.status="done",Ot(Un);if(this.extraShadowCaster)this.status="done",Ot(null,{buckets:Object.values(Xt).filter(za=>!za.isEmpty()),featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Ns.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Vn&&Dn&&ka){const za=new y(Vn),mo=new Map;for(const[po,Ac]of Dn.entries()){const{imagePosition:Wc}=i.fu(po,Ac,i.fv);mo.set(po,Wc)}const Ei={};for(const po in Xt){const Ac=Xt[po];Ac instanceof i.b4&&(O(Ac.layers,this.zoom,Ns.brightness,st,this.worldview),Ei[po]=i.fw(Ac,Vn,za.positions,Dn,mo,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,jo,this.worldview))}const ya={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(xt,Dn,jo,()=>{ya.iconsPending=!1,ho(Ei,za,ya)}),this.rasterizeIfNeeded(xt,ka,cl,()=>{ya.patternsPending=!1,ho(Ei,za,ya)})}},ho=(za,mo,Ei,ya)=>{if(Ei.iconsPending||Ei.patternsPending)return;const po=new i.fx(Dn,ka,this.lut);for(const Ac in Xt){const Wc=Xt[Ac];if(Ac in za)i.fy(Wc,za[Ac],this.showCollisionBoxes,st,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Dn,po);else if(Wc.hasPattern&&(Wc instanceof i.ba||Wc instanceof i.bb||Wc instanceof i.ea)){O(Wc.layers,this.zoom,Ns.brightness,st,this.worldview);const hu=Object.fromEntries(po.patternPositions);Wc.addFeatures(Ns,this.tileID.canonical,hu,st,this.tileTransform,this.brightness)}}this.status="done",Ot(null,{buckets:Object.values(Xt).filter(Ac=>!Ac.isEmpty()),featureIndex:qt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:mo.image,lineAtlas:Os,imageAtlas:po,brightness:Ns.brightness})};if(!this.extraShadowCaster){const za=i.fs(Ns.glyphDependencies,ya=>Object.keys(ya).map(Number));Object.keys(za).length?xt.send("getGlyphs",{uid:this.uid,stacks:za},(ya,po)=>{Un||(Un=ya,Vn=po,fl())},void 0,!1,ii):Vn={};const mo=Array.from(Ns.iconDependencies.keys()).map(ya=>i.I.parse(ya));mo.length?xt.send("getImages",{images:mo,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ya,po)=>{Un||(Un=ya,Dn=new Map,jo=this.updateImageMapAndGetImageTaskQueue(Dn,po,Ns.iconDependencies),fl())},void 0,!1,ii):(Dn=new Map,jo=new Map);const Ei=Array.from(Ns.patternDependencies.keys()).map(ya=>i.I.parse(ya));Ei.length?xt.send("getImages",{images:Ei,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ya,po)=>{Un||(Un=ya,ka=new Map,cl=this.updateImageMapAndGetImageTaskQueue(ka,po,Ns.patternDependencies),fl())},void 0,!1,ii):(ka=new Map,cl=new Map)}if(Ns.elevationFeatures&&Ns.elevationFeatures.length>0){const za=[];for(const Ei of Object.values(Xt))if(Ei instanceof i.bb){const ya=Ei.getUnevaluatedPortalGraph();ya&&za.push(ya)}const mo=i.ft.evaluate(za);for(const Ei of Object.values(Xt))if(Ei instanceof i.bb){const ya=je.layers[Zt.decode(Ei.sourceLayerIndex)];Ei.setEvaluatedPortalGraph(mo,ya,this.tileID.canonical,Ns.availableImages,Ns.brightness)}}fl()};_r.length>0?Promise.allSettled(_r).then(gr).catch(Ot):gr()}updateParameters(je){this.scaleFactor=je.scaleFactor,this.showCollisionBoxes=je.showCollisionBoxes,this.projection=je.projection,this.brightness=je.brightness,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.extraShadowCaster=je.extraShadowCaster,this.lut=je.lut,this.worldview=je.worldview,this.indoor=je.indoor}rasterizeIfNeeded(je,$e,st,vt){Array.from($e.values()).some(xt=>xt.usvg)?this.rasterize(je,$e,st,vt):vt()}updateImageMapAndGetImageTaskQueue(je,$e,st){const vt=new Map;for(const xt of $e.keys()){const Ot=st.get(xt)||[];for(const Zt of Ot){const qt=Zt.toString(),Xt=$e.get(Zt.id.toString());Xt.usvg?vt.has(qt)||(vt.set(qt,Zt),je.set(qt,Object.assign({},Xt))):je.set(qt,Xt)}}return vt}rasterize(je,$e,st,vt){this.rasterizeTask=je.send("rasterizeImages",{scope:this.scope,tasks:st},(xt,Ot)=>{if(!xt)for(const[Zt,qt]of Ot.entries()){const Xt=Object.assign($e.get(Zt),{data:qt});$e.set(Zt,Xt)}vt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function O($t,je,$e,st,vt){const xt=new i.ac(je,{brightness:$e,worldview:vt});for(const Ot of $t)Ot.recalculate(xt,st)}class q extends i.E{constructor(je,$e,st,vt,xt,Ot,Zt){super(),this.actor=je,this.layerIndex=$e,this.availableImages=st,this.availableModels=vt,this.loadVectorData=Ot||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(je.scheduler),this.isSpriteLoaded=xt,this.scheduler=je.scheduler,this.brightness=Zt}loadTile(je,$e){const st=je.uid,vt=je&&je.request,xt=vt&&vt.collectResourceTiming,Ot=this.loading[st]=new P(je);Ot.abort=this.loadVectorData(je,(Zt,qt)=>{const Xt=!this.loading[st];if(delete this.loading[st],Ot.cancelRasterize(),Xt||Zt||!qt)return Ot.status="done",Xt||(this.loaded[st]=Ot),$e(Zt);const Os=qt.rawData,Ns={},_r=i.aM(qt.responseHeaders);_r&&_r.expires&&(Ns.expires=_r.expires),_r&&_r.cacheControl&&(Ns.cacheControl=_r.cacheControl),Ot.vectorTile=qt.vectorTile||new i.fz(new i.bt(Os));const Zr=()=>{Ot.parse(Ot.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(gr,Un)=>{if(gr||!Un)return $e(gr);const Vn={};if(xt){const Dn=c(vt);Dn.length>0&&(Vn.resourceTiming=JSON.parse(JSON.stringify(Dn)))}$e(null,Object.assign({rawTileData:Os.slice(0),responseHeaders:qt.responseHeaders},Un,Ns,Vn))})};this.isSpriteLoaded?Zr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Zr,{type:"parseTile",isSymbolTile:je.isSymbolTile,zoom:je.tileZoom}):Zr()}),this.loaded=this.loaded||{},this.loaded[st]=Ot})}reloadTile(je,$e){const st=this.loaded,vt=je.uid;if(st&&st[vt]){const xt=st[vt];xt.updateParameters(je);const Ot=(Zt,qt)=>{const Xt=xt.reloadCallback;Xt&&(delete xt.reloadCallback,xt.parse(xt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),$e(Zt,qt)};xt.status==="parsing"?xt.reloadCallback=Ot:xt.status==="done"&&(xt.vectorTile?xt.parse(xt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Ot):Ot())}else $e(null,void 0)}abortTile(je,$e){const st=je.uid,vt=this.loading[st];vt&&(vt.abort&&vt.abort(),delete this.loading[st]),$e()}removeTile(je,$e){const st=this.loaded,vt=je.uid;st&&st[vt]&&delete st[vt],$e()}}class ${loadTile(je,$e){const{uid:st,encoding:vt,rawImageData:xt,padding:Ot}=je,Zt=ImageBitmap&&xt instanceof ImageBitmap?this.getImageData(xt,Ot):xt;$e(null,new i.fA(st,Zt,vt,Ot<1))}reloadTile(je,$e){$e(null,null)}abortTile(je,$e){$e()}removeTile(je,$e){$e()}getImageData(je,$e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(je.width,je.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=je.width,this.offscreenCanvas.height=je.height,this.offscreenCanvasContext.drawImage(je,0,0,je.width,je.height);const st=this.offscreenCanvasContext.getImageData(-$e,-$e,je.width+2*$e,je.height+2*$e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),st}}i.bs.setPbf(i.bt);class z{constructor(je){this._mrt=new i.bs(je.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=je.uid,this.tileID=je.tileID,this.source=je.source}parse(je,$e){const st=this._mrt;this.status="parsing",this._entireBuffer=je;try{st.parseHeader(je),this._isHeaderLoaded=!0;const vt=[];for(const xt in st.layers){const Ot=st.getLayer(xt),Zt=Ot.getDataRange(Ot.getBandList()),qt=st.createDecodingTask(Zt),Xt=je.slice(Zt.firstByte,Zt.lastByte+1),Os=i.bs.performDecoding(Xt,qt).then(Ns=>qt.complete(null,Ns)).catch(Ns=>qt.complete(Ns,null));vt.push(Os)}Promise.allSettled(vt).then(()=>$e(null,st)).catch(xt=>$e(xt))}catch(vt){$e(vt)}}}class V{constructor(je){this.actor=je,this.loading={},this.loaded={}}loadTile(je,$e){const st=je.uid,vt=je.request,xt=this.loading[st]=new z(je),{cancel:Ot}=i.bu(vt,(Zt,qt,Xt)=>{const Os=!this.loading[st];if(delete this.loading[st],Os||Zt||!qt)return xt.status="done",Os||(this.loaded[st]=xt),$e(Zt);xt.parse(qt,(Ns,_r)=>{if(Ns||!_r)return $e(Ns);$e(null,_r,Xt)}),this.loaded[st]=xt});xt.abort=Ot}reloadTile(je,$e){$e(null,void 0)}abortTile(je,$e){const st=je.uid,vt=this.loading[st];vt&&(vt.abort&&vt.abort(),delete this.loading[st]),$e()}removeTile(je,$e){const st=je.uid;this.loaded[st]&&delete this.loaded[st],$e()}decodeRasterArray(je,$e){i.bs.performDecoding(je.buffer,je.task).then(st=>$e(null,st)).catch(st=>$e(st))}}const X=i.fB.prototype.toGeoJSON;class Y{constructor(je){this._feature=je,this.extent=i.al,this.type=je.type,this.properties=je.tags,"id"in je&&!isNaN(je.id)&&(this.id=parseInt(je.id,10))}loadGeometry(){if(this._feature.type===1){const je=[];for(const $e of this._feature.geometry)je.push([new i.P($e[0],$e[1])]);return je}{const je=[];for(const $e of this._feature.geometry){const st=[];for(const vt of $e)st.push(new i.P(vt[0],vt[1]));je.push(st)}return je}}toGeoJSON(je,$e,st){return X.call(this,je,$e,st)}}class J{constructor(je,$e){this.name=je,this.extent=i.al,this.length=$e.length,this._jsonFeatures=$e}feature(je){return new Y(this._jsonFeatures[je])}}class Q{constructor(je){this.layers={},this.extent=i.al;for(const $e of Object.keys(je))this.layers[$e]=new J($e,je[$e])}}const ce=64/4096,ne=128;class re{constructor(){this.features=new Map}clear(){this.features.clear()}load(je=[],$e){for(const st of je){const vt=st.id;if(vt==null)continue;let xt=this.features.get(vt);xt&&this.updateCache(xt,$e),st.geometry?(xt=he(st),this.updateCache(xt,$e),this.features.set(vt,xt)):this.features.delete(vt),this.updateCache(xt,$e)}}updateCache(je,$e){for(const{canonical:st,uid:vt}of Object.values($e)){const{z:xt,x:Ot,y:Zt}=st;oe(je,Math.pow(2,xt),Ot,Zt)&&delete $e[vt]}}getTile(je,$e,st){const vt=Math.pow(2,je),xt=[];for(const Ot of this.features.values())oe(Ot,vt,$e,st)&&xt.push(_e(Ot,vt,$e,st));return{features:xt}}getFeatures(){return[...this.features.values()]}}function oe({minX:$t,minY:je,maxX:$e,maxY:st},vt,xt,Ot){return $t<(xt+1+ce)/vt&&je<(Ot+1+ce)/vt&&$e>(xt-ce)/vt&&st>(Ot-ce)/vt}function he($t){const{id:je,geometry:$e,properties:st}=$t;if(!$e)return;if($e.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:vt,coordinates:xt}=$e,Ot={id:je,type:1,geometry:[],tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Ot.geometry;if(vt==="Point")xe(xt,Zt,Ot);else if(vt==="MultiPoint")for(const qt of xt)xe(qt,Zt,Ot);else if(vt==="LineString")Ot.type=2,ue(xt,Zt,Ot);else if(vt==="MultiLineString")Ot.type=2,ge(xt,Zt,Ot);else if(vt==="Polygon")Ot.type=3,ge(xt,Zt,Ot,!0);else{if(vt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Ot.type=3;for(const qt of xt)ge(qt,Zt,Ot,!0)}return Ot}function xe([$t,je],$e,st){const vt=i.aF($t);let xt=i.aJ(je);xt=xt<0?0:xt>1?1:xt,$e.push(vt,xt),st.minX=Math.min(st.minX,vt),st.minY=Math.min(st.minY,xt),st.maxX=Math.max(st.maxX,vt),st.maxY=Math.max(st.maxY,xt)}function ue($t,je,$e,st=!1,vt=!1){const xt=[];for(const Ot of $t)xe(Ot,xt,$e);je.push(xt),st&&function(Ot,Zt){let qt=0;for(let Xt=0,Os=Ot.length,Ns=Os-2;Xt0===Zt)for(let Xt=0,Os=Ot.length;Xt=Ot&&Ns>=Ot||(Xt>=Ot?(Os+=Math.round(gr*((Ot-Xt)/Zr)),Xt=Ot):Ns>=Ot&&(_r=Os+Math.round(gr*((Ot-Xt)/Zr)),Ns=Ot),Os>=Ot&&_r>=Ot||(Os>=Ot?(Xt+=Math.round(Zr*((Ot-Os)/gr)),Os=Ot):_r>=Ot&&(Ns=Xt+Math.round(Zr*((Ot-Os)/gr)),_r=Ot),Zt&&Xt===Zt[Zt.length-1][0]&&Os===Zt[Zt.length-1][1]||(Zt=[[Xt,Os]],vt.push(Zt)),Zt.push([Ns,_r])))))}}function Se($t,je,$e,st,vt){const xt=($e-ce)/je,Ot=(st-ce)/je,Zt=($e+1+ce)/je,qt=(st+1+ce)/je;function Xt(_r,Zr){let gr=0;return _rZt&&(gr|=2),Zrqt&&(gr|=8),gr}let Os=[];for(let _r=1;_r<=8;_r*=2){let Zr=$t[$t.length-2],gr=$t[$t.length-1],Un=!(Xt(Zr,gr)&_r);for(let Vn=0;Vn<$t.length;Vn+=2){const Dn=$t[Vn],ka=$t[Vn+1],jo=!(Xt(Dn,ka)&_r);jo!==Un&&(8&_r?Os.push(Zr+(Dn-Zr)*(qt-gr)/(ka-gr),qt):4&_r?Os.push(Zr+(Dn-Zr)*(Ot-gr)/(ka-gr),Ot):2&_r?Os.push(Zt,gr+(ka-gr)*(Zt-Zr)/(Dn-Zr)):1&_r&&Os.push(xt,gr+(ka-gr)*(xt-Zr)/(Dn-Zr))),jo&&Os.push(Dn,ka),Zr=Dn,gr=ka,Un=jo}if(!($t=Os).length||_r===8)break;Os=[]}const Ns=[];for(let _r=0;_r>31}function qe($t,je){const{geometry:$e,type:st}=$t;let vt=0,xt=0;if(st===1){je.writeVarint(ke(1,$e.length));for(const Ot of $e){const Zt=Ot[0]-vt,qt=Ot[1]-xt;je.writeVarint(Oe(Zt)),je.writeVarint(Oe(qt)),vt+=Zt,xt+=qt}}else for(const Ot of $e){je.writeVarint(ke(1,1));const Zt=Ot.length-(st===3?1:0);for(let qt=0;qt$t},pe=Math.fround||(Ue=new Float32Array(1),$t=>(Ue[0]=+$t,Ue[0]));var Ue;const Xe=3,et=5,Ce=6;class Je{constructor(je){this.options=Object.assign(Object.create(dt),je),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(je){const{log:$e,minZoom:st,maxZoom:vt}=this.options;$e&&console.time("total time");const xt=`prepare ${je.length} points`;$e&&console.time(xt),this.points=je;const Ot=[];for(let qt=0;qt=st;qt--){const Xt=+Date.now();Zt=this.trees[qt]=this._createTree(this._cluster(Zt,qt)),$e&&console.log("z%d: %d clusters in %dms",qt,Zt.numItems,+Date.now()-Xt)}return $e&&console.timeEnd("total time"),this}getClusters(je,$e){let st=((je[0]+180)%360+360)%360-180;const vt=Math.max(-90,Math.min(90,je[1]));let xt=je[2]===180?180:((je[2]+180)%360+360)%360-180;const Ot=Math.max(-90,Math.min(90,je[3]));if(je[2]-je[0]>=360)st=-180,xt=180;else if(st>xt){const Ns=this.getClusters([st,vt,180,Ot],$e),_r=this.getClusters([-180,vt,xt,Ot],$e);return Ns.concat(_r)}const Zt=this.trees[this._limitZoom($e)],qt=Zt.range(He(st),We(Ot),He(xt),We(vt)),Xt=Zt.data,Os=[];for(const Ns of qt){const _r=this.stride*Ns;Os.push(Xt[_r+et]>1?Ge(Xt,_r,this.clusterProps):this.points[Xt[_r+Xe]])}return Os}getChildren(je){const $e=this._getOriginId(je),st=this._getOriginZoom(je),vt="No cluster with the specified id.",xt=this.trees[st];if(!xt)throw new Error(vt);const Ot=xt.data;if($e*this.stride>=Ot.length)throw new Error(vt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,st-1)),qt=xt.within(Ot[$e*this.stride],Ot[$e*this.stride+1],Zt),Xt=[];for(const Os of qt){const Ns=Os*this.stride;Ot[Ns+4]===je&&Xt.push(Ot[Ns+et]>1?Ge(Ot,Ns,this.clusterProps):this.points[Ot[Ns+Xe]])}if(Xt.length===0)throw new Error(vt);return Xt}getLeaves(je,$e,st){const vt=[];return this._appendLeaves(vt,je,$e=$e||10,st=st||0,0),vt}getTile(je,$e,st){const vt=this.trees[this._limitZoom(je)],xt=Math.pow(2,je),{extent:Ot,radius:Zt}=this.options,qt=Zt/Ot,Xt=(st-qt)/xt,Os=(st+1+qt)/xt,Ns={features:[]};return this._addTileFeatures(vt.range(($e-qt)/xt,Xt,($e+1+qt)/xt,Os),vt.data,$e,st,xt,Ns),$e===0&&this._addTileFeatures(vt.range(1-qt/xt,Xt,1,Os),vt.data,xt,st,xt,Ns),$e===xt-1&&this._addTileFeatures(vt.range(0,Xt,qt/xt,Os),vt.data,-1,st,xt,Ns),Ns.features.length?Ns:null}getClusterExpansionZoom(je){let $e=this._getOriginZoom(je)-1;for(;$e<=this.options.maxZoom;){const st=this.getChildren(je);if($e++,st.length!==1)break;je=st[0].properties.cluster_id}return $e}_appendLeaves(je,$e,st,vt,xt){const Ot=this.getChildren($e);for(const Zt of Ot){const qt=Zt.properties;if(qt&&qt.cluster?xt+qt.point_count<=vt?xt+=qt.point_count:xt=this._appendLeaves(je,qt.cluster_id,st,vt,xt):xt1;let Os,Ns,_r;if(Xt)Os=lt($e,qt,this.clusterProps),Ns=$e[qt],_r=$e[qt+1];else{const Un=this.points[$e[qt+Xe]];Os=Un.properties;const[Vn,Dn]=Un.geometry.coordinates;Ns=He(Vn),_r=We(Dn)}const Zr={type:1,geometry:[[Math.round(this.options.extent*(Ns*xt-st)),Math.round(this.options.extent*(_r*xt-vt))]],tags:Os};let gr;gr=Xt||this.options.generateId?$e[qt+Xe]:this.points[$e[qt+Xe]].id,gr!==void 0&&(Zr.id=gr),Ot.features.push(Zr)}}_limitZoom(je){return Math.max(this.options.minZoom,Math.min(Math.floor(+je),this.options.maxZoom+1))}_cluster(je,$e){const{radius:st,extent:vt,reduce:xt,minPoints:Ot}=this.options,Zt=st/(vt*Math.pow(2,$e)),qt=je.data,Xt=[],Os=this.stride;for(let Ns=0;Ns$e&&(Vn+=qt[ka+et])}if(Vn>Un&&Vn>=Ot){let Dn,ka=_r*Un,jo=Zr*Un,cl=-1;const ii=(Ns/Os<<5)+($e+1)+this.points.length;for(const fl of gr){const ho=fl*Os;if(qt[ho+2]<=$e)continue;qt[ho+2]=$e;const za=qt[ho+et];ka+=qt[ho]*za,jo+=qt[ho+1]*za,qt[ho+4]=ii,xt&&(Dn||(Dn=this._map(qt,Ns,!0),cl=this.clusterProps.length,this.clusterProps.push(Dn)),xt(Dn,this._map(qt,ho)))}qt[Ns+4]=ii,Xt.push(ka/Vn,jo/Vn,1/0,ii,-1,Vn),xt&&Xt.push(cl)}else{for(let Dn=0;Dn1)for(const Dn of gr){const ka=Dn*Os;if(!(qt[ka+2]<=$e)){qt[ka+2]=$e;for(let jo=0;jo>5}_getOriginZoom(je){return(je-this.points.length)%32}_map(je,$e,st){if(je[$e+et]>1){const Ot=this.clusterProps[je[$e+Ce]];return st?Object.assign({},Ot):Ot}const vt=this.points[je[$e+Xe]].properties,xt=this.options.map(vt);return st&&xt===vt?Object.assign({},xt):xt}}function Ge($t,je,$e){return{type:"Feature",id:$t[je+Xe],properties:lt($t,je,$e),geometry:{type:"Point",coordinates:[(st=$t[je],360*(st-.5)),tt($t[je+1])]}};var st}function lt($t,je,$e){const st=$t[je+et],vt=st>=1e4?`${Math.round(st/1e3)}k`:st>=1e3?Math.round(st/100)/10+"k":st,xt=$t[je+Ce],Ot=xt===-1?{}:Object.assign({},$e[xt]);return Object.assign(Ot,{cluster:!0,cluster_id:$t[je+Xe],point_count:st,point_count_abbreviated:vt})}function He($t){return $t/360+.5}function We($t){const je=Math.sin($t*Math.PI/180),$e=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return $e<0?0:$e>1?1:$e}function tt($t){const je=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(je))/Math.PI-90}function Ke($t,je,$e,st){let vt=st;const xt=je+($e-je>>1);let Ot,Zt=$e-je;const qt=$t[je],Xt=$t[je+1],Os=$t[$e],Ns=$t[$e+1];for(let _r=je+3;_r<$e;_r+=3){const Zr=rt($t[_r],$t[_r+1],qt,Xt,Os,Ns);if(Zr>vt)Ot=_r,vt=Zr;else if(Zr===vt){const gr=Math.abs(_r-xt);grst&&(Ot-je>3&&Ke($t,je,Ot,st),$t[Ot+2]=vt,$e-Ot>3&&Ke($t,Ot,$e,st))}function rt($t,je,$e,st,vt,xt){let Ot=vt-$e,Zt=xt-st;if(Ot!==0||Zt!==0){const qt=(($t-$e)*Ot+(je-st)*Zt)/(Ot*Ot+Zt*Zt);qt>1?($e=vt,st=xt):qt>0&&($e+=Ot*qt,st+=Zt*qt)}return Ot=$t-$e,Zt=je-st,Ot*Ot+Zt*Zt}function it($t,je,$e,st){const vt={id:$t??null,type:je,geometry:$e,tags:st,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(je==="Point"||je==="MultiPoint"||je==="LineString")It(vt,$e);else if(je==="Polygon")It(vt,$e[0]);else if(je==="MultiLineString")for(const xt of $e)It(vt,xt);else if(je==="MultiPolygon")for(const xt of $e)It(vt,xt[0]);return vt}function It($t,je){for(let $e=0;$e0&&(Ot+=st?(vt*Os-Xt*xt)/2:Math.sqrt(Math.pow(Xt-vt,2)+Math.pow(Os-xt,2))),vt=Xt,xt=Os}const Zt=je.length-3;je[2]=1,Ke(je,0,Zt,$e),je[Zt+2]=1,je.size=Math.abs(Ot),je.start=0,je.end=je.size}function Ts($t,je,$e,st){for(let vt=0;vt<$t.length;vt++){const xt=[];Es($t[vt],xt,$e,st),je.push(xt)}}function cr($t){return $t/360+.5}function zr($t){const je=Math.sin($t*Math.PI/180),$e=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return $e<0?0:$e>1?1:$e}function Ft($t,je,$e,st,vt,xt,Ot,Zt){if(st/=je,xt>=($e/=je)&&Ot=st)return null;const qt=[];for(const Xt of $t){const Os=Xt.geometry;let Ns=Xt.type;const _r=vt===0?Xt.minX:Xt.minY,Zr=vt===0?Xt.maxX:Xt.maxY;if(_r>=$e&&Zr=st)continue;let gr=[];if(Ns==="Point"||Ns==="MultiPoint")Ps(Os,gr,$e,st,vt);else if(Ns==="LineString")yr(Os,gr,$e,st,vt,!1,Zt.lineMetrics);else if(Ns==="MultiLineString")Ar(Os,gr,$e,st,vt,!1);else if(Ns==="Polygon")Ar(Os,gr,$e,st,vt,!0);else if(Ns==="MultiPolygon")for(const Un of Os){const Vn=[];Ar(Un,Vn,$e,st,vt,!0),Vn.length&&gr.push(Vn)}if(gr.length){if(Zt.lineMetrics&&Ns==="LineString"){for(const Un of gr)qt.push(it(Xt.id,Ns,Un,Xt.tags));continue}Ns!=="LineString"&&Ns!=="MultiLineString"||(gr.length===1?(Ns="LineString",gr=gr[0]):Ns="MultiLineString"),Ns!=="Point"&&Ns!=="MultiPoint"||(Ns=gr.length===3?"Point":"MultiPoint"),qt.push(it(Xt.id,Ns,gr,Xt.tags))}}return qt.length?qt:null}function Ps($t,je,$e,st,vt){for(let xt=0;xt<$t.length;xt+=3){const Ot=$t[xt+vt];Ot>=$e&&Ot<=st&&tn(je,$t[xt],$t[xt+1],$t[xt+2])}}function yr($t,je,$e,st,vt,xt,Ot){let Zt=Is($t);const qt=vt===0?na:Ln;let Xt,Os,Ns=$t.start;for(let Vn=0;Vn<$t.length-3;Vn+=3){const Dn=$t[Vn],ka=$t[Vn+1],jo=$t[Vn+2],cl=$t[Vn+3],ii=$t[Vn+4],fl=vt===0?Dn:ka,ho=vt===0?cl:ii;let za=!1;Ot&&(Xt=Math.sqrt(Math.pow(Dn-cl,2)+Math.pow(ka-ii,2))),fl<$e?ho>$e&&(Os=qt(Zt,Dn,ka,cl,ii,$e),Ot&&(Zt.start=Ns+Xt*Os)):fl>st?ho=$e&&(Os=qt(Zt,Dn,ka,cl,ii,$e),za=!0),ho>st&&fl<=st&&(Os=qt(Zt,Dn,ka,cl,ii,st),za=!0),!xt&&za&&(Ot&&(Zt.end=Ns+Xt*Os),je.push(Zt),Zt=Is($t)),Ot&&(Ns+=Xt)}let _r=$t.length-3;const Zr=$t[_r],gr=$t[_r+1],Un=vt===0?Zr:gr;Un>=$e&&Un<=st&&tn(Zt,Zr,gr,$t[_r+2]),_r=Zt.length-3,xt&&_r>=3&&(Zt[_r]!==Zt[0]||Zt[_r+1]!==Zt[1])&&tn(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&je.push(Zt)}function Is($t){const je=[];return je.size=$t.size,je.start=$t.start,je.end=$t.end,je}function Ar($t,je,$e,st,vt,xt){for(const Ot of $t)yr(Ot,je,$e,st,vt,xt,!1)}function tn($t,je,$e,st){$t.push(je,$e,st)}function na($t,je,$e,st,vt,xt){const Ot=(xt-je)/(st-je);return tn($t,xt,$e+(vt-$e)*Ot,1),Ot}function Ln($t,je,$e,st,vt,xt){const Ot=(xt-$e)/(vt-$e);return tn($t,je+(st-je)*Ot,xt,1),Ot}function tr($t,je){const $e=[];for(let st=0;st<$t.length;st++){const vt=$t[st],xt=vt.type;let Ot;if(xt==="Point"||xt==="MultiPoint"||xt==="LineString")Ot=dr(vt.geometry,je);else if(xt==="MultiLineString"||xt==="Polygon"){Ot=[];for(const Zt of vt.geometry)Ot.push(dr(Zt,je))}else if(xt==="MultiPolygon"){Ot=[];for(const Zt of vt.geometry){const qt=[];for(const Xt of Zt)qt.push(dr(Xt,je));Ot.push(qt)}}$e.push(it(vt.id,xt,Ot,vt.tags))}return $e}function dr($t,je){const $e=[];$e.size=$t.size,$t.start!==void 0&&($e.start=$t.start,$e.end=$t.end);for(let st=0;st<$t.length;st+=3)$e.push($t[st]+je,$t[st+1],$t[st+2]);return $e}function Sr($t,je){if($t.transformed)return $t;const $e=1<<$t.z,st=$t.x,vt=$t.y;for(const xt of $t.features){const Ot=xt.geometry,Zt=xt.type;if(xt.geometry=[],Zt===1)for(let qt=0;qt0&&je.size<(vt?Ot:st))return void($e.numPoints+=je.length/3);const Zt=[];for(let qt=0;qtOt)&&($e.numSimplified++,Zt.push(je[qt],je[qt+1])),$e.numPoints++;vt&&function(qt,Xt){let Os=0;for(let Ns=0,_r=qt.length,Zr=_r-2;Ns<_r;Zr=Ns,Ns+=2)Os+=(qt[Ns]-qt[Zr])*(qt[Ns+1]+qt[Zr+1]);if(Os>0===Xt)for(let Ns=0,_r=qt.length;Ns<_r/2;Ns+=2){const Zr=qt[Ns],gr=qt[Ns+1];qt[Ns]=qt[_r-2-Ns],qt[Ns+1]=qt[_r-1-Ns],qt[_r-2-Ns]=Zr,qt[_r-1-Ns]=gr}}(Zt,xt),$t.push(Zt)}const Wt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Hr{constructor(je,$e){const st=($e=this.options=function(xt,Ot){for(const Zt in Ot)xt[Zt]=Ot[Zt];return xt}(Object.create(Wt),$e)).debug;if(st&&console.time("preprocess data"),$e.maxZoom<0||$e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if($e.promoteId&&$e.generateId)throw new Error("promoteId and generateId cannot be used together.");let vt=function(xt,Ot){const Zt=[];if(xt.type==="FeatureCollection")for(let qt=0;qt1&&console.time("creation"),Zr=this.tiles[_r]=Yr(je,$e,st,vt,Xt),this.tileCoords.push({z:$e,x:st,y:vt}),Os)){Os>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",$e,st,vt,Zr.numFeatures,Zr.numPoints,Zr.numSimplified),console.timeEnd("creation"));const za=`z${$e}`;this.stats[za]=(this.stats[za]||0)+1,this.total++}if(Zr.source=je,xt==null){if($e===Xt.indexMaxZoom||Zr.numPoints<=Xt.indexMaxPoints)continue}else{if($e===Xt.maxZoom||$e===xt)continue;if(xt!=null){const za=xt-$e;if(st!==Ot>>za||vt!==Zt>>za)continue}}if(Zr.source=null,je.length===0)continue;Os>1&&console.time("clipping");const gr=.5*Xt.buffer/Xt.extent,Un=.5-gr,Vn=.5+gr,Dn=1+gr;let ka=null,jo=null,cl=null,ii=null,fl=Ft(je,Ns,st-gr,st+Vn,0,Zr.minX,Zr.maxX,Xt),ho=Ft(je,Ns,st+Un,st+Dn,0,Zr.minX,Zr.maxX,Xt);je=null,fl&&(ka=Ft(fl,Ns,vt-gr,vt+Vn,1,Zr.minY,Zr.maxY,Xt),jo=Ft(fl,Ns,vt+Un,vt+Dn,1,Zr.minY,Zr.maxY,Xt),fl=null),ho&&(cl=Ft(ho,Ns,vt-gr,vt+Vn,1,Zr.minY,Zr.maxY,Xt),ii=Ft(ho,Ns,vt+Un,vt+Dn,1,Zr.minY,Zr.maxY,Xt),ho=null),Os>1&&console.timeEnd("clipping"),qt.push(ka||[],$e+1,2*st,2*vt),qt.push(jo||[],$e+1,2*st,2*vt+1),qt.push(cl||[],$e+1,2*st+1,2*vt),qt.push(ii||[],$e+1,2*st+1,2*vt+1)}}getTile(je,$e,st){je=+je,$e=+$e,st=+st;const vt=this.options,{extent:xt,debug:Ot}=vt;if(je<0||je>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",je,$e,st);let Xt,Os=je,Ns=$e,_r=st;for(;!Xt&&Os>0;)Os--,Ns>>=1,_r>>=1,Xt=this.tiles[Mr(Os,Ns,_r)];return Xt&&Xt.source?(Ot>1&&(console.log("found parent tile z%d-%d-%d",Os,Ns,_r),console.time("drilling down")),this.splitTile(Xt.source,Os,Ns,_r,je,$e,st),Ot>1&&console.timeEnd("drilling down"),this.tiles[qt]?Sr(this.tiles[qt],xt):null):null}}function Mr($t,je,$e){return 32*((1<<$t)*$e+je)+$t}function xr($t,je){const $e=$t.tileID.canonical;if(!this._geoJSONIndex)return void je(null,null);const st=this._geoJSONIndex.getTile($e.z,$e.x,$e.y);if(!st)return void je(null,null);const vt=Xt=>Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",xt=st.features.filter(Xt=>vt(Xt));let Ot={_geojsonTileLayer:st.features};xt.length>0&&(Ot={_geojsonTileLayer:st.features.filter(Xt=>!vt(Xt)),hd_road_elevation:xt});const Zt=new Q(Ot),qt=function(Xt){const Os=new i.bt;for(const Ns of Object.keys(Xt))Os.writeMessage(3,Ee,{name:Ns,features:Xt[Ns]});return Os.finish()}(Ot).buffer;je(null,{vectorTile:Zt,rawData:qt})}class Wn extends q{constructor(je,$e,st,vt,xt,Ot,Zt){super(je,$e,st,vt,xt,xr,Zt),Ot&&(this.loadGeoJSON=Ot),this._dynamicIndex=new re}loadData(je,$e){const st=je&&je.request,vt=st&&st.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(je,(xt,Ot)=>{if(xt||!Ot)return $e(xt);if(typeof Ot!="object")return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));{try{if(je.filter){const qt=i.U(je.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(qt.result==="error")throw new Error(qt.value.map(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));Ot.features=Ot.features.filter(Xt=>qt.value.evaluate({zoom:0},Xt))}je.dynamic?(Ot.type==="Feature"&&(Ot={type:"FeatureCollection",features:[Ot]}),je.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Ot.features,this.loaded),je.cluster&&(Ot.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=je.cluster?new Je(function({superclusterOptions:qt,clusterProperties:Xt}){if(!Xt||!qt)return qt;const Os={},Ns={},_r={accumulated:null,zoom:0},Zr={properties:null},gr=Object.keys(Xt);for(const Un of gr){const[Vn,Dn]=Xt[Un],ka=i.U(Dn),jo=i.U(typeof Vn=="string"?[Vn,["accumulated"],["get",Un]]:Vn);Os[Un]=ka.value,Ns[Un]=jo.value}return qt.map=Un=>{Zr.properties=Un;const Vn={};for(const Dn of gr)Vn[Dn]=Os[Dn].evaluate(_r,Zr);return Vn},qt.reduce=(Un,Vn)=>{Zr.properties=Vn;for(const Dn of gr)_r.accumulated=Un[Dn],Un[Dn]=Ns[Dn].evaluate(_r,Zr)},qt}(je)).load(Ot.features):je.dynamic?this._dynamicIndex:function(qt,Xt){return new Hr(qt,Xt)}(Ot,je.geojsonVtOptions)}catch(qt){return $e(qt)}const Zt={};if(vt){const qt=c(st);qt&&(Zt.resourceTiming={},Zt.resourceTiming[je.source]=JSON.parse(JSON.stringify(qt)))}$e(null,Zt)}})}reloadTile(je,$e){const st=this.loaded;return st&&st[je.uid]?je.partial?$e(null,void 0):super.reloadTile(je,$e):this.loadTile(je,$e)}loadGeoJSON(je,$e){if(je.request)i.m(je.request,$e);else{if(typeof je.data!="string")return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return $e(null,JSON.parse(je.data))}catch{return $e(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(je,$e){try{$e(null,this._geoJSONIndex.getClusterExpansionZoom(je.clusterId))}catch(st){$e(st)}}getClusterChildren(je,$e){try{$e(null,this._geoJSONIndex.getChildren(je.clusterId))}catch(st){$e(st)}}getClusterLeaves(je,$e){try{$e(null,this._geoJSONIndex.getLeaves(je.clusterId,je.limit,je.offset))}catch(st){$e(st)}}}class ai{constructor(je,$e,st){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=je.projection,this.brightness=$e,this.worldview=st}parse(je,$e,st,vt){this.status="parsing";const xt=new i.aQ(st.tileID.overscaledZ,st.tileID.wrap,st.tileID.canonical.z,st.tileID.canonical.x,st.tileID.canonical.y),Ot=[],Zt=$e.familiesBySource[st.source],qt=new i.fn(xt,st.promoteId);qt.bucketLayerIDs=[],qt.is3DTile=!0,i.fC(je).then(Xt=>{if(!Xt)return vt(new Error("Could not parse tile"));const Os=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,Ns=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),_r=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Zr in Zt)for(const gr of Zt[Zr]){const Un=gr[0];qt.bucketLayerIDs.push(gr.map(ka=>i.B(ka.id,ka.scope))),Un.recalculate(_r,[]);const Vn=i.fD(Xt,1/i.d7(st.tileID.canonical)),Dn=new i.fE(gr,Vn,xt,Os,Ns,this.brightness,qt,this.worldview);Os||(Dn.needsUpload=!0),Ot.push(Dn),Dn.evaluate(Un)}this.status="done",vt(null,{buckets:Ot,featureIndex:qt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>vt(new Error(Xt.message)))}}class Aa{constructor(je,$e,st,vt,xt,Ot,Zt,qt){this.actor=je,this.layerIndex=$e,this.availableImages=st,this.availableModels=vt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=qt}loadTile(je,$e){const st=je.uid,vt=this.loading[st]=new ai(je,this.brightness,this.worldview);i.bu(je.request,(xt,Ot)=>{const Zt=!this.loading[st];return delete this.loading[st],Zt||xt?(vt.status="done",Zt||(this.loaded[st]=vt),$e(xt)):Ot&&Ot.byteLength!==0?void vt.parse(Ot,this.layerIndex,je,(qt,Xt)=>{vt.status="done",this.loaded=this.loaded||{},this.loaded[st]=vt,qt||!Xt?$e(qt):$e(null,Xt)}):(vt.status="done",this.loaded[st]=vt,$e())})}reloadTile(je,$e){const st=this.loaded,vt=je.uid;if(st&&st[vt]){const xt=st[vt];xt.projection=je.projection,xt.brightness=je.brightness;const Ot=(Zt,qt)=>{xt.reloadCallback&&(delete xt.reloadCallback,this.loadTile(je,$e)),$e(Zt,qt)};xt.status==="parsing"?xt.reloadCallback=Ot:xt.status==="done"&&this.loadTile(je,$e)}}abortTile(je,$e){const st=je.uid;this.loading[st]&&delete this.loading[st],$e()}removeTile(je,$e){const st=this.loaded,vt=je.uid;st&&st[vt]&&delete st[vt],$e()}}class no{constructor(je){this.self=je,this.actor=new i.fG(je,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:Wn,"raster-dem":$,"raster-array":V,"batched-model":Aa},this.workerSources={},this.self.registerWorkerSource=($e,st)=>{if(this.workerSourceTypes[$e])throw new Error(`Worker source with name "${$e}" already registered.`);this.workerSourceTypes[$e]=st},this.self.registerRTLTextPlugin=$e=>{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=$e.applyArabicShaping,i.fH.processBidirectionalText=$e.processBidirectionalText,i.fH.processStyledBidirectionalText=$e.processStyledBidirectionalText;for(const st of this.rtlPluginParsingListeners)st(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(je,$e,st){delete this.layerIndexes[je],delete this.availableImages[je],delete this.availableModels[je],delete this.workerSources[je],st()}checkIfReady(je,$e,st){st()}setReferrer(je,$e){this.referrer=$e}spriteLoaded(je,$e){this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={});const{scope:st,isLoaded:vt}=$e;if(this.isSpriteLoaded[je][st]=vt,this.workerSources[je]&&this.workerSources[je][st])for(const xt in this.workerSources[je][st]){const Ot=this.workerSources[je][st][xt];for(const Zt in Ot){const qt=Ot[Zt];qt instanceof q&&(qt.isSpriteLoaded=vt,qt.fire(new i.z("isSpriteLoaded")))}}}setImages(je,$e,st){this.availableImages[je]||(this.availableImages[je]={});const{scope:vt,images:xt}=$e;if(this.availableImages[je][vt]=xt,this.workerSources[je]&&this.workerSources[je][vt]){for(const Ot in this.workerSources[je][vt]){const Zt=this.workerSources[je][vt][Ot];for(const qt in Zt)Zt[qt].availableImages=xt}st()}else st()}setModels(je,{scope:$e,models:st},vt){if(this.availableModels[je]||(this.availableModels[je]={}),this.availableModels[je][$e]=st,this.workerSources[je]&&this.workerSources[je][$e]){for(const xt in this.workerSources[je][$e]){const Ot=this.workerSources[je][$e][xt];for(const Zt in Ot)Ot[Zt].availableModels=st}vt()}else vt()}setProjection(je,$e){this.projections[je]=i.cm($e)}setBrightness(je,$e,st){this.brightness=$e,st()}setWorldview(je,$e,st){this.worldview=$e,st()}setLayers(je,$e,st){this.getLayerIndex(je,$e.scope).replace($e.layers,$e.options),st()}updateLayers(je,$e,st){this.getLayerIndex(je,$e.scope).update($e.layers,$e.removedIds,$e.options),st()}loadTile(je,$e,st){$e.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,$e.type,$e.source,$e.scope).loadTile($e,st)}decodeRasterArray(je,$e,st){this.getWorkerSource(je,$e.type,$e.source,$e.scope).decodeRasterArray($e,st)}reloadTile(je,$e,st){$e.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,$e.type,$e.source,$e.scope).reloadTile($e,st)}abortTile(je,$e,st){this.getWorkerSource(je,$e.type,$e.source,$e.scope).abortTile($e,st)}removeTile(je,$e,st){this.getWorkerSource(je,$e.type,$e.source,$e.scope).removeTile($e,st)}removeSource(je,$e,st){if(!(this.workerSources[je]&&this.workerSources[je][$e.scope]&&this.workerSources[je][$e.scope][$e.type]&&this.workerSources[je][$e.scope][$e.type][$e.source]))return;const vt=this.workerSources[je][$e.scope][$e.type][$e.source];delete this.workerSources[je][$e.scope][$e.type][$e.source],vt.removeSource!==void 0?vt.removeSource($e,st):st()}loadWorkerSource(je,$e,st){try{this.self.importScripts($e.url),st()}catch(vt){st(vt)}}syncRTLPluginState(je,$e,st){if(i.fH.isParsed())st(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(st);else try{i.fH.setState($e);const vt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||vt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(vt),i.fH.isParsed()?st(null,!0):this.rtlPluginParsingListeners.push(st))}catch(vt){st(vt)}}setDracoUrl(je,$e){this.dracoUrl=$e}getAvailableImages(je,$e){this.availableImages[je]||(this.availableImages[je]={});let st=this.availableImages[je][$e];return st||(st=[]),st}getAvailableModels(je,$e){this.availableModels[je]||(this.availableModels[je]={});let st=this.availableModels[je][$e];return st||(st={}),st}getLayerIndex(je,$e){this.layerIndexes[je]||(this.layerIndexes[je]={});let st=this.layerIndexes[je][$e];return st||(st=this.layerIndexes[je][$e]=new f,st.scope=$e),st}getWorkerSource(je,$e,st,vt){const xt=this.workerSources;return xt[je]||(xt[je]={}),xt[je][vt]||(xt[je][vt]={}),xt[je][vt][$e]||(xt[je][vt][$e]={}),this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={}),xt[je][vt][$e][st]||(xt[je][vt][$e][st]=new this.workerSourceTypes[$e]({send:(Ot,Zt,qt,Xt,Os,Ns)=>this.actor.send(Ot,Zt,qt,je,Os,Ns),scheduler:this.actor.scheduler},this.getLayerIndex(je,vt),this.getAvailableImages(je,vt),this.getAvailableModels(je,vt),this.isSpriteLoaded[je][vt],void 0,this.brightness,this.worldview)),xt[je][vt][$e][st]}rasterizeImagesWorker(je,$e,st){const vt=new Map;for(const[xt,{image:Ot,imageVariant:Zt}]of $e.tasks.entries()){const qt=this.imageRasterizer.rasterize(Zt,Ot,$e.scope,je);vt.set(xt,qt)}st(void 0,vt)}removeRasterizedImages(je,$e,st){this.imageRasterizer.removeImagesFromCacheByIds($e.imageIds,$e.scope,je),st()}enforceCacheSizeLimit(je,$e){i.fJ($e)}getWorkerPerformanceMetrics(je,$e,st){st(void 0,void 0)}}return i.fF(self)&&(self.worker=new no(self)),no}),o(["./shared"],function(i){var c="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},m={mark(T){performance.mark(T)},measure(T,h,v){performance.measure(T,h,v)}};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,y={},_=function(){if(g)return y;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,B,W=new Blob([""],{type:"text/javascript"}),ee=URL.createObjectURL(W);try{B=new Worker(ee),F=!0}catch{F=!1}return B&&B.terminate(),URL.revokeObjectURL(ee),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var B=F.getContext("2d");if(!B)return!1;var W=B.getImageData(0,0,1,1);return W&&W.width===F.width}()?(v[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(v[D]=function(F){var B,W=function(ee){var ae=document.createElement("canvas"),le=Object.create(T.webGLContextAttributes);return le.failIfMajorPerformanceCaveat=ee,ae.getContext("webgl2",le)}(F);if(!W)return!1;try{B=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!B||W.isContextLost())&&(W.shaderSource(B,"void main() {}"),W.compileShader(B),W.getShaderParameter(B,W.COMPILE_STATUS)===!0)}(D)),v[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}g=1,y.supported=T,y.notSupportedReason=h;var v={};return T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},y}();function w(T,h,v){const A=document.createElement(T);return h!=null&&(A.className=h),v&&v.appendChild(A),A}function j(T,h,v){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 v&&v.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 I(){N&&S&&(M=N[S],N[S]="none")}function P(){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 $(T,h){const v=T.getBoundingClientRect();return X(T,v,h)}function z(T,h){const v=T.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,v){return this._transformRequestFn&&this._transformRequestFn(h,v)||{url:h}}normalizeStyleURL(h,v){if(!i.h(h))return h;const A=ne(h);return A.params.push(`sdk=js-${c}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeGlyphsURL(h,v){if(!i.h(h))return h;const A=ne(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeModelURL(h,v){if(!i.h(h))return h;const A=ne(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeSourceURL(h,v,A,D){if(!i.h(h))return h;const F=ne(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||v)}normalizeIconsetURL(h,v){const A=ne(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||v)):re(A)}normalizeSpriteURL(h,v,A,D){const F=ne(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${v}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${v}${A}`,re(F))}normalizeTileURL(h,v,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=ne(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${v||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(B){for(const W of B){const ee=W.match(/^access_token=(.*)$/);if(ee)return ee[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,v){const A=ne(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 v&&(F=F.filter(B=>!B.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,v){const A=!!v&&i.h(v),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,v){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ne(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 re(h);if(v=v||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!v)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(v[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=${v||""}`),re(h)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ne(T){const h=T.match(ce);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 re(T){const h=T.params.length?`?${T.params.join("&")}`:"";return`${T.protocol}://${T.authority}${T.path}${h}`}const oe="mapbox.eventData";function he(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 xe{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const v=he(i.e.ACCESS_TOKEN);let A="";return A=v&&v.u?i.f(v.u):i.e.ACCESS_TOKEN||"",h?`${oe}.${h}:${A}`:`${oe}:${A}`}fetchEventData(){const h=i.s("localStorage"),v=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(v);F&&(this.eventData=JSON.parse(F));const B=localStorage.getItem(A);B&&(this.anonId=B);const W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const ee=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(v,JSON.stringify(this.eventData)),B&&localStorage.setItem(D,B.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,v,A,D){if(!i.e.EVENTS_URL)return;const F=ne(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const B={event:this.type,created:new Date(h).toISOString()},W=v?Object.assign(B,v):B,ee={url:re(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(ee,ae=>{this.pendingRequest=null,A(ae),this.saveEventData(),this.processRequests(D)})}queueRequest(h,v){this.queue.push(h),this.processRequests(v)}}class ue extends xe{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 v=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:v},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:v,payload:A}=this.queue.shift();this.postEvent(v,A,()=>{},h)}}const ge=new class extends xe{constructor(T){super("appUserTurnstile"),this._customAccessToken=T}postTurnstileEvent(T,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(T)&&T.some(v=>i.h(v)||i.j(v))&&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=he(i.e.ACCESS_TOKEN),v=h?h.u:i.e.ACCESS_TOKEN;let A=v!==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),B=new Date(D),W=(D-this.eventData.lastSuccess)/864e5;A=A||W>=1||W<-1||F.getDate()!==B.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Y,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=v)},T):this.processRequests()}},_e=ge.postTurnstileEvent.bind(ge),Be=new class extends xe{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(T,h,v,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(v||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:v}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(v,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Y,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T))}remove(){this.errorCb=null}},Se=Be.postMapLoadEvent.bind(Be),Ee=new class extends xe{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:v,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!T&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(v),B={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(B.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:B},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:v}=this.queue.shift();this.postEvent(h,v,()=>{},T)}},Ae=Ee.postStyleLoadEvent.bind(Ee),Me=new ue({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),ke=Me.postMetricsEvent.bind(Me),Oe=new ue({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),qe=Oe.postMetricsEvent.bind(Oe),ve=new class extends xe{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:v}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),B=performance.getEntriesByType("mark"),W=function(Ne){const Re={};if(Ne){for(const Ie in Ne)if(Ie!=="other")for(const Ze of Ne[Ie]){const Ve=`${Ie}ResolveRangeMin`,at=`${Ie}ResolveRangeMax`,ht=`${Ie}RequestCount`,ot=`${Ie}RequestCachedCount`;Re[Ve]=Math.min(Re[Ve]||1/0,Ze.startTime),Re[at]=Math.max(Re[at]||-1/0,Ze.responseEnd);const At=Nt=>{Re[Nt]===void 0&&(Re[Nt]=0),++Re[Nt]};Ze.transferSize!==void 0&&Ze.transferSize===0&&At(ot),At(ht)}}return Re}(function(Ne,Re){const Ie={};if(Ne)for(const Ze of Ne){const Ve=Re(Ze);Ie[Ve]===void 0&&(Ie[Ve]=[]),Ie[Ve].push(Ze)}return Ie}(F,f)),ee=window.devicePixelRatio,ae=navigator.connection||navigator.mozConnection||navigator.webkitConnection,le=ae?ae.effectiveType:void 0,we={counters:[],metadata:[],attributes:[]},be=(Ne,Re,Ie)=>{Ie!=null&&Ne.push({name:Re,value:Ie.toString()})};for(const Ne in W)be(we.counters,Ne,W[Ne]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(be(we.counters,"interactionRangeMin",D.interactionRange[0]),be(we.counters,"interactionRangeMax",D.interactionRange[1])),B)for(const Ne of Object.values(u)){const Re=B.find(Ie=>Ie.name===Ne);Re&&be(we.counters,Ne,Re.startTime)}return be(we.counters,"visibilityHidden",D.visibilityHidden),be(we.attributes,"style",function(Ne){if(Ne)for(const Re of Ne){const Ie=Re.name.split("?")[0];if(i.i(Ie)){const Ze=Ie.split("/").slice(-2);if(Ze.length===2)return`mapbox://styles/${Ze[0]}/${Ze[1]}`}}}(F)),be(we.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),be(we.attributes,"fogEnabled",D.fogEnabled?"true":"false"),be(we.attributes,"projection",D.projection),be(we.attributes,"zoom",D.zoom),be(we.metadata,"devicePixelRatio",ee),be(we.metadata,"connectionEffectiveType",le),be(we.metadata,"navigatorUserAgent",navigator.userAgent),be(we.metadata,"screenWidth",window.screen.width),be(we.metadata,"screenHeight",window.screen.height),be(we.metadata,"windowWidth",window.innerWidth),be(we.metadata,"windowHeight",window.innerHeight),be(we.metadata,"mapWidth",D.width/ee),be(we.metadata,"mapHeight",D.height/ee),be(we.metadata,"webglRenderer",D.renderer),be(we.metadata,"webglVendor",D.vendor),be(we.metadata,"sdkVersion",c),be(we.metadata,"sdkIdentifier","mapbox-gl-js"),we}(v);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},T)}},dt=ve.postPerformanceEvent.bind(ve),pe=new class extends xe{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(T,h,v,A){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=ne(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:re(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,B=>{this.pendingRequest=null,v(B),this.saveEventData(),this.processRequests(A)})}getSessionAPI(T,h,v,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(v||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:v}=this.queue.shift();h&&this.success[h]||this.getSession(v,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T)}remove(){this.errorCb=null}},Ue=pe.getSessionAPI.bind(pe),Xe=new Set;function et(T,h){h?Xe.add(T):Xe.delete(T)}class Ce{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,v){this._updatedSourceCaches[h]=v,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const v=h.scope;this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._updatedLayers[v].add(h.id),this.setDirty()}removeLayer(h){const v=h.scope;this._removedLayers[v]=this._removedLayers[v]||{},this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._removedLayers[v][h.id]=h,this._updatedLayers[v].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 v in this._updatedLayers)h[v]=h[v]||{},h[v].updatedIds=Array.from(this._updatedLayers[v].values());for(const v in this._removedLayers)h[v]=h[v]||{},h[v].removedIds=Object.keys(this._removedLayers[v]);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,v){this._updatedImages[v]=this._updatedImages[v]||new Set,this._updatedImages[v].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 Je(T){const{userImage:h}=T;return!!(h&&h.render&&h.render())&&(T.data.replace(new Uint8Array(h.data.buffer)),!0)}class Ge 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 v=this.atlasTexture.get(h);v&&(v.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,v){this.imageProviders.has(v)||this.imageProviders.set(v,new Map),this.imageProviders.get(v).set(h.id,h)}removeImageProvider(h,v){this.imageProviders.has(v)&&this.imageProviders.get(v).delete(h)}getPendingImageProviders(){const h=[];for(const v of this.imageProviders.values())for(const A of v.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,v){if(this.loaded.get(v)!==h&&(this.loaded.set(v,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,v,D);this.requestors=[]}}hasImage(h,v){return!!this.getImage(h,v)}getImage(h,v){return this.images.get(v).get(h.toString())}addImage(h,v,A){this._validate(h,A)&&this.images.get(v).set(h.toString(),A)}_validate(h,v){let A=!0;return this._validateStretch(v.stretchX,v.data&&v.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(v.stretchY,v.data&&v.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(v.content,v)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,v){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(v))}getImages(h,v,A){const D=[],F=[],B=this.imageProviders.get(v);for(const le of h){if(!le.iconsetId){D.push(le);continue}const we=B.get(le.iconsetId);we&&(this.getImage(le,v)?F.push(le):we.addPendingRequest(le))}if(D.length===0)return void this._notify(F,v,A);let W=!0;const ee=!!this.loaded.get(v),ae=this.images.get(v);if(!ee)for(const le of D)ae.has(le.toString())||(W=!1);ee||W?this._notify(D,v,A):this.requestors.push({ids:D,scope:v,callback:A})}rasterizeImages(h,v){const A=new Map,{tasks:D,scope:F}=h;for(const[B,W]of D.entries()){const ee=this.getImage(W.id,F);ee&&A.set(B,{image:ee,imageVariant:W})}this._rasterizeImages(F,A,v)}_rasterizeImages(h,v,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:v,scope:h},A);else{const D=new Map;for(const[F,{image:B,imageVariant:W}]of v.entries())D.set(F,this.imageRasterizer.rasterize(W,B,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,v,A){const D=this.images.get(v),F=new Map;for(const B of h){if(!D.get(B.toString())){if(B.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:B.name}))}const W=D.get(B.toString());if(!W){i.w(`Image "${B.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 ee={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(ee,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),F.set(i.I.toString(B),ee)}A(null,F)}getPixelSize(h){const{width:v,height:A}=this.atlasImage.get(h);return{width:v,height:A}}getPattern(h,v,A){const D=h.toString(),F=this.patterns.get(v),B=F.get(D),W=this.getImage(h,v);if(!W)return null;if(B){if(B.position.version===W.version)return B.position;B.position.version=W.version}else{if(W.usvg&&!W.data){const ee=this.getPatternInFlightId(D,v);if(this.patternsInFlight.has(ee))return null;this.patternsInFlight.add(ee);const ae=new i.A(h).scaleSelf(i.o.devicePixelRatio),le=new Map([[ae.toString(),{image:W,imageVariant:ae}]]);return this._rasterizeImages(v,le,(we,be)=>this.storePatternImage(ae,v,W,A,be)),null}this.storePattern(h,v,W)}return this._updatePatternAtlas(v,A),F.get(D).position}getPatternInFlightId(h,v){return i.B(h,v)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,v,A,D,F){const B=h.toString(),W=F?F.get(B):void 0;W&&(A.data=W,this.storePattern(h.id,v,A),this._updatePatternAtlas(v,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),v)))}storePattern(h,v,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(v).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,v){const A=h.gl;let D=this.atlasTexture.get(v);D?this.dirty&&(D.update(this.atlasImage.get(v)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(v),A.RGBA8),this.atlasTexture.set(v,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,v){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ae})=>ae),{w:F,h:B}=i.G(D),W=this.atlasImage.get(h);W.resize({width:F||1,height:B||1});const ee=this.images.get(h);for(const[ae,{bin:le,position:we}]of A.entries()){let be=we.padding;const Ne=le.x+be,Re=le.y+be,Ie=ee.get(ae).data,Ze=Ie.width,Ve=Ie.height;be=be>1?be-1:be,i.q.copy(Ie,W,{x:0,y:0},{x:Ne,y:Re},{width:Ze,height:Ve},v),i.q.copy(Ie,W,{x:0,y:Ve-be},{x:Ne,y:Re-be},{width:Ze,height:be},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ne,y:Re+Ve},{width:Ze,height:be},v),i.q.copy(Ie,W,{x:Ze-be,y:0},{x:Ne-be,y:Re},{width:be,height:Ve},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ne+Ze,y:Re},{width:be,height:Ve},v),i.q.copy(Ie,W,{x:Ze-be,y:Ve-be},{x:Ne-be,y:Re-be},{width:be,height:be},v),i.q.copy(Ie,W,{x:0,y:Ve-be},{x:Ne+Ze,y:Re-be},{width:be,height:be},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ne+Ze,y:Re+Ve},{width:be,height:be},v),i.q.copy(Ie,W,{x:Ze-be,y:0},{x:Ne-be,y:Re+Ve},{width:be,height:be},v)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,v){const A=this.images.get(v);for(const D of h){if(this.callbackDispatchedThisFrame.get(v).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(v).add(D.toString());const F=A.get(D.toString());Je(F)&&this.updateImage(D,v,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function lt(T){const h=T.value,v=T.valueSpec,A=T.style,D=T.styleSpec,F=T.key,B=T.arrayElementValidator||tr;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(v.length&&h.length!==v.length)return[new i.V(F,h,`array length ${v.length} expected, length ${h.length} found`)];if(v["min-length"]&&h.lengthD)return[new i.V(h,v,`${v} is greater than the maximum value ${D}`)]}return[]}function We(T){const h=T.key,v=T.value;if(!i.H(v))return[new i.V(h,v,`object expected, ${i.K(v)} found`)];const A=T.valueSpec,D=i.J(v.type);let F,B,W,ee={};const ae=D!=="categorical"&&v.property===void 0,le=!ae,we=function(Ie){const Ze=Ie.stops;return Array.isArray(Ze)&&Array.isArray(Ze[0])&&i.H(Ze[0][0])}(v),be=dr({key:T.key,value:T.value,valueSpec:T.styleSpec.function,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{stops:function(Ie){if(D==="identity")return[new i.V(Ie.key,Ie.value,'identity function may not have a "stops" property')];let Ze=[];const Ve=Ie.value;return Ze=Ze.concat(lt({key:Ie.key,value:Ve,valueSpec:Ie.valueSpec,style:Ie.style,styleSpec:Ie.styleSpec,arrayElementValidator:Ne})),Array.isArray(Ve)&&Ve.length===0&&Ze.push(new i.V(Ie.key,Ve,"array must have at least one stop")),Ze},default:function(Ie){return tr({key:Ie.key,value:Ie.value,valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec})}}});return D==="identity"&&ae&&be.push(new i.V(T.key,T.value,'missing required property "property"')),D==="identity"||v.stops||be.push(new i.V(T.key,T.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&be.push(new i.V(T.key,T.value,"exponential functions not supported")),T.styleSpec.$version>=8&&(le&&!i.N(A)?be.push(new i.V(T.key,T.value,"property functions not supported")):ae&&!i.O(A)&&be.push(new i.V(T.key,T.value,"zoom functions not supported"))),D!=="categorical"&&!we||v.property!==void 0||be.push(new i.V(T.key,T.value,'"property" property is required')),be;function Ne(Ie){let Ze=[];const Ve=Ie.value,at=Ie.key;if(!Array.isArray(Ve))return[new i.V(at,Ve,`array expected, ${i.K(Ve)} found`)];if(Ve.length!==2)return[new i.V(at,Ve,`array length 2 expected, length ${Ve.length} found`)];if(we){if(!i.H(Ve[0]))return[new i.V(at,Ve,`object expected, ${i.K(Ve[0])} found`)];const ht=Ve[0];if(ht.zoom===void 0)return[new i.V(at,Ve,"object stop key must have zoom")];if(ht.value===void 0)return[new i.V(at,Ve,"object stop key must have value")];const ot=i.J(ht.zoom);if(typeof ot!="number")return[new i.V(at,ht.zoom,"stop zoom values must be numbers")];if(W&&W>ot)return[new i.V(at,ht.zoom,"stop zoom values must appear in ascending order")];ot!==W&&(W=ot,B=void 0,ee={}),Ze=Ze.concat(dr({key:`${at}[0]`,value:Ve[0],valueSpec:{zoom:{}},style:Ie.style,styleSpec:Ie.styleSpec,objectElementValidators:{zoom:He,value:Re}}))}else Ze=Ze.concat(Re({key:`${at}[0]`,value:Ve[0],style:Ie.style,styleSpec:Ie.styleSpec},Ve));return i.Q(i.S(Ve[1]))?Ze.concat([new i.V(`${at}[1]`,Ve[1],"expressions are not allowed in function stops.")]):Ze.concat(tr({key:`${at}[1]`,value:Ve[1],valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec}))}function Re(Ie,Ze){const Ve=i.K(Ie.value),at=i.J(Ie.value),ht=Ie.value!==null?Ie.value:Ze;if(F){if(Ve!==F)return[new i.V(Ie.key,ht,`${Ve} stop domain type must match previous stop domain type ${F}`)]}else F=Ve;if(Ve!=="number"&&Ve!=="string"&&Ve!=="boolean"&&typeof at!="number"&&typeof at!="string"&&typeof at!="boolean")return[new i.V(Ie.key,ht,"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(Ie.key,ht,ot)]}return D!=="categorical"||Ve!=="number"||typeof at=="number"&&isFinite(at)&&Math.floor(at)===at?D!=="categorical"&&Ve==="number"&&typeof at=="number"&&typeof B=="number"&&B!==void 0&&atnew i.V(`${T.key}${A.key}`,T.value,A.message));const v=h.value.expression||h.value._styleExpression.expression;if(T.expressionContext==="property"&&T.propertyKey==="text-font"&&!v.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(v))return[new i.V(T.key,T.value,'"feature-state" data expressions are not supported with layout properties.')];if(T.expressionContext==="filter")return Ke(v,T);if(T.expressionContext==="appearance")return rt(v,T);if(T.expressionContext&&T.expressionContext.indexOf("cluster")===0){if(!i.X(v,["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(v))return[new i.V(T.key,T.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ke(T,h){const v=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)v.delete(D);if(v.size===0)return[];const A=[];return T instanceof i._&&v.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(...Ke(D,h))}),A)}function rt(T,h){const v=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)v.add(D);if(v.size===0)return[];const A=[];return T instanceof i._&&!v.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] is not an allowed parameter`)]:(T.eachChild(D=>{A.push(...rt(D,h))}),A)}function it(T){const h=T.key,v=T.value,A=T.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(v))===-1&&D.push(new i.V(h,v,`expected one of [${A.values.join(", ")}], ${JSON.stringify(v)} found`)):Object.keys(A.values).indexOf(i.J(v))===-1&&D.push(new i.V(h,v,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(v)} found`)),D}function It(T){return i.a2(i.S(T.value))?tt(Object.assign({},T,{expressionContext:"filter",valueSpec:T.styleSpec[`filter_${T.layerType||"fill"}`]})):Vt(T)}function Vt(T){const h=T.value,v=T.key;if(!Array.isArray(h))return[new i.V(v,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(v,h,"filter array must have at least 1 element")];const A=T.styleSpec;let D=it({key:`${v}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${v}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let B=2;B":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(v,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(v,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(v,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 B=1;B{ae in v&&h.push(new i.V(A,v[ae],`"${ae}" is prohibited for ref layers`))}),D.layers.forEach(ae=>{i.J(ae.id)===W&&(ee=ae)}),ee?ee.ref?h.push(new i.V(A,v.ref,"ref cannot reference another ref layer")):B=i.J(ee.type):typeof W=="string"&&h.push(new i.V(A,v.ref,`ref layer "${W}" not found`))}else if(B!=="background"&&B!=="sky"&&B!=="slot")if(v.source)if(i.a0(v.source)){const ee=D.sources&&D.sources[v.source],ae=ee&&i.J(ee.type);ee?ae==="vector"&&B==="raster"?h.push(new i.V(A,v.source,`layer "${v.id}" requires a raster source`)):ae==="raster"&&B!=="raster"?h.push(new i.V(A,v.source,`layer "${v.id}" requires a vector source`)):ae!=="vector"||v["source-layer"]?ae==="raster-dem"&&B!=="hillshade"?h.push(new i.V(A,v.source,"raster-dem source can only be used with layer type 'hillshade'.")):ae!=="raster-array"||["raster","raster-particle"].includes(B)?B==="line"&&v.paint&&(v.paint["line-gradient"]||v.paint["line-trim-offset"])&&ae==="geojson"&&!ee.lineMetrics?h.push(new i.V(A,v,`layer "${v.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):B==="raster-particle"&&ae!=="raster-array"&&h.push(new i.V(A,v.source,`layer "${v.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,v.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,v,`layer "${v.id}" must specify a "source-layer"`)):h.push(new i.V(A,v.source,`source "${v.source}" not found`))}else h.push(new i.V(`${A}.source`,v.source,'"source" must be a string'));else h.push(new i.V(A,v,'missing required property "source"'));return h=h.concat(dr({key:A,value:v,valueSpec:F.layer,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{"*":()=>[],type:()=>tr({key:`${A}.type`,value:v.type,valueSpec:F.layer.type,style:T.style,styleSpec:T.styleSpec,object:v,objectKey:"type"}),filter:ee=>It(Object.assign({layerType:B},ee)),layout:ee=>dr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ae=>Ts(Object.assign({layerType:B},ae))}}),paint:ee=>dr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ae=>Es(Object.assign({layerType:B,layer:v},ae))}}),appearances(ee){const ae=lt({key:ee.key,value:ee.value,valueSpec:ee.valueSpec,style:ee.style,styleSpec:ee.styleSpec,arrayElementValidator:be=>function(Ne){const{key:Re,layer:Ie,layerType:Ze}=Ne,Ve=i.J(Ne.value),at=i.J(Ve.name),ht=i.J(Ve.condition),ot=dr({key:Re,value:Ve,valueSpec:Ne.styleSpec.appearance,style:Ne.style,styleSpec:Ne.styleSpec,objectElementValidators:{condition:At=>function(Nt){const Ct=[];return Ct.push(...tt({key:Nt.key,value:Nt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),Ct}(Object.assign({layer:Ie,layerType:Ze},At)),properties:At=>function(Nt){const Ct=[],{styleSpec:wt,layer:gt,layerType:Dt}=Nt,Ht=wt[`paint_${Dt}`],Ut=wt[`layout_${Dt}`],es=Nt.object[Nt.objectKey];for(const ts in es){const _s=ts in Ht?"paint":ts in Ut?"layout":void 0;if(!_s){Ct.push(new i.V(Nt.key,ts,`unknown property "${ts}" for layer type "${Dt}"`));continue}const Ks=Object.assign({},Nt,{key:`${Nt.key}.${ts}`,object:es,objectKey:ts,layer:gt,layerType:Dt,value:es[ts],valueSpec:_s==="paint"?Ht[ts]:Ut[ts]});Ct.push(...hs(Ks,_s))}return Ct}(Object.assign({layer:Ie,layerType:Ze},At))}});return at!=="hidden"&&ht===void 0&&ot.push(new i.V(Ne.key,"name",'Appearance with name different than "hidden" must have a condition')),ot}(Object.assign({layerType:B,layer:v},be))}),le=Array.isArray(ee.value)?ee.value:[],we=new Set;return le.forEach((be,Ne)=>{const Re=i.J(be.name);if(Re)if(we.has(Re)){const Ie=i.J(v.id);ae.push(new i.V(ee.key,Re,`Duplicated appearance name "${Re}" for layer "${Ie}"`))}else we.add(Re)}),ae}}})),h}function zr({key:T,value:h}){return i.a0(h)?[]:[new i.V(T,h,`string expected, ${i.K(h)} found`)]}const Ft={promoteId:function T({key:h,value:v}){if(i.a0(v))return zr({key:h,value:v});if(Array.isArray(v)){const D=[],F=i.S(v),B=i.U(F);return B.result==="error"&&B.value.forEach(W=>{D.push(new i.V(`${h}${W.key}`,null,`${W.message}`))}),i.X(B.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(v))return[new i.V(h,v,`string, expression or object expected, "${i.K(v)}" found`)];const A=[];for(const D in v)A.push(...T({key:`${h}.${D}`,value:v[D]}));return A}};function Ps(T){const h=T.value,v=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(v,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(v,h,'"type" is required')];const F=i.J(h.type);let B=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||B.push(new i.a3(v,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return B=B.concat(dr({key:v,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:T.style,styleSpec:A,objectElementValidators:Ft})),B;case"geojson":if(B=dr({key:v,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:Ft}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${v}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const W in h.clusterProperties){const ee=h.clusterProperties[W];if(!Array.isArray(ee))return[new i.V(`${v}.clusterProperties.${W}`,ee,"array expected")];const[ae,le]=ee,we=typeof ae=="string"?[ae,["accumulated"],["get",W]]:ae;B.push(...tt({key:`${v}.${W}.map`,value:le,expressionContext:"cluster-map"})),B.push(...tt({key:`${v}.${W}.reduce`,value:we,expressionContext:"cluster-reduce"}))}}return B;case"video":return dr({key:v,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return dr({key:v,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(v,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return it({key:`${v}.type`,value:h.type,valueSpec:{values:yr(A)}})}}function yr(T){return T.source.reduce((h,v)=>{const A=T[v];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function Is(T){const h=T.value,v=T.styleSpec,A=v.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 B in h){const W=B.match(/^(.*)-transition$/),ee=B.match(/^(.*)-use-theme$/);F=F.concat(ee&&A[ee[1]]?tr({key:B,value:h[B],valueSpec:{type:"string"},style:D,styleSpec:v}):W&&A[W[1]]&&A[W[1]].transition?tr({key:B,value:h[B],valueSpec:v.transition,style:D,styleSpec:v}):A[B]?tr({key:B,value:h[B],valueSpec:A[B],style:D,styleSpec:v}):[new i.V(B,h[B],`unknown property "${B}"`)])}return F}function Ar(T){const h=T.value;if(!h)return[];const v=T.key;if(!i.H(h))return[new i.V(v,h,`object expected, ${i.K(h)} found`)];let A=[];const D=T.styleSpec,F=D["light-3d"],B=T.style,W=T.style.lights;for(const le of["type","id"])if(!(le in h))return A=A.concat([new i.V(v,h,`missing property "${le}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${v}.type`,h.type,"string expected")]),A;if(W)for(let le=0;le[],array:lt,boolean:function(T){const h=T.value,v=T.key;return i.$(h)?[]:[new i.V(v,h,`boolean expected, ${i.K(h)} found`)]},number:He,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:It,function:We,layer:cr,object:dr,source:Ps,model:i.a7,light:Is,"light-3d":Ar,terrain:tn,fog:na,string:zr,formatted:function(T){return zr(T).length===0?[]:tt(T)},resolvedImage:function(T){return zr(T).length===0?[]:tt(T)},projection:function(T){const h=T.value,v=T.styleSpec,A=v.projection,D=T.style;if(i.H(h)){let F=[];for(const B in h)F=F.concat(tr({key:B,value:h[B],valueSpec:A[B],style:D,styleSpec:v}));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:v,styleSpec:A}=T;if(!i.H(v))return[new i.V(h,v,"import must be an object")];const{data:D,...F}=v;Object.defineProperty(F,"__line__",{value:v.__line__,enumerable:!1});let B=dr(Object.assign({},T,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&B.push(new i.V(`${T.key}.id`,F,"import id can't be an empty string")),D&&(B=B.concat(dn(D,A,{key:`${T.key}.data`}))),B},iconset:function(T){const h=T.value,v=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(v,h,"object expected")];if(!h.type)return[new i.V(v,h,'"type" is required')];const F=i.J(h.type);let B=[];if(B=B.concat(dr({key:v,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(W,ee){return!(W!=="source"||!ee.source)}(F,h)){const W=D.sources&&D.sources[h.source],ee=W&&i.J(W.type);W?ee!=="raster-array"&&B.push(new i.V(v,h.source,`iconset cannot be used with a source of type ${String(ee)}, it only be used with a "raster-array" source type`)):B.push(new i.V(v,h.source,`source "${h.source}" not found`))}return B}};function tr(T,h=!1){const v=T.value,A=T.valueSpec,D=T.styleSpec;if(A.expression){if(i.a4(i.J(v)))return We(T);if(i.Q(i.S(v)))return tt(T)}if(A.type&&Ln[A.type]){const F=Ln[A.type](T);return h===!0&&F.length>0&&Array.isArray(T.value)?tt(T):F}return dr(Object.assign({},T,{valueSpec:A.type?D[A.type]:A}))}function dr(T){const h=T.key,v=T.value,A=T.valueSpec||{},D=T.objectElementValidators||{},F=T.style,B=T.styleSpec;if(!i.H(v))return[new i.V(h,v,`object expected, ${i.K(v)} found`)];let W=[];for(const ee in v){const ae=ee.split(".")[0];let le;D[ae]?le=D[ae]:A[ae]?le=tr:D["*"]?le=D["*"]:A["*"]&&(le=tr),le?W=W.concat(le({key:(h&&`${h}.`)+ee,value:v[ee],valueSpec:A[ae]||A["*"],style:F,styleSpec:B,object:v,objectKey:ee},v)):W.push(new i.a3(h,v[ee],`unknown property "${ee}"`))}for(const ee in A){if(D[ee])continue;const ae=A[ee];ae.required&&ae.default===void 0&&v[ee]===void 0&&W.push(new i.V(h,v,`missing required property "${ee}"`))}return W}function Sr({key:T,value:h}){const v=zr({key:T,value:h});if(v.length)return v;const A=h;return A.indexOf("{fontstack}")===-1&&v.push(new i.V(T,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&v.push(new i.V(T,h,'"glyphs" url must include a "{range}" token')),v}function dn(T,h=i.a6,v={}){return dr({key:v.key||"",value:T,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:T,objectElementValidators:{glyphs:Sr}})}function Yr(T,h=i.a6){return $e(dn(T,h))}const ui=T=>$e(Ps(T)),ns=T=>$e(Is(T)),Wt=T=>$e(Ar(T)),Hr=T=>$e(tn(T)),Mr=T=>$e(na(T)),xr=T=>$e(function(h){const v=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(v===void 0)return[];if(!i.H(v))return[new i.V("snow",v,`object expected, ${i.K(v)} found`)];let B=[];for(const W in v){const ee=W.match(/^(.*)-transition$/);B=B.concat(ee&&F[ee[1]]&&F[ee[1]].transition?tr({key:W,value:v[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?tr({key:W,value:v[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,v[W],`unknown property "${W}"`)])}return B}(T)),Wn=T=>$e(function(h){const v=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(v===void 0)return[];if(!i.H(v))return[new i.V("rain",v,`object expected, ${i.K(v)} found`)];let B=[];for(const W in v){const ee=W.match(/^(.*)-transition$/);B=B.concat(ee&&F[ee[1]]&&F[ee[1]].transition?tr({key:W,value:v[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?tr({key:W,value:v[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,v[W],`unknown property "${W}"`)])}return B}(T)),ai=T=>$e(cr(T)),Aa=T=>$e(It(T)),no=T=>$e(Es(T)),$t=T=>$e(Ts(T)),je=T=>$e(i.a7(T));function $e(T){return T.slice().sort((h,v)=>h.line&&v.line?h.line-v.line:0)}function st(T,h){let v=!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))),v=!0);return v}const vt=i.a6.light;let xt;class Ot extends i.E{constructor(h,v="flat"){super(),this._transitionable=new i.a8(xt||(xt=new i.a9({anchor:new i.aa(vt.anchor),position:new i.ab(vt.position),color:new i.aa(vt.color),intensity:new i.aa(vt.intensity)}))),this.setLight(h,v),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,v,A={}){this._validate(ns,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=v)}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,v,A){return(!A||A.validate!==!1)&&st(this,h.call(Yr,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let qt=class extends i.E{constructor(T,h,v,A,D){super(),this.scope=v,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),v,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 v=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(v=F,A=-1):A=F;return D<.01&&v>0&&A>v?[v,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,Os=65,Ns=.05;function _r(T,h,v,A){const D=i.ah(Xt,Os,v),[F,B]=Zr(T,A);let W=1-Math.min(1,Math.exp((h-F)/(B-F)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*D*T.alpha}function Zr(T,h){const v=.5/Math.tan(.5*h);return[T.range[0]+v,T.range[1]+v]}function gr(T,h,v,A,D){const F=i.af([],[h,v,A],D.mercatorFogMatrix);return _r(T,i.ag(F),D.pitch,D._fov)}function Un(T,h,v,A,D,F,B){const W=[[v,A,0],[D,A,0],[D,F,0],[v,F,0]];let ee=Number.MAX_VALUE,ae=-Number.MAX_VALUE;for(const le of W){const we=i.af([],le,h),be=i.ag(we);ee=Math.min(ee,be),ae=Math.max(ae,be)}return[_r(T,ee,B.pitch,B._fov),_r(T,ae,B.pitch,B._fov)]}const Vn=i.a6.fog;class Dn extends i.E{constructor(h,v,A,D){super();const F=new i.a9({range:new i.aa(Vn.range),color:new i.aa(Vn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Vn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Vn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Vn["horizon-blend"]),"star-intensity":new i.aa(Vn["star-intensity"]),"vertical-range":new i.aa(Vn["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=v,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,v=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:v?[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,v,A={}){if(this._validate(Mr,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(Vn))D[F]===void 0&&(D[F]=Vn[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,v)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const v=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Xt,Os,h))*v.a}getOpacityAtLatLng(h,v){return this._transform.projection.supportsFog?function(A,D,F){const B=i.ae.fromLngLat(D),W=F.elevation?F.elevation.getAtPointOrZero(B):0;return gr(A,B.x,B.y,W,F)}(this.state,h,v):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const v=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Un(this.state,v,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,v,A,D,F){return this._transform.projection.supportsFog?Un(this.state,h,v,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Zr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const v=[4,5,6,7];for(const A of v){const D=h.points[A];let F;if(D[2]>=0)F=D;else{const B=h.points[A-4];F=i.am(B,D,B[2]/(B[2]-D[2]))}if(gr(this.state,F[0],F[1],0,this._transform)>=Ns)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,v,A){return(!A||A.validate!==!1)&&st(this,h.call(Yr,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ka,jo,cl,ii,fl=class extends i.E{constructor(T,h,v,A){super();const D=ka||(ka=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,v,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=v}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),v=this.properties.get("direction"),A=i.an(v[0]),D=-Math.max(i.an(v[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],B=this.properties.get("vignette"),W=this.properties.get("vignette-color");return W.a=B,{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,v={}){if(this._validate(xr,T,v))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,v){return(!v||v.validate!==!1)&&st(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},ho=class extends i.E{constructor(T,h,v,A){super();const D=jo||(jo=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,v,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=v}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),v=this.properties.get("direction"),A=i.an(v[0]),D=-Math.max(i.an(v[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],B=this.properties.get("vignette-color");return B.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:B}}get(){return this._transitionable.serialize()}set(T,h,v={}){if(this._validate(Wn,T,v))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,v){return(!v||v.validate!==!1)&&st(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class za extends i.E{constructor(h,v,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(v),this._transitionable=new i.a8(v,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,v){this._options=h,this._transitionable.setTransitionOrValue(h.properties,v)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class mo{constructor(h,v,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=v,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,v){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=v.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),B=i.P.convert(h[1]),W=F.add(B)._div(2);A=[F,B],D=i.aq(F,B).every(ee=>v.isPointAboveHorizon(ee))&&v.isPointAboveHorizon(W)}return new mo(A,D,v)}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 v=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(v,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>v.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=v.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const v=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(v,A,h),F=this.cameraPoint.clone();switch(3*((F.y>v.y)+(F.y>A.y))+((F.x>v.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,v,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/v._pixelsPerMercatorPixel+1,B=A?this._bufferedCameraMercator(F,v):this._bufferedScreenMercator(F,v);let W=h.tileID.wrap+(B.unwrapped?D:0);const ee=B.polygon.map(Ze=>i.as(h.tileTransform,Ze,W));if(!i.at(ee,0,0,i.al,i.al))return;W=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ae=this.screenGeometryMercator.polygon.map(Ze=>i.au(h.tileTransform,Ze,W)),le=ae.map(Ze=>new i.P(Ze[0],Ze[1])),we=v.getFreeCameraOptions().position||new i.ae(0,0,0),be=i.au(h.tileTransform,we,W),Ne=ae.map(Ze=>{const Ve=i.av(Ze,Ze,be);return i.aw(Ve,Ve),new i.ax(be,Ve)}),Re=i.ay(h,1,v.zoom)*v._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:le,tilespaceRays:Ne,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(Ie=i.az(ee),Ie.min.x=i.aA(Ie.min.x,0,i.al),Ie.min.y=i.aA(Ie.min.y,0,i.al),Ie.max.x=i.aA(Ie.max.x,0,i.al),Ie.max.y=i.aA(Ie.max.y,0,i.al),Ie),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Re};var Ie}_bufferedScreenMercator(h,v){const A=po(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),v):{polygon:this.bufferedScreenGeometry(h).map(F=>v.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,v){const A=po(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),v):{polygon:this.bufferedCameraGeometry(h).map(F=>v.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,v){const A=function(F,B){const W=i.aB([],B.pixelMatrix,B.globeMatrix),ee=[0,-i.aD,0,1],ae=[0,i.aD,0,1],le=[0,0,0,1];i.aC(ee,ee,W),i.aC(ae,ae,W),i.aC(le,le,W);const we=new i.P(ee[0]/ee[3],ee[1]/ee[3]),be=new i.P(ae[0]/ae[3],ae[1]/ae[3]),Ne=i.aE(F,we)&&ee[3]1?Ei(F.slice(0,Ze),B):[],ht=Zenew i.P(ya(Ct.x),Ct.y)),ht=ht.map(Ct=>new i.P(ya(Ct.x),Ct.y));const ot=[...at];ot.length===0&&ot.push(ht[ht.length-1]);const At=i.ak(ot[ot.length-1].y,(ht.length===0?at[0]:ht[0]).y,Ve);let Nt;return Nt=Ne?[new i.P(0,At),new i.P(0,0),new i.P(1,0),new i.P(1,At)]:[new i.P(1,At),new i.P(1,1),new i.P(0,1),new i.P(0,At)],ot.push(...Nt),ht.length===0?ot.push(at[0]):ot.push(...ht),{polygon:ot.map(Ct=>new i.ae(Ct.x,Ct.y)),unwrapped:!1}}(h,v);if(A)return A;const D=function(F,B){let W=!1,ee=-1/0,ae=0;for(let we=0;weee&&(ee=F[we].x,ae=we);for(let we=0;we.5&&(Ne.x{we.x-=1}),{polygon:F,unwrapped:W}}(Ei(h,v).map(F=>new i.P(ya(F.x),F.y)),v);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Ei(T,h){return i.aG(T,v=>{const A=h.pointCoordinate3D(v);v.x=A.x,v.y=A.y},1/256)}function ya(T){return T<0?1+T%1:T%1}function po(T){return 100*T|0}function Ac(T,h,v,A,D){const F=function(W,ee){if(W)return D(W);if(ee){if(T.url&&ee.tiles&&T.tiles&&delete T.tiles,ee.variants){if(!Array.isArray(ee.variants))return D(new Error("variants must be an array"));for(const le of ee.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"){ee=Object.assign(ee,le);break}}}const ae=i.aH(Object.assign({},ee,T),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ae.tiles=h.canonicalizeTileset(ae,T.url),D(null,ae)}},B=function(W,ee,ae){if(!W)return null;if(!ee&&!ae)return W;ae=ae||W.worldview_default;const le=Object.values(W.language||{});if(le.length===0)return null;const we=Object.values(W.worldview||{});if(we.length===0)return null;const be=le.every(Re=>Re===ee),Ne=we.every(Re=>Re===ae);return be&&Ne?W:ee in(W.language_options||{})||ae in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W:null}(T.data,v,A);return B?i.o.frame(()=>F(null,B)):T.url?i.m(h.transformRequest(h.normalizeSourceURL(T.url,null,v,A),i.R.Source),F):i.o.frame(()=>{const{data:W,...ee}=T;F(null,ee)})}function Wc(T,h){const v=Math.pow(2,h.z),A=Math.floor(i.aF(T.getWest())*v),D=Math.floor(i.aJ(T.getNorth())*v),F=Math.ceil(i.aF(T.getEast())*v),B=Math.ceil(i.aJ(T.getSouth())*v);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)v&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${v}`),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 B of F.vector_layers)this.vectorLayerIds.push(B.id),F.worldview&&F.worldview[B.source]&&this.localizableLayerIds.add(B.id)}this.tileBounds=hu.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,v){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),B=this.map.style?this.map.style.getLut(this.scope):null,W=B?{image:B.image.clone()}:null,ee={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)&&(ee.localizableLayerIds=this.localizableLayerIds),ee.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=v:h.request=h.actor.send("reloadTile",ee,ae.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",ee,ae.bind(this),void 0,!0);else{const le=i.aL.call({deduped:this._deduped},ee,(we,be)=>{if(we||!be)ae.call(this,we);else{const Ne=i.aM(be.responseHeaders);ee.data={rawData:be.rawData.slice(0),expires:Ne.expires,cacheControl:Ne.cacheControl},h.actor&&h.actor.send("loadTile",ee,ae.bind(this),void 0,!0)}},!0);h.request={cancel:le}}function ae(le,we){return delete h.request,h.aborted?v(null):le&&le instanceof i.aN&&le.status!==404?v(le):(we&&we.resourceTiming&&(h.resourceTiming=we.resourceTiming),this.map._refreshExpiredTiles&&we&&h.setExpiryData(we),h.loadVectorData(we,this.map.painter),i.aO(this.dispatcher),v(null,we),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,v){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Vl extends i.E{constructor(h,v,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"},v),Object.assign(this,i.aH(v,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const v=this.map.getWorldview();this._tileJSONRequest=Ac(this._options,this.map._requestManager,null,v,(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=hu.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,v){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,B,W)=>{if(delete h.request,h.aborted)return h.state="unloaded",v(null);if(F)return h.state="errored",v(F);if(!B)return v(null);const ee=i.aM(W);this.map._refreshExpiredTiles&&h.setExpiryData(ee),h.setTexture(B,this.map.painter),h.state="loaded",i.aO(this.dispatcher),v(null)})}abortTile(h,v){h.request&&(h.request.cancel(),delete h.request),v&&v()}unloadTile(h,v){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(),v&&v()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function hh([T,h],v,A,{scaled:D=!0}={}){const{tileSize:F,buffer:B}=A,{x:W,y:ee,z:ae}=v;if(!isFinite(W)||!isFinite(ee)||!isFinite(ae))throw new Error("Invalid MRT header");const le=2**ae,we=le*i.aF(T),be=le*i.aJ(h);return function([Ne,Re],Ie,{scaled:Ze=!0}={}){if(!Ie)throw new Error("bandView is undefined");const{data:Ve,tileSize:at,buffer:ht,offset:ot,scale:At,dimension:Nt}=Ie;if(Ne<-ht||Ne>at+ht||Re<-ht||Re>at+ht)throw new Error(`Point (${Ne}, ${Re}) out of bounds for tileSize=${at}, buffer=${ht}`);const Ct=(Re+ht)*(at+2*ht)+(Ne+ht);if(new Uint32Array(Ve.buffer)[Ct]===4294967295)return null;let wt=[];wt=Ze?[]:new Ie.data.constructor(Nt);for(let gt=0;gt{if(delete h.request,h.aborted)return h.state="unloaded",v(null);if(W)return W.name==="AbortError"?void 0:(h.state="errored",v(W));if(this.map._refreshExpiredTiles&&ee){const le=i.aM(ae);h.setExpiryData(le)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!ee)return v(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=ee}v(null)};h.request=this.partial?h.fetchHeader(void 0,B.bind(this)):h.actor.send("loadTile",F,B.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,v){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,v,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(v,A,D,(F,B)=>{if(F)return h.state="errored",this.fire(new i.y(F)),void this.triggerRepaint(h);B&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(A,B,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const v=this.rasterLayers.find(({id:F})=>F===h),A=v&&v.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,v,A){if(!h)return;const D=v.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;v instanceof i.aR?F=v.paint.get("raster-array-band"):v instanceof i.aS&&(F=v.paint.get("raster-particle-array-band"));const B=F||this.getInitialBand(D);if(B==null)return;if(!h.textureDescriptorPerLayer.get(v.id))return void this.prepareTile(h,D,v.id,B);if(h.updateNeeded(v.id,B)&&!A)return;const W=h.textureDescriptorPerLayer.get(v.id);return Object.assign({},W,{texture:h.texturePerLayer.get(v.id)})}getImages(h,v){const A=new Map;for(const D of h)for(const F of v){const[B,W]=F.split("/"),ee=D.getLayer(B);if(!ee||!ee.hasBand(W)||!ee.hasDataForBand(W))continue;const{bytes:ae,tileSize:le,buffer:we}=ee.getBandView(W),be=le+2*we,Ne={data:new i.q({width:be,height:be},ae),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,Ne)}return A}queryRasterArrayValueByBandId(h,v,A){const D=v._mrt;return new Promise(F=>{const B={},W=new Set;for(const[ee,ae]of Object.entries(D.layers)){if(A.layerName&&ee!==A.layerName)continue;const le={};B[ee]=le;for(const{bands:we}of ae.dataIndex)for(const be of we)A.bands&&!A.bands.includes(be)||(W.add(i.B(ee,be)),v.fetchBand(ee,null,be,Ne=>{i.o.frame(()=>{le[be]=Ne?null:hh([h.lng,h.lat],D,ae.getBandView(be)),W.delete(i.B(ee,be)),W.size===0&&F(B)})},!1))}W.size===0&&F(B)})}_loadTileForQuery(h,v){if(this._loadTileLoaded[h.uid])return void v(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(v);this._loadTilePending[h.uid]=[v];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,B,W)=>{if(F)return this._loadTilePending[h.uid].forEach(ee=>ee(F,null)),void delete this._loadTilePending[h.uid];if(!B)return this._loadTilePending[h.uid].forEach(ee=>ee(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&B){const ee=i.aM(W);h.setExpiryData(ee)}h._mrt=B,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(ee=>ee(null,B)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,v,A){return new Promise((D,F)=>{this._loadTileForQuery(v,(B,W)=>{B?F(B):D(W?this.queryRasterArrayValueByBandId(h,v,A):null)})})}queryRasterArrayValue(h,v){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?v.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,v):this.queryRasterArrayValueByAllBands(A,D,v):Promise.resolve(null)}findLoadedParent(h){const v=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,B,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 v=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,B={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(v,B,(W,ee)=>F&&!ee?(T.state="loaded",h(null)):(delete T.request,T.destroy(!1),T.aborted?h(null):W?h(W):(T.loadVectorData(ee,this.map.painter,v==="reloadTile"),h(null))),void 0,v==="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,v,A){super(T,h,v,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,v)=>{this._loaded=!0,h?this.fire(new i.y(h)):v&&(this.video=v,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,v,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=v,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,v=this.map.getWorldview();this._tileJSONRequest=Ac(this._options,this.map._requestManager,h,v,(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}`),v&&v.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${v}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new hu(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 v=this.map._requestManager.normalizeTileURL(T.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(v,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 B of F)B.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,B){return T.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&B&&T.setExpiryData(B),T.loadModelData(B,this.map.painter),T.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(T,h,v,A){super(T,h,v,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,v,A){super(),this.id=T,this.type="custom",this._dataType="raster",this._dispatcher=v,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 hu(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:v,z:A}=T.canonical;return this._implementation.hasTile({x:h,y:v,z:A})}return!this.tileBounds||this.tileBounds.contains(T.canonical)}loadTile(T,h){const{x:v,y:A,z:D}=T.tileID.canonical,F=new AbortController;T.request=Promise.resolve(this._implementation.loadTile({x:v,y:A,z:D},{signal:F.signal})).then((function(B){return delete T.request,T.aborted?(T.state="unloaded",h(null)):B===void 0?(T.state="errored",h(null)):B===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}(B)?(this.loadTileData(T,B),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(B=>{B.name!=="AbortError"&&(T.state="errored",h(B))}),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:v,y:A,z:D}=T.tileID.canonical;this._implementation.unloadTile({x:v,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"}))}}},Hl=function(T,h,v,A){const D=new Zm[h.type](T,h,v,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 Jx(T,h,v=""){return`${v}:${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 _y(T,h,v,A=""){if(T.uniqueFeatureID){const D=Jx(T,h,A);if(v.has(D))return!0;v.add(D)}return!1}function J1(T,h,v,A,D=!1){const F=h.sourceCache.transform,B=h.sourceCache.tilesIn(T,h.has3DLayers,D);B.sort(Rp);const W=[];for(const ee of B){const ae=ee.tile.queryRenderedFeatures(h,ee,v,A,F,D);Object.keys(ae).length&&W.push({wrappedTileID:ee.tile.tileID.wrapped().key,queryResults:ae})}for(const ee in h.layers){const ae=h.layers[ee];if(ae.styleLayer){const le=ae.styleLayer.queryRenderedFeatures(T,h.sourceCache,A);Object.keys(le).length&&W.push({wrappedTileID:0,queryResults:le})}}return W.length===0?{}:function(ee){const ae={},le={};for(const we of ee){const be=we.queryResults,Ne=we.wrappedTileID,Re=le[Ne]=le[Ne]||{};for(const Ie in be){const Ze=be[Ie],Ve=Re[Ie]=Re[Ie]||{},at=ae[Ie]=ae[Ie]||[];for(const ht of Ze)Ve[ht.featureIndex]||(Ve[ht.featureIndex]=!0,at.push(ht))}}return ae}(W)}function eb(T,h,v,A,D,F){const B={},W=A.queryRenderedSymbols(T),ee=[];for(const ae of Object.keys(W).map(Number))ee.push(D[ae]);ee.sort(Rp);for(const ae of ee){const le=ae.featureIndex.lookupSymbolFeatures(W[ae.bucketInstanceId],ae.bucketIndex,ae.sourceLayerIndex,h,v,F);for(const we in le){const be=B[we]=B[we]||[],Ne=le[we];Ne.sort((Re,Ie)=>{const Ze=ae.featureSortOrder;if(Ze){const Ve=Ze.indexOf(Re.featureIndex);return Ze.indexOf(Ie.featureIndex)-Ve}return Ie.featureIndex-Re.featureIndex});for(const Re of Ne)be.push(Re)}}return B}function tb(T,h){const v=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(B=>B.id===F)[0]));for(const F of D)v[F.fqid]=A}}return v}const mu=32,um=33,Vd=new Uint16Array(8184);for(let T=0;T<2046;T++){let h=T+2,v=0,A=0,D=0,F=0,B=0,W=0;for(1&h?D=F=B=mu:v=A=W=mu;(h>>=1)>1;){const ae=v+D>>1,le=A+F>>1;1&h?(D=v,F=A,v=B,A=W):(v=D,A=F,D=B,F=W),B=ae,W=le}const ee=4*T;Vd[ee+0]=v,Vd[ee+1]=A,Vd[ee+2]=D,Vd[ee+3]=F}const Td=new Uint16Array(2178),pu=new Uint8Array(1089),qf=new Uint16Array(1089);function Uf(T){return T===0?-.03125:T===32?.03125:0}const Ym={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 Qm{constructor(h,v,A,D,F,B){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=v,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=B,this._hasAppearances=null}registerFadeDuration(h){const v=h+this.timeAdded;vA)D=!1;else if(v)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,v){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 B=this.buckets[F],W=B.layers[0],ee=W.sourceLayer||"_geojsonTileLayer",ae=h.style.getLayerSourceCache(W);let le={};ae&&(le=ae._state.getState(ee,void 0));const we=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},be=Object.keys(le).length>0&&!v;B.hasAppearances=B.layers.some(Ie=>Ie.appearances&&Ie.appearances.length>0);const Ne=be?B.stateDependentLayers:B.layers;if(be&&B.stateDependentLayers.length!==0||v){const Ie=this.latestFeatureIndex.loadVTLayers();B.update(le,Ie[ee],A,we,Ne,v,D)}if(be&&B.stateDependentLayers.length!==0||v||B.hasAppearances){const Ie={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};B.updateAppearances(this.tileID.canonical,le,A,Ie)}(B instanceof i.ba||B instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ae&&B.uploadPending()&&h._terrain._clearRenderCacheForTile(ae.id,this.tileID);const Re=h&&h.style&&h.style.getOwnLayer(F);Re&&(this.queryPadding=Math.max(this.queryPadding,Re.queryRadius(B)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Ze--){const Ve=4*Ze,at=Vd[Ve+0],ht=Vd[Ve+1],ot=Vd[Ve+2],At=Vd[Ve+3],Nt=at+ot>>1,Ct=ht+At>>1,wt=Nt+Ct-ht,gt=Ct+at-Nt,Dt=ht*um+at,Ht=At*um+ot,Ut=Ct*um+Nt,es=Math.hypot((Td[2*Dt+0]+Td[2*Ht+0])/2-Td[2*Ut+0],(Td[2*Dt+1]+Td[2*Ht+1])/2-Td[2*Ut+1])>=16;pu[Ut]=pu[Ut]||(es?1:0),Ze<1022&&(pu[Ut]=pu[Ut]||pu[(ht+gt>>1)*um+(at+wt>>1)]||pu[(At+gt>>1)*um+(ot+wt>>1)])}const we=new i.b1,be=new i.b0;let Ne=0;function Re(Ze,Ve){const at=Ve*um+Ze;return qf[at]===0&&(we.emplaceBack(Td[2*at+0],Td[2*at+1],Ze*i.al/mu,Ve*i.al/mu),qf[at]=++Ne),qf[at]-1}function Ie(Ze,Ve,at,ht,ot,At){const Nt=Ze+at>>1,Ct=Ve+ht>>1;if(Math.abs(Ze-ot)+Math.abs(Ve-At)>1&&pu[Ct*um+Nt])Ie(ot,At,Ze,Ve,Nt,Ct),Ie(at,ht,ot,At,Nt,Ct);else{const wt=Re(Ze,Ve),gt=Re(at,ht),Dt=Re(ot,At);be.emplaceBack(wt,gt,Dt)}}return Ie(0,0,mu,mu,mu,0),Ie(mu,mu,0,0,0,mu),{vertices:we,indices:be}}(this.tileID.canonical,v);D=B.vertices,F=B.indices}else{D=new i.b1,F=new i.b0;for(const{x:W,y:ee}of A)D.emplaceBack(W,ee,0,0);const B=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let W=0;W0&&(ee=i.bl(new Float64Array(16),v.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,v,B,ee,W),this._makeGlobeTileDebugTextBuffer(h,D,v,B,ee,W)}_globePoint(h,v,A,D,F,B,W){let ee=i.bm(h,v,A);if(B){const ae=1<.5?Ne=-1:be<-.5&&(Ne=1);let Re=(h/i.al+A.x)/ae+Ne,Ie=(v/i.al+A.y)/ae;Re=(Re-le)*D._pixelsPerMercatorPixel+le,Ie=(Ie-we)*D._pixelsPerMercatorPixel+we;const Ze=[Re*D.worldSize,Ie*D.worldSize,0];i.af(Ze,Ze,B),ee=i.bn(ee,Ze,W)}return i.af(ee,ee,F)}_makeGlobeTileDebugBorderBuffer(h,v,A,D,F,B){const W=new i.bd,ee=new i.be,ae=new i.bo,le=(be,Ne,Re,Ie,Ze)=>{const Ve=(Re-be)/(Ze-1),at=(Ie-Ne)/(Ze-1),ht=W.length;for(let ot=0;otwe*Ne+Re;for(let Ne=0;Ne{if(F)v(F);else try{const ee=A.getHeaderLength(B);if(ee>h)return void(this.request=this.fetchHeader(ee,v));A.parseHeader(B),this._isHeaderLoaded=!0;let ae=0;for(const le of Object.values(A.layers))ae=Math.max(ae,le.dataIndex[le.dataIndex.length-1].lastByte);B.byteLength>=ae&&(this.entireBuffer=B),v(null,this.entireBuffer||B,W)}catch(ee){v(ee)}}),this.request}fetchBandForRender(h,v,A,D){this.fetchBand(h,v,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,v,A);const B=this.textureDescriptorPerLayer.get(v);D(null,B?B.img:null)})}fetchBand(h,v,A,D,F=!0){const B=this._mrt;if(!this._isHeaderLoaded||!B)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 ee;const ae=i.B(String(A),i.B(this.tileID.key,h));let le=this._taskQueue.get(ae);le?le.add(D):(le=new Set,le.add(D),this._taskQueue.set(ae,le));const we=(Ie,Ze)=>{ee.complete(Ie,Ze),Ie?D(Ie):(le.forEach(Ve=>Ve(null,Ze)),this._taskQueue.delete(ae))},be=(Ie,Ze)=>{if(Ie)return D(Ie);const Ve=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Ze,task:ee},we,void 0,!0);if(v!==null){const at=this._workQueuePerLayer.get(v)||[];at.push(()=>{Ve&&Ve.cancel(),ee.cancel()}),this._workQueuePerLayer.has(v)||this._workQueuePerLayer.set(v,at)}};let Ne;try{Ne=B.getLayer(h)}catch(Ie){if(this.state==="reloading")return;throw Ie}if(!Ne)return void D(new Error(`Unknown sourceLayer "${h}"`));if(Ne.hasDataForBand(A))return le.forEach(Ie=>Ie(null,null)),void this._taskQueue.delete(ae);const Re=Ne.getDataRange([A]);if(ee=B.createDecodingTask(Re),!ee||ee.tasks.length)if(v!==null&&this.flushQueues(v),this.entireBuffer)be(null,this.entireBuffer.slice(Re.firstByte,Re.lastByte+1));else{const Ie=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Re.firstByte}-${Re.lastByte}`}}),Ze=i.bu(Ie,be);if(v!==null){const Ve=this._fetchQueuePerLayer.get(v)||[];Ve.push(()=>{Ze.cancel(),ee.cancel()}),this._fetchQueuePerLayer.has(v)||this._fetchQueuePerLayer.set(v,Ve)}}}updateNeeded(h,v){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==v||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,v,A){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:F,tileSize:B,buffer:W,offset:ee,scale:ae}=D.getBandView(A),le=B+2*W,we=new i.q({width:le,height:le},F),be=this.texturePerLayer.get(v);be&&be instanceof i.T&&be.update(we,{premultiply:!1}),this.textureDescriptorPerLayer.set(v,{layer:h,band:A,img:we,buffer:W,offset:ee,tileSize:B,format:D.pixelFormat,mix:[ae,256*ae,65536*ae,16777216*ae]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const v of this.texturePerLayer.values())v&&v instanceof i.T&&v.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 sv{constructor(h,v){this.max=h,this.onRemove=v,this.reset()}reset(){for(const h in this.data)for(const v of this.data[h])v.timeout&&clearTimeout(v.timeout),this.onRemove(v.value);return this.data={},this.order=[],this}add(h,v,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:v,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 B=this._getAndRemoveByKey(this.order[0]);B&&this.onRemove(B)}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 v=this.data[h].shift();return v.timeout&&clearTimeout(v.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),v.value}getByKey(h){const v=this.data[h];return v?v[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,v){if(!this.has(h))return this;const A=h.wrapped().key,D=v===void 0?0:this.data[A].indexOf(v),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 v=this._getAndRemoveByKey(this.order[0]);v&&this.onRemove(v)}return this}filter(h){const v=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||v.push(D);for(const A of v)this.remove(A.value.tileID,A)}}class eg{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,v,A){const D=String(v);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,v,A){if(this.deletedStates[h]===null)return;const D=String(v);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&v!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(v!==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,v){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(v!==void 0){const W=String(v),ee=Object.assign({},A[W],D[W]);if(F){const ae=F[v];if(ae===null)return{};for(const le in ae)delete ee[le]}return ee}const B=Object.assign({},A,D);if(F)for(const W in F)delete B[W];return B}initializeTileState(h,v){h.refreshFeatureState(v)}coalesceChanges(h,v){const A={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const F={};for(const B in this.stateChanges[D])this.state[D][B]||(this.state[D][B]={}),Object.assign(this.state[D][B],this.stateChanges[D][B]),F[B]=this.state[D][B];A[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const B in this.state[D])F[B]={},this.state[D][B]={};else for(const B in this.deletedStates[D]){if(this.deletedStates[D][B]===null)this.state[D][B]={};else if(this.state[D][B])for(const W of Object.keys(this.deletedStates[D][B]))delete this.state[D][B][W];F[B]=this.state[D][B]}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(v)}}class Il extends i.E{constructor(h,v,A){super(),this.id=h,this._onlySymbols=A,v.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))}),v.on("error",()=>{this._sourceErrored=!0}),this._source=v,this._tiles={},this._cache=new sv(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=v.minTileCacheSize,this._maxTileCacheSize=v.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new eg,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,v){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,v)}_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 v in this._tiles){const A=this._tiles[v];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(sb).map(h=>h.key)}getRenderableIds(h,v){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,v)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const B=D.tileID,W=F.tileID,ee=new i.P(B.canonical.x,B.canonical.y)._rotate(this.transform.angle),ae=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return B.overscaledZ-W.overscaledZ||ae.y-ee.y||ae.x-ee.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(sb).map(D=>D.key)}hasRenderableParent(h){const v=this.findLoadedParent(h,0);return!!v&&this._isIdRenderable(v.tileID.key)}_isIdRenderable(h,v,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(v||!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,v){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=v),this._loadTile(A,this._tileLoaded.bind(this,A,h,v)))}_tileLoaded(h,v,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(v,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let B=new Map;F&&F.responseHeaders&&(B=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:B}))}_backfillDEM(h){const v=this.getRenderableIds();for(let D=0;D1||(Math.abs(B)>1&&(Math.abs(B+ee)===1?B+=ee:Math.abs(B-ee)===1&&(B-=ee)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,B,W),D.neighboringTiles&&D.neighboringTiles[ae]&&(D.neighboringTiles[ae].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,v,A,D){for(const F in this._tiles){let B=this._tiles[F];if(D[F]||!B.hasData()||B.tileID.overscaledZ<=v||B.tileID.overscaledZ>A)continue;let W=B.tileID;for(;B&&B.tileID.overscaledZ>v+1;){const ae=B.tileID.scaledTo(B.tileID.overscaledZ-1);B=this._tiles[ae.key],B&&B.hasData()&&(W=ae)}let ee=W;for(;ee.overscaledZ>v;)if(ee=ee.scaledTo(ee.overscaledZ-1),h[ee.key]){D[W.key]=W;break}}}findLoadedParent(h,v){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=v?A:null}for(let A=h.overscaledZ-1;A>=v;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const v=this._tiles[h.key];return v&&v.hasData()?v:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,v){v=v||this._source.tileSize;const A=Math.ceil(h.width/v)+1,D=Math.ceil(h.height/v)+1,F=Math.floor(A*D*5),B=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,B):B;this._cache.setMaxSize(W)}handleWrapJump(h){const v=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,v){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+v),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,v,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,v),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const B=this._source.type==="batched-model";let W,ee=this._source.maxzoom;const ae=this.map&&this.map.painter?this.map.painter._terrain:null;if(ae&&ae.sourceCache===this&&ae.attenuationRange()){const be=ae.attenuationRange()[0],Ne=Math.floor(be)-Math.log2(ae.getDemUpscale());ee>Ne&&(ee=Ne)}if(this.used||this.usedForTerrain){if(this._source.tileID)W=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(be=>new i.aQ(be.canonical.z,be.wrap,be.canonical.z,be.canonical.x,be.canonical.y));else if(this.tileCoverLift!==0){const be=h.clone();be.tileCoverLift=this.tileCoverLift,W=be.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:ee,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:B}),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:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:ee,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:B}),this._source.hasTile){const be=this._source.hasTile.bind(this._source);W=W.filter(Ne=>be(Ne))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!tg(this._source.type)){const be=h.coveringZoomLevel({tileSize:v||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),Ne=Math.min(be,this._source.maxzoom);if(B){const Re=h.extendTileCover(W,Ne);for(const Ie of Re)W.push(Ie)}else if(F){const Re=h.extendTileCoverToNearPlane(W,this.transform.getFrustum(Ne),Ne);for(const Ie of Re)W.push(Ie)}else if(this.castsShadows&&D){const Re=h.extendTileCover(W,Ne,D,16);for(const Ie of Re)this._shadowCasterTiles[Ie.key]=!0,W.push(Ie)}}const le=this._updateRetainedTiles(W);if(tg(this._source.type)&&W.length!==0){const be={},Ne={},Re=Object.keys(le);for(const Ze of Re){const Ve=le[Ze],at=this._tiles[Ze];if(!at||at.fadeEndTime&&at.fadeEndTime<=i.o.now())continue;const ht=this.findLoadedParent(Ve,Math.max(Ve.overscaledZ-Il.maxOverzooming,this._source.minzoom));ht&&(this._addTile(ht.tileID),be[ht.tileID.key]=ht.tileID),Ne[Ze]=Ve}const Ie=W[W.length-1].overscaledZ;for(const Ze in this._tiles){const Ve=this._tiles[Ze];if(le[Ze]||!Ve.hasData())continue;let at=Ve.tileID;for(;at.overscaledZ>Ie;){at=at.scaledTo(at.overscaledZ-1);const ht=this._tiles[at.key];if(ht&&ht.hasData()&&Ne[at.key]){le[Ze]=Ve.tileID;break}}}for(const Ze in be)le[Ze]||(this._coveredTiles[Ze]=!0,le[Ze]=be[Ze])}for(const be in le)this._tiles[be].clearFadeHold();const we=i.bv(this._tiles,le);for(const be of we){const Ne=this._tiles[be];Ne.hasSymbolBuckets&&!Ne.holdingForFade()?Ne.setHoldDuration(this.map._fadeDuration):Ne.hasSymbolBuckets&&!Ne.symbolFadeFinished()||this._removeTile(+be)}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 v={};if(h.length===0)return v;const A={},D=h.reduce((ae,le)=>Math.min(ae,le.overscaledZ),1/0),F=h[0].overscaledZ,B=Math.max(F-Il.maxOverzooming,this._source.minzoom),W=Math.max(F+Il.maxUnderzooming,this._source.minzoom),ee={};for(const ae of h){const le=this._addTile(ae);v[ae.key]=ae,le.hasData()||D=this._source.maxzoom){const be=ae.children(this._source.maxzoom)[0],Ne=this.getTile(be);if(Ne&&Ne.hasData()){v[be.key]=be;continue}}else{const be=ae.children(this._source.maxzoom);if(v[be[0].key]&&v[be[1].key]&&v[be[2].key]&&v[be[3].key])continue}let we=le.wasRequested();for(let be=ae.overscaledZ-1;be>=B;--be){const Ne=ae.scaledTo(be);if(A[Ne.key]||(A[Ne.key]=!0,le=this.getTile(Ne),!le&&we&&(le=this._addTile(Ne)),le&&(v[Ne.key]=Ne,we=le.wasRequested(),le.hasData())))break}}return v}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const v=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}v.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of v)this._loadedParentTiles[F]=A}}_addTile(h){let v=this._tiles[h.key];if(v)return v.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),v;v=this._cache.getAndRemove(h),v&&(this._setTileReloadTimer(h.key,v),v.tileID=h,this._state.initializeTileState(v,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,v)));const A=!!v;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();v=this._source.type==="raster-array"?new Ad(h,F,this.transform.tileZoom,D,this._isRaster):new Qm(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(v,this._tileLoaded.bind(this,v,h.key,v.state))}return v.uses++,this._tiles[h.key]=v,A||this._source.fire(new i.z("dataloading",{tile:v,coord:v.tileID,dataType:"source"})),v}_setTileReloadTimer(h,v){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=v.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const v=this._tiles[h];v&&(v.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),v.uses>0||(v.hasData()&&v.state!=="reloading"||v.state==="empty"?this._cache.add(v.tileID,v,v.getExpiryTimeout()):(v.aborted=!0,this._abortTile(v),this._unloadTile(v))))}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,v,A){const D=[],F=this.transform;if(!F)return D;const B=F.projection.name==="globe",W=i.aF(F.center.lng);for(const ee in this._tiles){const ae=this._tiles[ee];if(A&&ae.clearQueryDebugViz(),ae.holdingForFade())continue;let le;if(B){const we=ae.tileID.canonical;if(we.z===0){const be=[Math.abs(i.aA(W,...Fh(we,-1))-W),Math.abs(i.aA(W,...Fh(we,1))-W)];le=[0,2*be.indexOf(Math.min(...be))-1]}else{const be=[Math.abs(i.aA(W,...Fh(we,-1))-W),Math.abs(i.aA(W,...Fh(we,0))-W),Math.abs(i.aA(W,...Fh(we,1))-W)];le=[be.indexOf(Math.min(...be))-1]}}else le=[0];for(const we of le){const be=h.containsTile(ae,F,v,we);be&&D.push(be)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,v){const A=this.getRenderableIds(h,v).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 v=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const B of v){const W=1/(1<F[B.key]-F[W.key]),v}hasTransition(){if(this._source.hasTransition())return!0;if(tg(this._source.type))for(const h in this._tiles){const v=this._tiles[h];if(v.fadeEndTime!==void 0&&v.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,v,A){this._state.updateState(h=h||"_geojsonTileLayer",v,A)}removeFeatureState(h,v,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",v,A)}getFeatureState(h,v){return this._state.getState(h=h||"_geojsonTileLayer",v)}setDependencies(h,v,A){const D=this._tiles[h];D&&D.setDependencies(v,A)}reloadTilesForDependencies(h,v){for(const A in this._tiles)this._tiles[A].hasDependency(h,v)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,v))}_preloadTiles(h,v){if(!this._sourceLoaded){const ee=()=>{this._sourceLoaded&&(this._source.off("data",ee),this._preloadTiles(h,v))};return void this._source.on("data",ee)}const A=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,B=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const ee of D){const ae=ee.coveringTiles({tileSize:B,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 ae)A.set(le.key,le);this.usedForTerrain&&ee.updateElevation(!1)}const W=Array.from(A.values());i.bw(W,(ee,ae)=>{const le=new Qm(ee,this._source.tileSize*ee.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(le,we=>{this._source.type==="raster-dem"&&le.dem&&this._backfillDEM(le),ae(we,le)})},v)}}function sb(T,h){const v=Math.abs(2*T.wrap)-+(T.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return T.overscaledZ-h.overscaledZ||A-v||h.canonical.y-T.canonical.y||h.canonical.x-T.canonical.x}function tg(T){return T==="raster"||T==="image"||T==="video"||T==="custom"}function Fh(T,h){const v=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&&v.visible,v.visible=D}}updateZOffset(h,v){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,B=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 ee=B?B.getTile(v):null;if(!ee&&B)for(const ae in B._tiles){const le=B._tiles[ae];if(v.canonical.isChildOf(le.tileID.canonical)){ee=le;break}}this.currentBuildingBuckets.push({bucket:ee?ee.getBucket(F):null,tileID:ee?ee.tileID:v,verticalScale:W})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(v[A]=h[A])}),v}function rv(T){T=T.slice();const h=Object.create(null);for(let v=0;v0?(D-B)/W:0;return this.points[F].mult(1-ee).add(this.points[v].mult(ee))}}class e2{constructor(h,v,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(v/A);for(let B=0;Bthis.width||D<0||v>this.height)return!F&&[];const W=[];if(h<=0&&v<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let ee=0;ee0:W}_queryCircle(h,v,A,D,F){const B=h-A,W=h+A,ee=v-A,ae=v+A;if(W<0||B>this.width||ae<0||ee>this.height)return!D&&[];const le=[];return this._forEachCell(B,ee,W,ae,this._queryCellCircle,le,{hitTest:D,circle:{x:h,y:v,radius:A},seenUids:{box:{},circle:{}}},F),D?le.length>0:le}query(h,v,A,D,F){return this._query(h,v,A,D,!1,F)}hitTest(h,v,A,D,F){return this._query(h,v,A,D,!0,F)}hitTestCircle(h,v,A,D){return this._queryCircle(h,v,A,!0,D)}_queryCell(h,v,A,D,F,B,W,ee){const ae=W.seenUids,le=this.boxCells[F];if(le!==null){const be=this.bboxes;for(const Ne of le)if(!ae.box[Ne]){ae.box[Ne]=!0;const Re=4*Ne;if(h<=be[Re+2]&&v<=be[Re+3]&&A>=be[Re+0]&&D>=be[Re+1]&&(!ee||ee(this.boxKeys[Ne]))){if(W.hitTest)return B.push(!0),!0;B.push({key:this.boxKeys[Ne],x1:be[Re],y1:be[Re+1],x2:be[Re+2],y2:be[Re+3]})}}}const we=this.circleCells[F];if(we!==null){const be=this.circles;for(const Ne of we)if(!ae.circle[Ne]){ae.circle[Ne]=!0;const Re=3*Ne;if(this._circleAndRectCollide(be[Re],be[Re+1],be[Re+2],h,v,A,D)&&(!ee||ee(this.circleKeys[Ne]))){if(W.hitTest)return B.push(!0),!0;{const Ie=be[Re],Ze=be[Re+1],Ve=be[Re+2];B.push({key:this.circleKeys[Ne],x1:Ie-Ve,y1:Ze-Ve,x2:Ie+Ve,y2:Ze+Ve})}}}}}_queryCellCircle(h,v,A,D,F,B,W,ee){const ae=W.circle,le=W.seenUids,we=this.boxCells[F];if(we!==null){const Ne=this.bboxes;for(const Re of we)if(!le.box[Re]){le.box[Re]=!0;const Ie=4*Re;if(this._circleAndRectCollide(ae.x,ae.y,ae.radius,Ne[Ie+0],Ne[Ie+1],Ne[Ie+2],Ne[Ie+3])&&(!ee||ee(this.boxKeys[Re])))return B.push(!0),!0}}const be=this.circleCells[F];if(be!==null){const Ne=this.circles;for(const Re of be)if(!le.circle[Re]){le.circle[Re]=!0;const Ie=3*Re;if(this._circlesCollide(Ne[Ie],Ne[Ie+1],Ne[Ie+2],ae.x,ae.y,ae.radius)&&(!ee||ee(this.circleKeys[Re])))return B.push(!0),!0}}}_forEachCell(h,v,A,D,F,B,W,ee){const ae=this._convertToXCellCoord(h),le=this._convertToYCellCoord(v),we=this._convertToXCellCoord(A),be=this._convertToYCellCoord(D);for(let Ne=ae;Ne<=we;Ne++)for(let Re=le;Re<=be;Re++)if(F.call(this,h,v,A,D,this.xCellCount*Re+Ne,B,W,ee))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,v,A,D,F,B){const W=D-h,ee=F-v,ae=A+B;return ae*ae>W*W+ee*ee}_circleAndRectCollide(h,v,A,D,F,B,W){const ee=(B-D)/2,ae=Math.abs(h-(D+ee));if(ae>ee+A)return!1;const le=(W-F)/2,we=Math.abs(v-(F+le));if(we>le+A)return!1;if(ae<=ee||we<=le)return!0;const be=ae-ee,Ne=we-le;return be*be+Ne*Ne<=A*A}}const _t={unknown:0,flipRequired:1,flipNotRequired:2},As=Math.tan(85*Math.PI/180);function Js(T,h,v,A,D,F,B){const W=i.bC();if(v)if(F.name==="globe"){const ee=i.bD(D,h);i.aB(W,W,ee)}else{const ee=i.bE([],B);W[0]=ee[0],W[1]=ee[1],W[4]=ee[2],W[5]=ee[3],A||i.bB(W,W,D.angle)}else i.aB(W,D.labelPlaneMatrix,T);return W}function yn(T,h,v,A,D,F,B){const W=Js(T,h,v,A,D,F,B);return F.name==="globe"&&v||(W[2]=W[6]=W[10]=W[14]=0),W}function vn(T,h,v,A,D,F,B){if(v){if(F.name==="globe"){const W=Js(T,h,v,A,D,F,B);return i.bl(W,W),i.aB(W,T,W),W}{const W=i.bz(T),ee=i.bA([]);return ee[0]=B[0],ee[1]=B[1],ee[4]=B[2],ee[5]=B[3],i.aB(W,W,ee),A||i.bB(W,W,-D.angle),W}}return D.glCoordMatrix}function xa(T,h,v,A){const D=[T,h,v,1];v?i.aC(D,D,A):Vr(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Wr(T,h){return Math.min(.5+T/h*.5,1.5)}function fo(T,h){const v=T[0]/T[3],A=T[1]/T[3];return v>=-h[0]&&v<=h[0]&&A>=-h[1]&&A<=h[1]}function sg(T,h,v,A,D,F,B,W,ee,ae,le=1){const we=v.transform,be=A?T.textSizeData:T.iconSizeData,Ne=i.bK(be,v.transform.zoom,le),Re=we.projection.name==="globe",Ie=[256/v.width*2+1,256/v.height*2+1],Ze=A?T.text.dynamicLayoutVertexArray:T.icon.dynamicLayoutVertexArray;Ze.clear();let Ve=null;Re&&(Ve=A?T.text.globeExtVertexArray:T.icon.globeExtVertexArray);const at=T.lineVertexArray,ht=A?T.text.placedSymbolArray:T.icon.placedSymbolArray,ot=v.transform.width/v.transform.height;let At,Nt=!1;for(let Ct=0;CtMath.abs(v)?{useVertical:!0}:T===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==_t.unknown&&function(D,F){return D===0||Math.abs(F/D)>As}(v,A)?h===_t.flipRequired?{needsFlipping:!0}:null:v<0?{needsFlipping:!0}:null}function iv(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve,at,ht){const ot=h/24,At=T.lineOffsetX*ot,Nt=T.lineOffsetY*ot,{lineStartIndex:Ct,glyphStartIndex:wt,numGlyphs:gt,segment:Dt,writingMode:Ht,flipState:Ut}=T,es=Ct+T.lineLength,ts=_s=>{if(le){const[is,Jt,zs]=_s.up,ir=ae.length;i.bN(le,ir+0,is,Jt,zs),i.bN(le,ir+1,is,Jt,zs),i.bN(le,ir+2,is,Jt,zs),i.bN(le,ir+3,is,Jt,zs)}const[Ks,Yt,zt]=_s.point;i.bO(ae,Ks,Yt,zt,_s.angle)};if(gt>1){const _s=Fp(ot,W,At,Nt,v,we,be,T,ee,F,Ne,Ie,!1,Ze,Ve,at,ht);if(!_s)return{notEnoughRoom:!0};if(A&&!v){let[Ks,Yt,zt]=_s.first.point,[is,Jt,zs]=_s.last.point;[Ks,Yt]=xa(Ks,Yt,zt,B),[is,Jt]=xa(is,Jt,zs,B);const ir=Xr(Ht,Ut,(is-Ks)*Re,Jt-Yt);if(T.flipState=ir&&ir.needsFlipping?_t.flipRequired:_t.flipNotRequired,ir)return ir}ts(_s.first);for(let Ks=wt+1;Ks0?is:Jm(be,zt,Ks,1,D,void 0,Ze,Ve.canonical),zs=Xr(Ht,Ut,(Jt[0]-Ks[0])*Re,Jt[1]-Ks[1]);if(T.flipState=zs&&zs.needsFlipping?_t.flipRequired:_t.flipNotRequired,zs)return zs}const _s=nb(ot*W.getoffsetX(wt),At,Nt,v,we,be,Dt,Ct,es,ee,F,Ne,Ie,!1,!1,Ze,Ve,at,ht);if(!_s)return{notEnoughRoom:!0};ts(_s)}return{}}function ov(T,h,v,A,D){const{x:F,y:B,z:W}=A.projectTilePoint(T.x,T.y,h);if(!D)return xa(F,B,W,v);const[ee,ae,le]=D.getElevation(T,D.elevation,D.elevationFeature);return xa(F+ee,B+ae,W+le,v)}function Jm(T,h,v,A,D,F,B,W){const ee=ov(T.sub(h)._unit()._add(T),W,D,B,F);return i.av(ee,v,ee),i.aw(ee,ee),i.bH(ee,v,ee,A)}function nb(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve,at){const ht=A?T-h:T+h;let ot=ht>0?1:-1,At=0;A&&(ot*=-1,At=Math.PI),ot<0&&(At+=Math.PI);let Nt=W+B+(ot>0?0:1)|0,Ct=D,wt=D,gt=0,Dt=0;const Ht=Math.abs(ht),Ut=[],es=[];let ts=F,_s=ts,Ks=i.bF([]);const Yt=()=>Jm(_s,ts,wt,Ht-gt+1,le,be,Ie,Ze.canonical);for(;gt+Dt<=Ht;){if(Nt+=ot,Nt=ee)return null;if(wt=Ct,_s=ts,Ut.push(wt),Ne&&es.push(_s),ts=new i.P(ae.getx(Nt),ae.gety(Nt)),Ct=we[Nt],!Ct){const Pr=ov(ts,Ze.canonical,le,Ie,be);Ct=Pr[3]>0?we[Nt]=Pr:Yt()}gt+=Dt;const Zs=i.av([],Ct,wt),Dr=i.bG(wt,Ct);if(v&&Dr>0&&Dt>0&&i.bJ(Ks,Zs)/(Dt*Dr)0,ht),Ct=ae*Nt.perspectiveRatio,wt=(A.x1*v+W.x-A.padding)*Ct+Nt.point.x,gt=(A.y1*v+W.y-A.padding)*Ct+Nt.point.y,Dt=(A.x2*v+W.x+A.padding)*Ct+Nt.point.x,Ht=(A.y2*v+W.y+A.padding)*Ct+Nt.point.y,Ut=Nt.perspectiveRatio<=.55||Nt.occluded;return!this.isInsideGrid(wt,gt,Dt,Ht)||!ee&&this.grid.hitTest(wt,gt,Dt,Ht,we)||Ut?{box:[],offscreen:!1,occluded:Nt.occluded}:{box:[wt,gt,Dt,Ht],offscreen:this.isOffscreen(wt,gt,Dt,Ht),occluded:!1}}placeCollisionCircles(h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze){const Ve=[],at=this.transform.elevation,ht=h.getProjection(),ot=h.elevationType==="road",At=!!at||ot,Nt=i.bV.getAtTileOffsetFunc(Ze,this.transform.center.lat,this.transform.worldSize,ht),Ct=new i.P(A.tileAnchorX,A.tileAnchorY),wt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:gt,y:Dt,z:Ht}=ht.projectTilePoint(wt.x,wt.y,Ze.canonical),Ut=null;if(At){const Dr=ot?h.getElevationFeatureForText(D):null;Ut={getElevation:Nt,elevation:at,elevationFeature:Dr};const[Pr,pr,wr]=Nt(Ct,at,Dr);gt+=Pr,Dt+=pr,Ht+=wr}const es=ht.name==="globe",ts=this.projectAndGetPerspectiveRatio(ee,gt,Dt,Ht,Ze,es||!!at||this.transform.pitch>0,ht),{perspectiveRatio:_s}=ts,Ks=(be?W/_s:W*_s)/i.bY,Yt=xa(gt,Dt,Ht,ae),zt=A.lineOffsetX*Ks,is=A.lineOffsetY*Ks,Jt=i.an(h.layers[0].layout.get("text-max-angle")),zs=Math.cos(Jt),ir=ts.signedDistanceFromCamera>0?Fp(Ks,B,zt,is,ot&&A.flipState===1,Yt,wt,A,F,ae,{},At&&!be?Ut:null,be&&At,ht,Ze,be,zs):null;let br=!1,er=!1,Zs=!0;if(ir&&!ts.occluded){const Dr=.5*Re*_s+Ie,Pr=new i.P(-100,-100),pr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),wr=new jy,{first:Qr,last:On}=ir,Sa=Qr.path.length;let oi=[];for(let En=Sa-1;En>=1;En--)oi.push(Qr.path[En]);for(let En=1;En(At&&!es&&(Ti=Nt(jiEn[3]<=0)&&(oi=[]));let ei=[];if(oi.length>0){let En=1/0,pi=-1/0,Ti=1/0,ji=-1/0;for(const Xa of oi)En=Math.min(En,Xa[0]),Ti=Math.min(Ti,Xa[1]),pi=Math.max(pi,Xa[0]),ji=Math.max(ji,Xa[1]);pi>=Pr.x&&En<=pr.x&&ji>=Pr.y&&Ti<=pr.y&&(ei=[oi.map(Xa=>new i.P(Xa[0],Xa[1]))],(Enpr.x||Tipr.y)&&(ei=i.bW(ei,Pr.x,Pr.y,pr.x,pr.y)))}for(const En of ei){wr.reset(En,.25*Dr);let pi=0;pi=wr.length<=.5*Dr?1:Math.ceil(wr.paddedLength/Fr)+1;for(let Ti=0;Ti0?(i.aC(ee,ee,h),this.fogState&&F&&W.name!=="globe"&&(ae=function(be,Ne,Re,Ie,Ze,Ve){const at=Ve.calculateFogTileMatrix(Ze),ht=[Ne,Re,Ie];return i.af(ht,ht,at),_r(be,i.ag(ht),Ve.pitch,Ve._fov)}(this.fogState,v,A,D,F.toUnwrapped(),this.transform)>.9)):Vr(ee,ee,h);const le=ee[3];return{point:new i.P((ee[0]/le+1)/2*this.transform.width+$a,(-ee[1]/le+1)/2*this.transform.height+$a),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/le*.5,1.5),signedDistanceFromCamera:le,occluded:B&&ee[2]>le||ae}}isOffscreen(h,v,A,D){return A<$a||h>=this.screenRightBoundary||D<$a||v>this.screenBottomBoundary}isInsideGrid(h,v,A,D){return A>=0&&h=0&&vA.collisionGroupID===v}}return this.collisionGroups[h]}}function Hd(T,h,v,A,D){const{horizontalAlign:F,verticalAlign:B}=i.c1(T),W=-(F-.5)*h,ee=-(B-.5)*v,ae=i.c2(T,A);return new i.P(W+ae[0]*D,ee+ae[1]*D)}function Nl(T,h,v,A,D){const F=new i.P(T,h);return v&&F._rotate(A?D:-D),F}class zme{constructor(h,v,A,D,F,B){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new Mi(this.transform,F),this.buildingIndex=B,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=v,this.retainedQueryData={},this.collisionGroups=new s2(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,v,A,D,F=1){const B=A.getBucket(v),W=A.latestFeatureIndex;if(!B||!W||v.fqid!==B.layerIds[0])return;const ee=B.layers[0].layout,ae=B.layers[0].paint,le=A.collisionBoxArray,we=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),be=A.tileSize/i.al,Ne=A.tileID.toUnwrapped();this.transform.setProjection(B.projection);const Re=(Ie=A.tileID,Ze=B.getProjection(),Ve=this.transform,Ze.name===this.projection?Ve.calculateProjMatrix(Ie.toUnwrapped()):Jw(Ve,Ze,Ie));var Ie,Ze,Ve;const at=ee.get("text-pitch-alignment")==="map",ht=ee.get("text-rotation-alignment")==="map";v.compileFilter(v.options);const ot=v.dynamicFilter(),At=v.dynamicFilterNeedsFeature(),Nt=this.transform.calculatePixelsToTileUnitsMatrix(A),Ct=yn(Re,A.tileID.canonical,at,ht,this.transform,B.getProjection(),Nt);let wt=null;const gt=B.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(at){const zt=vn(Re,A.tileID.canonical,at,ht,this.transform,B.getProjection(),Nt);wt=i.aB([],this.transform.labelPlaneMatrix,zt)}let Dt=null;ot&&A.latestFeatureIndex&&(Dt={unwrappedTileID:Ne,dynamicFilter:ot,dynamicFilterNeedsFeature:At}),this.retainedQueryData[B.bucketInstanceId]=new t2(B.bucketInstanceId,W,B.sourceLayerIndex,B.index,A.tileID);const[Ht,Ut]=B.layers[0].layout.get("text-size-scale-range"),es=i.aA(F,Ht,Ut),[ts,_s]=ee.get("icon-size-scale-range"),Ks=i.aA(F,ts,_s),Yt={bucket:B,layout:ee,paint:ae,posMatrix:Re,invMatrix:gt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:Ct,labelToScreenMatrix:wt,clippingData:Dt,scale:we,textPixelRatio:be,holdingForFade:A.holdingForFade(),collisionBoxArray:le,partiallyEvaluatedTextSize:i.bK(B.textSizeData,this.transform.zoom,es),partiallyEvaluatedIconSize:i.bK(B.iconSizeData,this.transform.zoom,Ks),collisionGroup:this.collisionGroups.get(B.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const zt of B.sortKeyRanges){const{sortKey:is,symbolInstanceStart:Jt,symbolInstanceEnd:zs}=zt;h.push({sortKey:is,symbolInstanceStart:Jt,symbolInstanceEnd:zs,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:B.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve,at,ht,ot,At){const{textOffset0:Nt,textOffset1:Ct,crossTileID:wt}=Ie,gt=[Nt,Ct],Dt=Hd(h,B,W,gt,ee),Ht=this.collisionIndex.placeCollisionBox(Ve,ee,v,A,D,F,Nl(Dt.x,Dt.y,ae,le,this.transform.angle),Re,we,be,Ne.predicate);if(ht){const Ut=Ve.getSymbolInstanceIconSize(At,this.transform.zoom,Ie.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Ve,Ut,ht,A,D,F,Nl(Dt.x,Dt.y,ae,le,this.transform.angle),Re,we,be,Ne.predicate).box.length===0)return}if(Ht.box.length>0){let Ut;return this.prevPlacement&&this.prevPlacement.variableOffsets[wt]&&this.prevPlacement.placements[wt]&&this.prevPlacement.placements[wt].text&&(Ut=this.prevPlacement.variableOffsets[wt].anchor),this.variableOffsets[wt]={textOffset:gt,width:B,height:W,anchor:h,textScale:ee,prevAnchor:Ut},this.markUsedJustification(Ve,h,Ie,at),Ve.allowVerticalPlacement&&(this.markUsedOrientation(Ve,at,Ie),this.placedOrientations[wt]=at),{shift:Dt,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,v,A,D,F=1){const{bucket:B,layout:W,paint:ee,posMatrix:ae,textLabelPlaneMatrix:le,labelToScreenMatrix:we,clippingData:be,textPixelRatio:Ne,mercatorCenter:Re,invMatrix:Ie,holdingForFade:Ze,collisionBoxArray:Ve,partiallyEvaluatedTextSize:at,partiallyEvaluatedIconSize:ht,collisionGroup:ot,latestFeatureIndex:At}=h.parameters,Nt=W.get("text-optional"),Ct=W.get("icon-optional"),wt=W.get("text-allow-overlap"),gt=W.get("icon-allow-overlap"),Dt=W.get("text-rotation-alignment")==="map",Ht=W.get("icon-rotation-alignment")==="map",Ut=W.get("text-pitch-alignment")==="map",es=ee.get("symbol-z-offset"),ts=W.get("symbol-elevation-reference")==="sea",_s=W.get("symbol-placement"),[Ks,Yt]=W.get("text-size-scale-range"),[zt,is]=W.get("icon-size-scale-range"),Jt=i.aA(F,Ks,Yt),zs=i.aA(F,zt,is),ir=W.get("text-variable-anchor"),br=Dt&&_s!=="point",er=Ht&&_s!=="point",Zs=ir&&B.hasTextData(),Dr=B.hasIconTextFit()&&Zs&&B.hasIconData();this.transform.setProjection(B.projection);const Pr=Zs||br,pr=er||Dr;let wr=wt&&(gt||!B.hasIconData()||Ct),Qr=gt&&(wt||!B.hasTextData()||Nt);const On=!es.isConstant();!B.collisionArrays&&Ve&&B.deserializeCollisionBoxes(Ve),A&&D&&B.updateCollisionDebugBuffers(this.transform.zoom,Ve,Jt,zs);const Sa=(Fr,ei,En)=>{const{crossTileID:pi,numVerticalGlyphVertices:Ti}=Fr;let ji=null;if(be&&be.dynamicFilterNeedsFeature||On){const Ro=this.retainedQueryData[B.bucketInstanceId];ji=At.loadFeature({featureIndex:Fr.featureIndex,bucketIndex:Ro.bucketIndex,sourceLayerIndex:Ro.sourceLayerIndex,layoutVertexArrayOffset:0});const nl=ji.properties?ji.properties.worldview:null;if(B.localizable&&B.worldview&&typeof nl=="string")if(nl==="all")ji.properties.$localized=!0;else{if(!nl.split(",").includes(B.worldview))return;ji.properties.$localized=!0,ji.properties.worldview=B.worldview}}if(be&&!(0,be.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:B.worldview},ji,this.retainedQueryData[B.bucketInstanceId].tileID.canonical,new i.P(Fr.tileAnchorX,Fr.tileAnchorY),this.transform.calculateDistanceTileData(be.unwrappedTileID)))return this.placements[pi]=new bi(!1,!1,!1,!0),void v.add(pi);const Xa=es.evaluate(ji,{});if(v.has(pi))return;if(Ze)return void(this.placements[pi]=new bi(!1,!1,!1));let Kn=!1,hi=!1,To=!0,oo=!1,fi=!1,Va=null,Zn={box:null,offscreen:null,occluded:null},eo={box:null},Ko=null,ko=null,Ri=null,Vu=0,Ed=0,Kl=0;En.textFeatureIndex?Vu=En.textFeatureIndex:Fr.useRuntimeCollisionCircles&&(Vu=Fr.featureIndex),En.verticalTextFeatureIndex&&(Ed=En.verticalTextFeatureIndex);const Wd=B.elevationFeatures?B.elevationFeatures[Fr.elevationFeatureIndex]:void 0,Kd=Ro=>{Ro.tileID=this.retainedQueryData[B.bucketInstanceId].tileID;const nl=this.transform.elevation;Ro.elevation=ts?Xa:Xa+i.bV.getAtTileOffset(Ro.tileID,new i.P(Ro.tileAnchorX,Ro.tileAnchorY),nl,Wd),Ro.elevation+=Fr.zOffset},ld=En.textBox;if(ld){Kd(ld);const Ro=Fi=>{let xl=i.bL.horizontal;if(B.allowVerticalPlacement&&!Fi&&this.prevPlacement){const Ao=this.prevPlacement.placedOrientations[pi];Ao&&(this.placedOrientations[pi]=Ao,xl=Ao,this.markUsedOrientation(B,xl,Fr))}return xl},nl=(Fi,xl)=>{if(B.allowVerticalPlacement&&Ti>0&&En.verticalTextBox){for(const Ao of B.writingModes)if(Ao===i.bL.vertical?(Zn=xl(),eo=Zn):Zn=Fi(),Zn&&Zn.box&&Zn.box.length)break}else Zn=Fi()};if(ir){let Fi=ir;if(this.prevPlacement&&this.prevPlacement.variableOffsets[pi]){const So=this.prevPlacement.variableOffsets[pi];Fi.indexOf(So.anchor)>0&&(Fi=Fi.filter(op=>op!==So.anchor),Fi.unshift(So.anchor))}const xl=(So,op,A2)=>{const Hp=B.getSymbolInstanceTextSize(at,Fr,this.transform.zoom,ei),E2=(So.x2-So.x1)*Hp+2*So.padding,Mb=(So.y2-So.y1)*Hp+2*So.padding,Jf=Fr.hasIconTextFit&&!gt?op:null;Jf&&Kd(Jf);let xg={box:[],offscreen:!1,occluded:!1};const Tb=wt?2*Fi.length:Fi.length;for(let zy=0;zy=Fi.length,Fr,ei,B,A2,Jf,at,ht);if(gg&&(xg=gg.placedGlyphBoxes,xg&&xg.box&&xg.box.length)){Kn=!0,Va=gg.shift;break}}return xg};nl(()=>xl(ld,En.iconBox,i.bL.horizontal),()=>{const So=En.verticalTextBox;return So&&Kd(So),B.allowVerticalPlacement&&!(Zn&&Zn.box&&Zn.box.length)&&Ti>0&&So?xl(So,En.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Zn&&(Kn=Zn.box,To=Zn.offscreen,oo=Zn.occluded);const Ao=Ro(!(!Zn||!Zn.box));if(!Kn&&this.prevPlacement){const So=this.prevPlacement.variableOffsets[pi];So&&(this.variableOffsets[pi]=So,this.markUsedJustification(B,So.anchor,Fr,Ao))}}else{const Fi=(xl,Ao)=>{const So=B.getSymbolInstanceTextSize(at,Fr,this.transform.zoom,ei),op=this.collisionIndex.placeCollisionBox(B,So,xl,Re,Ie,Pr,new i.P(0,0),wt,Ne,ae,ot.predicate);return op&&op.box&&op.box.length&&(this.markUsedOrientation(B,Ao,Fr),this.placedOrientations[pi]=Ao),op};nl(()=>Fi(ld,i.bL.horizontal),()=>{const xl=En.verticalTextBox;return B.allowVerticalPlacement&&Ti>0&&xl?(Kd(xl),Fi(xl,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),Ro(!!(Zn&&Zn.box&&Zn.box.length))}}if(Ko=Zn,Kn=Ko&&Ko.box&&Ko.box.length>0,To=Ko&&Ko.offscreen,oo=Ko&&Ko.occluded,Fr.useRuntimeCollisionCircles){const Ro=Fr.centerJustifiedTextSymbolIndex>=0?Fr.centerJustifiedTextSymbolIndex:Fr.verticalPlacedTextSymbolIndex,nl=B.text.placedSymbolArray.get(Ro),Fi=i.bM(B.textSizeData,at,nl),xl=W.get("text-padding");ko=this.collisionIndex.placeCollisionCircles(B,wt,nl,Ro,B.lineVertexArray,B.glyphOffsetArray,Fi,ae,le,we,A,Ut,ot.predicate,Fr.collisionCircleDiameter*Fi/i.bY,xl,this.retainedQueryData[B.bucketInstanceId].tileID),Kn=wt||ko.circles.length>0&&!ko.collisionDetected,To=To&&ko.offscreen,oo=ko.occluded}if(En.iconFeatureIndex&&(Kl=En.iconFeatureIndex),En.iconBox){const Ro=nl=>{Kd(nl);const Fi=Fr.hasIconTextFit&&Va?Nl(Va.x,Va.y,Dt,Ut,this.transform.angle):new i.P(0,0),xl=B.getSymbolInstanceIconSize(ht,this.transform.zoom,Fr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(B,xl,nl,Re,Ie,pr,Fi,gt,Ne,ae,ot.predicate)};eo&&eo.box&&eo.box.length&&En.verticalIconBox?(Ri=Ro(En.verticalIconBox),hi=Ri.box.length>0):(Ri=Ro(En.iconBox),hi=Ri.box.length>0),To=To&&Ri.offscreen,fi=Ri.occluded}const gm=Nt||Fr.numHorizontalGlyphVertices===0&&Ti===0,ip=Ct||Fr.numIconVertices===0;if(gm||ip?ip?gm||(hi=hi&&Kn):Kn=hi&&Kn:hi=Kn=hi&&Kn,Kn&&Ko&&Ko.box&&this.collisionIndex.insertCollisionBox(Ko.box,W.get("text-ignore-placement"),B.bucketInstanceId,eo&&eo.box&&Ed?Ed:Vu,ot.ID),hi&&Ri&&this.collisionIndex.insertCollisionBox(Ri.box,W.get("icon-ignore-placement"),B.bucketInstanceId,Kl,ot.ID),ko&&(Kn&&this.collisionIndex.insertCollisionCircles(ko.circles,W.get("text-ignore-placement"),B.bucketInstanceId,Vu,ot.ID),A)){const Ro=B.bucketInstanceId;let nl=this.collisionCircleArrays[Ro];nl===void 0&&(nl=this.collisionCircleArrays[Ro]=new K3);for(let Fi=0;Fi=0;--ei){const En=Fr[ei];Sa(B.symbolInstances.get(En),En,B.collisionArrays[En])}B.hasAnyZOffset&&i.w(`${B.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(B.hasAnyZOffset){const Fr=B.getSortedIndexesByZOffset();for(let ei=0;ei=0&&(h.text.placedSymbolArray.get(F).crossTileID=we>=0&&F!==we?0:ae),B>=0&&(h.text.placedSymbolArray.get(B).crossTileID=we>=0&&B!==we?0:ae),W>=0&&(h.text.placedSymbolArray.get(W).crossTileID=we>=0&&W!==we?0:ae),ee>=0&&(h.text.placedSymbolArray.get(ee).crossTileID=we>=0&&ee!==we?0:ae)}markUsedOrientation(h,v,A){const D=v===i.bL.horizontal||v===i.bL.horizontalOnly?v:0,F=v===i.bL.vertical?v:0,{leftJustifiedTextSymbolIndex:B,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:ae}=A,le=h.text.placedSymbolArray;B>=0&&(le.get(B).placedOrientation=D),W>=0&&(le.get(W).placedOrientation=D),ee>=0&&(le.get(ee).placedOrientation=D),ae>=0&&(le.get(ae).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const v=this.prevPlacement;let A=!1;this.prevZoomAdjustment=v?v.zoomAdjustment(this.transform.zoom):0;const D=v?v.symbolFadeChange(h):1,F=v?v.opacities:{},B=v?v.variableOffsets:{},W=v?v.placedOrientations:{};for(const ee in this.placements){const ae=this.placements[ee],le=F[ee];le?(this.opacities[ee]=new Vf(le,D,ae.text,ae.icon,null,ae.clipped),A=A||ae.text!==le.text.placed||ae.icon!==le.icon.placed):(this.opacities[ee]=new Vf(null,D,ae.text,ae.icon,ae.skipFade,ae.clipped),A=A||ae.text||ae.icon)}for(const ee in F){const ae=F[ee];if(!this.opacities[ee]){const le=new Vf(ae,D,!1,!1);le.isHidden()||(this.opacities[ee]=le,A=A||ae.text.placed||ae.icon.placed)}}for(const ee in B)this.variableOffsets[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.variableOffsets[ee]=B[ee]);for(const ee in W)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=W[ee]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=v?v.lastPlacementChangeTime:h)}updateLayerOpacities(h,v,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const B of v){const W=B.getBucket(h);W&&B.latestFeatureIndex&&h.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,F,B,B.collisionBoxArray,A,D,B.tileID,h.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,B.tileID),W.elevationType==="road"&&W.updateRoadElevation(B.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(h,v,A,D,F,B,W,ee){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 ae=h.layers[0].layout,le=h.layers[0].paint,we=!!h.layers[0].dynamicFilter(),be=new Vf(null,0,!1,!1,!0),Ne=ae.get("text-allow-overlap"),Re=ae.get("icon-allow-overlap"),Ie=ae.get("text-variable-anchor"),Ze=ae.get("text-rotation-alignment")==="map",Ve=ae.get("text-pitch-alignment")==="map",at=le.get("symbol-z-offset"),ht=ae.get("symbol-elevation-reference")==="sea",ot=!at.isConstant(),At=new Vf(null,0,Ne&&(Re||!h.hasIconData()||ae.get("icon-optional")),Re&&(Ne||!h.hasTextData()||ae.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const Nt=(wt,gt,Dt)=>{for(let Ht=0;Ht0||Ht>0,ir=es>0,br=this.placedOrientations[Ut],er=br===i.bL.vertical,Zs=br===i.bL.horizontal||br===i.bL.horizontalOnly;!zs&&!ir||Jt.isHidden()||Ct++;let Dr=!1;if((zs||ir)&&B)for(const Pr of h.activeReplacements){if(i.bZ(Pr,F,i.b_.Symbol,ee)||Pr.min.x>ts||ts>Pr.max.x||Pr.min.y>_s||_s>Pr.max.y)continue;const pr=i.b$(ts,_s,W.canonical,Pr.footprintTileId.canonical);if(Dr=i.c0(pr,Pr.footprint),Dr)break}if(zs){const Pr=Dr?lv:Bu(Jt.text);Nt(h.text,Dt,er?lv:Pr),Nt(h.text,Ht,Zs?lv:Pr);const pr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:wr,centerJustifiedTextSymbolIndex:Qr,rightJustifiedTextSymbolIndex:On,verticalPlacedTextSymbolIndex:Sa}=gt,oi=h.text.placedSymbolArray,Fr=pr||er?1:0;wr>=0&&(oi.get(wr).hidden=Fr),Qr>=0&&(oi.get(Qr).hidden=Fr),On>=0&&(oi.get(On).hidden=Fr),Sa>=0&&(oi.get(Sa).hidden=pr||Zs?1:0);const ei=this.variableOffsets[Ut];ei&&this.markUsedJustification(h,ei.anchor,gt,br);const En=this.placedOrientations[Ut];En&&(this.markUsedJustification(h,"left",gt,En),this.markUsedOrientation(h,En,gt))}if(ir){const Pr=Dr?lv:Bu(Jt.icon),{placedIconSymbolIndex:pr,verticalPlacedIconSymbolIndex:wr}=gt,Qr=h.icon.placedSymbolArray,On=Jt.icon.isHidden()?1:0;pr>=0&&(Nt(h.icon,es,er?lv:Pr),Qr.get(pr).hidden=On),wr>=0&&(Nt(h.icon,gt.numVerticalIconVertices,Zs?lv:Pr),Qr.get(wr).hidden=On)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Pr=h.collisionArrays[wt];if(Pr){let pr=new i.P(0,0),wr=!0;if(Pr.textBox||Pr.verticalTextBox){if(Ie){const On=this.variableOffsets[Ut];On?(pr=Hd(On.anchor,On.width,On.height,On.textOffset,On.textScale),Ze&&pr._rotate(Ve?this.transform.angle:-this.transform.angle)):wr=!1}we&&(wr=!Jt.clipped),Pr.textBox&&Ny(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!wr||er,zt,ht,pr.x,pr.y),Pr.verticalTextBox&&Ny(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!wr||Zs,zt,ht,pr.x,pr.y)}const Qr=wr&&!!(!Zs&&Pr.verticalIconBox);Pr.iconBox&&Ny(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Qr,zt,ht,gt.hasIconTextFit?pr.x:0,gt.hasIconTextFit?pr.y:0),Pr.verticalIconBox&&Ny(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Qr,zt,ht,gt.hasIconTextFit?pr.x:0,gt.hasIconTextFit?pr.y:0)}}}if(h.fullyClipped=Ct===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 Ny(T,h,v,A,D,F,B){T.emplaceBack(h?1:0,v?1:0,F||0,B||0,A,D?1:0),T.emplaceBack(h?1:0,v?1:0,F||0,B||0,A,D?1:0),T.emplaceBack(h?1:0,v?1:0,F||0,B||0,A,D?1:0),T.emplaceBack(h?1:0,v?1:0,F||0,B||0,A,D?1:0)}const n6=Math.pow(2,25),r2=Math.pow(2,24),Z3=Math.pow(2,17),a6=Math.pow(2,16),Y3=Math.pow(2,9),zu=Math.pow(2,8),rg=Math.pow(2,1);function Bu(T){if(T.opacity===0&&!T.placed)return 0;if(T.opacity===1&&T.placed)return 4294967295;const h=T.placed?1:0,v=Math.floor(127*T.opacity);return v*n6+h*r2+v*Z3+h*a6+v*Y3+h*zu+v*rg+h}const lv=0;class ab{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,v,A,D,F,B){const W=this._bucketParts;for(;this._currentTileIndexee.sortKey-ae.sortKey));this._currentPartIndex{const ee=i.o.now()-B;return!this._forceFullPlacement&&ee>2};for(;this._currentPlacementIndex>=0;){const ee=v[h[this._currentPlacementIndex]],ae=this.placement.collisionIndex.transform.zoom;if(ee.type==="symbol"&&ee.visibility!=="none"&&(!ee.minzoom||ee.minzoom<=ae)&&(!ee.maxzoom||ee.maxzoom>ae)){const le=ee,we=le.layout.get("symbol-z-elevate"),be=le.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ne=le.layout.get("symbol-z-order"),Re=Ne==="viewport-y"||Ne==="auto"&&!(Ne!=="viewport-y"&&be),Ie=le.layout.get("text-allow-overlap")||le.layout.get("icon-allow-overlap")||le.layout.get("text-ignore-placement")||le.layout.get("icon-ignore-placement"),Ze=Re&&Ie,Ve=this._inProgressLayer=this._inProgressLayer||new ab(le),at=i.B(ee.source,ee.scope);if(Ve.continuePlacement(we||Ze?D[at]:A[at],this.placement,this._showCollisionBoxes,ee,W,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const ep=512/i.al/2;class ng{constructor(h,v,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(v.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let B=0;BZe-Ve);for(const Ze of Ie){const Ve=this.crossTileIDs[Ze];if(this.keys[Ze]===le&&!A.has(Ve)){A.add(Ve),ae.crossTileID=Ve;break}}}}}class pc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class i6{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const v=Math.round((h-this.lng)/360);if(v!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const B in D){const W=D[B];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+v),F[W.tileID.key]=W}this.indexes[A]=F}this.lng=h}addBucket(h,v,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===v.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const W in B){const ee=B[W];ee.tileID.isChildOf(h)&&ee.findMatches(v.symbolInstances,h,D)}else{const W=B[h.scaledTo(Number(F)).key];W&&W.findMatches(v.symbolInstances,h,D)}}for(let F=0;F{v[A]=!0});for(const A in this.layerIndexes)v[A]||delete this.layerIndexes[A]}}const Hf=771;class Gn{constructor(h,v,A,D){this.blendFunction=h,this.blendColor=v.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}Gn.Replace=[1,0,1,0],Gn.disabled=new Gn(Gn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Gn.unblended=new Gn(Gn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Gn.alphaBlended=new Gn([1,Hf,1,Hf],i.ao.transparent,[!0,!0,!0,!0]),Gn.alphaBlendedNonPremultiplied=new Gn([770,Hf,770,Hf],i.ao.transparent,[!0,!0,!0,!0]),Gn.multiply=new Gn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Gn.additive=new Gn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Br{constructor(h,v,A){this.func=h,this.mask=v,this.range=A}}Br.ReadOnly=!1,Br.ReadWrite=!0,Br.disabled=new Br(519,Br.ReadOnly,[0,1]);const Q3=7680;class bn{constructor(h,v,A,D,F,B){this.test=h,this.ref=v,this.mask=A,this.fail=D,this.depthFail=F,this.pass=B}}bn.disabled=new bn({func:519,mask:0},0,0,Q3,Q3,Q3);const ib=1029,X3=2305;class gn{constructor(h,v,A){this.enable=h,this.mode=v,this.frontFace=A}}function Gf(T,h){const v=i.ca(T,3);i.cc(T,h),i.cg(T,3,v)}function o6(T,h){const v=i.c7([]);return i.c8(v,v,-h),i.c9(v,v,-T),v}function J3(T,h){const v=[T[0],T[1],0],A=[h[0],h[1],0];if(i.ag(v)>=1e-15){const B=i.aw([],v);i.c5(A,B,i.bJ(A,B)),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 o6(Math.atan2(Math.sqrt(T[0]*T[0]+T[1]*T[1]),-T[2]),F)}gn.disabled=new gn(!1,ib,X3),gn.backCCW=new gn(!0,ib,X3),gn.backCW=new gn(!0,ib,2304),gn.frontCW=new gn(!0,1028,2304),gn.frontCCW=new gn(!0,1028,X3);class $u{constructor(h,v){this.position=h,this.orientation=v}get position(){return this._position}set position(h){if(h){const v=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(v.x=i.bT(v.x,0,1)),this._position=v}else this._position=null}lookAtPoint(h,v,A){if(this.orientation=null,!this.position)return;const D=this.position,F=A||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),B=i.ae.fromLngLat(h,F),W=[B.x-D.x,B.y-D.y,B.z-D.z];v||(v=[0,0,1]),v[2]=Math.abs(v[2]),this.orientation=J3(W,v)}setPitchBearing(h,v){this.orientation=o6(i.an(h),i.an(-v))}}class eC{constructor(h,v){this._transform=i.bA([]),this.orientation=v,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 v;h&&i.cg(this._transform,3,[(v=h)[0],v[1],v[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&Gf(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),v=this.right();return{bearing:Math.atan2(-v[1],v[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,v){this._orientation=o6(h,v),Gf(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,v){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,v)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,v,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]*=v,F}getWorldToCamera(h,v){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]*=v,A[9]*=v,A[10]*=v,A[11]*=v,A}getCameraToClipPerspective(h,v,A,D){const F=new Float64Array(16);return i.cd(F,h,v,A,D),F}getCameraToClipOrthographic(h,v,A,D,F,B){const W=new Float64Array(16);return i.ce(W,h,v,A,D,F,B),W}getDistanceToElevation(h,v=!1){const A=h===0?0:i.cf(h,v?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new eC([...this.position],[...this.orientation])}}const Kc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class tC{constructor(h=0,v=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(v)||v<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=v,this.left=A,this.right=D}interpolate(h,v,A){return v.top!=null&&h.top!=null&&(this.top=i.ak(h.top,v.top,A)),v.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,v.bottom,A)),v.left!=null&&h.left!=null&&(this.left=i.ak(h.left,v.left,A)),v.right!=null&&h.right!=null&&(this.right=i.ak(h.right,v.right,A)),this}getCenter(h,v){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+v-this.bottom)/2,0,v);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 tC(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const $p=15;class l6{constructor(h,v,A,D,F,B,W){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=v||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(B),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 tC,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new eC,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 l6(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.pitch<$p}get elevation(){return this._elevation}set elevation(h){this._elevation!==h&&(this._elevation=h,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(h,v=!1){const A=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||A)&&this._updateCameraOnTerrain(),(h||A)&&this._constrainCamera(v),this._calcMatrices()}getProjection(){return i.aH(this.projection,["name","center","parallels"])}setProjection(h){this.projectionOptions=h||{name:"mercator"};const v=this.projection?this.getProjection():void 0;this.projection=i.cm(this.projectionOptions);const A=this.getProjection(),D=!i.by(v,A);return D&&this._calcMatrices(),this.mercatorFromTransition=!1,D}setOrthographicProjectionAtLowPitch(h){return this._orthographicProjectionAtLowPitch!==h&&(this._orthographicProjectionAtLowPitch=h,this._calcMatrices(),!0)}setMercatorFromTransition(){const h=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=i.cm({name:"mercator"});const v=h!==this.projection.name;return v&&this._calcMatrices(),v}get minZoom(){return this._minZoom}set minZoom(h){this._minZoom!==h&&(this._minZoom=h,this.zoom=Math.max(this.zoom,h))}get maxZoom(){return this._maxZoom}set maxZoom(h){this._maxZoom!==h&&(this._maxZoom=h,this.zoom=Math.min(this.zoom,h))}get minPitch(){return this._minPitch}set minPitch(h){this._minPitch!==h&&(this._minPitch=h,this.pitch=Math.max(this.pitch,h))}get maxPitch(){return this._maxPitch}set maxPitch(h){this._maxPitch!==h&&(this._maxPitch=h,this.pitch=Math.min(this.pitch,h))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(h){h===void 0?h=!0:h===null&&(h=!1),this._renderWorldCopies=h}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const h=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(h))}get cameraWorldSize(){const h=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(h))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return i.cf(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.P(this.width,this.height)}get bearing(){return i.bT(this.rotation,-180,180)}set bearing(h){this.rotation=h}get rotation(){return-this.angle/Math.PI*180}set rotation(h){const v=-h*Math.PI/180;this.angle!==v&&(this._unmodified=!1,this.angle=v,this._calcMatrices(),this.rotationMatrix=i.cn(),i.co(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(h){const v=i.aA(h,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==v&&(this._unmodified=!1,this._pitch=v,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(h){h=Math.max(.01,Math.min(60,h)),this._fov!==h&&(this._unmodified=!1,this._fov=i.an(h),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const h=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/h)}get averageElevation(){return this._averageElevation}set averageElevation(h){this._averageElevation=h,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(h){const v=Math.min(Math.max(h,this.minZoom),this.maxZoom);this._zoom!==v&&(this._unmodified=!1,this._setZoom(v),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(h){this._zoom=h,this.scale=this.zoomScale(h),this.tileZoom=Math.floor(h),this.zoomFraction=h-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(h){this._tileCoverLift!==h&&(this._tileCoverLift=h)}_updateCameraOnTerrain(){const h=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,v=this.elevation&&h===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!v||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;v||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,v=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let B=0;B{const Ze=i.cY(be,we,Ne,Re,Ie);ee.has(Ze)||(F.push(new i.aQ(we,be,Ne,Re,Ie)),ee.add(Ze))};for(let we=0;webe.canonical.z)continue;const Ne=be.canonical,Re=be.overscaledZ,Ie=be.wrap,Ze=1<0,ht=Ne.y+10,At=be.wrap-(at?0:1),Nt=be.wrap+(Ve?0:1),Ct=at?Ne.x-1:Ze-1,wt=Ve?Ne.x+1:0;if(B)A[0]<0?(ae(Re,Nt,Ne.z,wt,Ne.y),A[1]<0&&ht&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y+1),ae(Re,Nt,Ne.z,wt,Ne.y+1)),A[1]>0&&ot&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y-1),ae(Re,Nt,Ne.z,wt,Ne.y-1))):A[0]>0?(ae(Re,At,Ne.z,Ct,Ne.y),A[1]<0&&ht&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y+1),ae(Re,At,Ne.z,Ct,Ne.y+1)),A[1]>0&&ot&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y-1),ae(Re,At,Ne.z,Ct,Ne.y-1))):A[1]<0&&ht?ae(Re,Ie,Ne.z,Ne.x,Ne.y+1):ot&&ae(Re,Ie,Ne.z,Ne.x,Ne.y-1);else{const gt=be.visibleQuadrants;1>&&(ae(Re,At,Ne.z,Ct,Ne.y),ot&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y-1),ae(Re,At,Ne.z,Ct,Ne.y-1))),2>&&(ae(Re,Nt,Ne.z,wt,Ne.y),ot&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y-1),ae(Re,Nt,Ne.z,wt,Ne.y-1))),4>&&(ae(Re,At,Ne.z,Ct,Ne.y),ht&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y+1),ae(Re,At,Ne.z,Ct,Ne.y+1))),8>&&(ae(Re,Nt,Ne.z,wt,Ne.y),ht&&(ae(Re,Ie,Ne.z,Ne.x,Ne.y+1),ae(Re,Nt,Ne.z,wt,Ne.y+1)))}}const le=[];for(const we of F)F.some(be=>we.isChildOf(be))||le.push(we);if(F=le.filter(we=>!h.some(be=>!!(we.overscaledZ{const Ve=Ze.canonical.x+.5-Ne[0],at=Ze.canonical.y+.5-Ne[1];return Ve*Ve+at*at{const Ct=i.cY(ht,at,ot,At,Nt);F.has(Ct)||(D.push(new i.aQ(at,ht,ot,At,Nt)),F.add(Ct))},W=h.reduce((at,ht)=>Math.max(at,ht.overscaledZ),A),ee=1<{const ot=Math.floor(at[0]),At=Math.floor(at[1]),Nt=(at[0]-ot)*i.al,Ct=(at[1]-At)*i.al,wt=Math.floor(ht[0]),gt=Math.floor(ht[1]),Dt=(ht[0]-wt)*i.al,Ht=(ht[1]-gt)*i.al;for(let Ut=-1;Ut<=1;Ut++){const es=ot+Ut;if(!(es<0||es>=ee)){le.x=Nt-Ut*i.al,we.x=Dt-(es-wt)*i.al;for(let ts=-1;ts<=1;ts++){const _s=At+ts;le.y=Ct-ts*i.al,we.y=Ht-(_s-gt)*i.al,i.cZ(le,we,ae)&&B(W,0,A,es,_s)}}}},Ne=v.points,Re=Ne[i.cv],Ie=Ne[i.cw],Ze=this._projectToGround(Re,Ne[i.cx]),Ve=this._projectToGround(Ie,Ne[i.cy]);return be(Re,Ze),be(Ie,Ve),D}_projectToGround(h,v){return i.cz(i.cA(),h,v,h[2]/(h[2]-v[2]))}coveringTiles(h){let v=this.coveringZoomLevel(h);const A=v,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,B=this.projection.name==="mercator";if(h.minzoom!==void 0&&vh.maxzoom&&(v=h.maxzoom);const W=this.locationCoordinate(this.center),ee=this.center.lat,ae=1<{const Jt=new i.ae(zt.x+25e-6,zt.y,zt.z),zs=new i.ae(zt.x,zt.y+25e-6,zt.z),ir=zt.toLngLat(),br=Jt.toLngLat(),er=zs.toLngLat(),Zs=this.locationCoordinate(ir),Dr=this.locationCoordinate(br),Pr=this.locationCoordinate(er),pr=Math.hypot(Dr.x-Zs.x,Dr.y-Zs.y),wr=Math.hypot(Pr.x-Zs.x,Pr.y-Zs.y);return Math.sqrt(pr*wr)*Ct/25e-6},gt=zt=>{const is=At,Jt=Nt;return{aabb:i.cF(this,ae,0,0,0,zt,Jt,is,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:is,wrap:zt,fullyVisible:!1}},Dt=[];let Ht=[];const Ut=v,es=h.reparseOverscaled?A:v,ts=(Ze-this._centerAltitude)*Ie,_s=zt=>{if(!this._elevation||!zt.tileID||!B)return;const is=this._elevation.getMinMaxForTile(zt.tileID),Jt=zt.aabb;is?(Jt.min[2]=is.min,Jt.max[2]=is.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(zt.shouldSplit=Yt(zt),zt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},Ks=(zt,is)=>{if(.707*is{if(zt.zoom=.9)return!0}else if(F&&(zs=zt.aabb.distanceZ(Ve)*Ie),this.projection.isReprojectedInTileSpace&&A<=5){const wr=Math.pow(2,zt.zoom),Qr=wt(new i.ae((zt.x+.5)/wr,(zt.y+.5)/wr));ir=Qr>.85?1:Qr}if(!B&&!we){const wr=Math.sqrt(is*is+Jt*Jt+zs*zs);let Qr=(1<0;){const zt=Dt.pop(),is=zt.x,Jt=zt.y;let zs=zt.fullyVisible;const ir=()=>this.projection.name==="globe"&&(zt.y===0||zt.y===(1<>1),Dr={aabb:B?zt.aabb.quadrant(br):i.cF(this,ae,zt.zoom+1,er,Zs,zt.wrap,zt.minZ,zt.maxZ,this.projection),zoom:zt.zoom+1,x:er,y:Zs,wrap:zt.wrap,fullyVisible:zs,tileID:void 0,shouldSplit:void 0,minZ:zt.minZ,maxZ:zt.maxZ};F&&!we&&(Dr.tileID=new i.aQ(zt.zoom+1===Ut?es:zt.zoom+1,zt.wrap,zt.zoom+1,er,Zs),_s(Dr)),Dt.push(Dr)}else{const br=zt.zoom===Ut?es:zt.zoom;if(h.minzoom&&h.minzoom>br)continue;let er=0;if(!zs){let pr=at?zt.aabb.intersectsPrecise(Ne):zt.aabb.intersectsPreciseFlat(Ne);if(pr===0&&ir()){const wr=new i.cD(zt.zoom,is,Jt);pr=i.cE(this,ae,wr,!0).intersectsPrecise(Ne)}if(pr===0)continue;if(h.calculateQuadrantVisibility)if(Ne.containsPoint(zt.aabb.center))er=15;else for(let wr=0;wr<4;wr++)zt.aabb.quadrant(wr).intersects(Ne)!==0&&(er|=1<{const zs=[0,0,0,1],ir=[i.al,i.al,0,1],br=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(zs,zs,br),i.aC(ir,ir,br);const er=i.cG([],zs,ir),Zs=i.cH([],zs,ir),Dr=i.c$(er,Zs);if(Dr===0)return!0;let Pr=!1;const pr=this._elevation;if(pr&&Dr>zt&&is!==0){const wr=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Qr;h.isTerrainDEM||(Qr=pr.getMinMaxForTile(Jt.tileID)),Qr||(Qr={min:Nt,max:At});const On=i.cI(this.rotation),Sa=[On[0]*i.al,On[1]*i.al,Qr.max];i.af(Sa,Sa,wr),Pr=(1-Sa[1])*this.height*.5zt.distanceSq-is.distanceSq).map(zt=>zt.tileID)}resize(h,v){this.width=h,this.height=v,this.pixelsToGLUnits=[2/h,-2/v],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 v=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,v);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,v){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;A=(v.x-F.x)/W,D=(v.y-F.y)/W}else{const W=this.pointCoordinate(v),ee=this.pointCoordinate(F);A=W.x-ee.x,D=W.y-ee.y}const B=this.locationCoordinate(h);this.setLocation(new i.ae(B.x-A,B.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,v){return this.projection.locationPoint(this,h,v)}locationPoint3D(h,v){return this.projection.locationPoint(this,h,v,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,v){return this.coordinateLocation(this.pointCoordinate3D(h,v))}locationCoordinate(h,v){const A=v?i.cf(v,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,v){const A=v??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 B=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/B);const W=D[2],ee=F[2];return{p0:D,p1:F,t:W===ee?0:(A-W)/(ee-W)}}screenPointToMercatorRay(h){const v=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(v,v,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(v,v,1/v[3]),i.cK(A,A,1/A[3]),v[2]=i.cf(v[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(v,v,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([v[0],v[1],v[2]],i.aw([],i.av([],A,v)))}rayIntersectionCoordinate(h){const{p0:v,p1:A,t:D}=h,F=i.cf(v[2],this._center.lat),B=i.cf(A[2],this._center.lat);return new i.ae(i.ak(v[0],A[0],D)/this.worldSize,i.ak(v[1],A[1],D)/this.worldSize,i.ak(F,B,D))}pointCoordinate(h,v=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,v)}pointCoordinate3D(h,v){if(!this.elevation)return this.pointCoordinate(h,v);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,v);const B=.02*F,W=h.clone();for(let ee=0;ee<10&&F-D>B;ee++){W.y=i.ak(D,F,.66);const ae=this.projection.pointCoordinate3D(this,W.x,W.y);ae?(F=W.y,A=ae):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 v=this.pointCoordinate(h);return v.y>=0&&v.y<=1}_coordinatePoint(h,v){const A=v&&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:v}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(v,h)),B=this.pointLocation3D(new i.P(D,h)),W=this.pointLocation3D(new i.P(D,A)),ee=this.pointLocation3D(new i.P(v,A));let ae=Math.min(F.lng,B.lng,W.lng,ee.lng),le=Math.max(F.lng,B.lng,W.lng,ee.lng),we=Math.min(F.lat,B.lat,W.lat,ee.lat),be=Math.max(F.lat,B.lat,W.lat,ee.lat);const Ne=Math.pow(2,-this.zoom)/16*270,Re=this.projection.name==="globe"?1:4,Ie=(Ze,Ve,at,ht,ot)=>{const At=(Ze+at)/2,Nt=(Ve+ht)/2,Ct=new i.P(At,Nt),{lng:wt,lat:gt}=this.pointLocation3D(Ct),Dt=Math.max(0,ae-wt,we-gt,wt-le,gt-be);ae=Math.min(ae,wt),le=Math.max(le,wt),we=Math.min(we,gt),be=Math.max(be,gt),(otNe)&&(Ie(Ze,Ve,At,Nt,ot+1),Ie(At,Nt,at,ht,ot+1))};if(Ie(v,h,D,h,1),Ie(D,h,D,A,1),Ie(D,A,v,A,1),Ie(v,A,v,h,1),this.projection.name==="globe"){const[Ze,Ve]=i.cM(this);Ze?(be=90,le=180,ae=-180):Ve&&(we=-90,le=180,ae=-180)}return new i.aI(new i.aT(ae,we),new i.aT(le,be))}_getBoundsRectangular(h,v){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,B=this.width-this._edgeInsets.right,W=new i.P(D,A),ee=new i.P(B,A),ae=new i.P(B,F),le=new i.P(D,F);let we=this.pointCoordinate(W,h),be=this.pointCoordinate(ee,h);const Ne=this.pointCoordinate(ae,v),Re=this.pointCoordinate(le,v),Ie=(Ze,Ve)=>(Ve.y-Ze.y)/(Ve.x-Ze.x);return we.y>1&&be.y>=0?we=new i.ae((1-Re.y)/Ie(Re,we)+Re.x,1):we.y<0&&be.y<=1&&(we=new i.ae(-Re.y/Ie(Re,we)+Re.x,0)),be.y>1&&we.y>=0?be=new i.ae((1-Ne.y)/Ie(Ne,be)+Ne.x,1):be.y<0&&we.y<=1&&(be=new i.ae(-Ne.y/Ie(Ne,be)+Ne.x,0)),new i.aI().extend(this.coordinateLocation(we)).extend(this.coordinateLocation(be)).extend(this.coordinateLocation(Re)).extend(this.coordinateLocation(Ne))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const v=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(v.min*h.exaggeration(),v.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 v=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-v*(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.maxLngwe&&(W=we-ae),we-leNe&&(B=Ne-ee),Ne-be{for(let Yt=0;Yt<16;Yt++)es[Yt]=i.ak(ts[Yt],_s[Yt],Ks)})(W,W,ee,i.d0(this.pitch>=$p?1:this.pitch/$p))}else W=ee;const ae=i.cP([],ee,B);let le=i.cP([],W,B);if(this.projection.isReprojectedInTileSpace){const gt=this.locationCoordinate(this.center),Dt=i.bA([]);i.br(Dt,Dt,[gt.x*this.worldSize,gt.y*this.worldSize,0]),i.aB(Dt,Dt,i.cQ(this)),i.br(Dt,Dt,[-gt.x*this.worldSize,-gt.y*this.worldSize,0]),i.aB(le,le,Dt),i.aB(ae,ae,Dt),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),v){const gt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);gt[8]=2*-h.x/this.width,gt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],gt,B)}else this.expandedFarZProjMatrix=this.projMatrix;const we=i.bl([],W);this.frustumCorners=i.cT.fromInvProjectionMatrix(we,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!v);const be=new Float32Array(16);i.bA(be),i.cS(be,be,[1,-1,1]),i.cU(be,be,this._pitch),i.bB(be,be,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 Re=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ne[8]=2*-h.x/this.width,Ne[9]=2*(h.y+Re)/this.height,this.skyboxMatrix=i.aB(be,Ne,be);const Ie=this.point,Ze=Ie.x,Ve=Ie.y,at=this.width%2/2,ht=this.height%2/2,ot=Math.cos(this.angle),At=Math.sin(this.angle),Nt=Ze-Math.round(Ze)+ot*at+At*ht,Ct=Ve-Math.round(Ve)+ot*ht+At*at,wt=new Float64Array(le);if(i.br(wt,wt,[Nt>.5?Nt-1:Nt,Ct>.5?Ct-1:Ct,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,ae),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 gt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(gt,gt,B),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,v=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,v];i.c5(F,F,D),i.c5(A,A,-1),i.cW(A,A,F);const B=i.bC();i.br(B,B,A),i.cS(B,B,F),this.mercatorFogMatrix=B,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,v,D)}_computeCameraPosition(h){const v=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*v-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 v=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((v-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,v=this._camera.forward(),{pitch:A,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,B=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),W=Math.max((h[2]-F)/Math.cos(A),B),ee=this._zoomFromMercatorZ(W);i.bH(h,h,v,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(ee,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 v=0,A=i.cL,D=0,F=1/0;for(;A-v>1e-6&&A>v;){const B=v+.5*(A-v),W=this.tileSize*Math.pow(2,B),ee=this.getCameraToCenterDistance(this.projection,B,W),ae=this.scaleZoom(ee/(Math.max(0,h)*this.tileSize)),le=Math.abs(B-ae);leae||be.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,v){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+v;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([v,A,D],F){const B=[v,A,D,1];i.aC(B,B,F);const W=B[3]=Math.max(B[3],1e-6);return B[0]/=W,B[1]/=W,B[2]/=W,B}([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,v=this.zoom,A=this.worldSize){const D=i.cO(h,v,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,A,D);let B=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(B=i.ak(1,B,i.d0(this.pitch>=$p?1:this.pitch/$p))),B}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 ky=(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 v=T.transform,A=Math.max(Math.abs(v._zoom-(T.minCutoffZoom-1)),1),D=v.isLODDisabled(!1)?i.ah(60,45,v.pitch):i.ah(30,15,v.pitch),F=v._farZ-v._nearZ,B=h*v.height,W=((1-(ee=D))*v.cameraToCenterDistance+ee*(v._farZ+B))*A;var ee;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[v._nearZ,v._farZ,(W-v._nearZ)/F,(W-B-v._nearZ)/F]}}},tp=2048;class n2{constructor(h,v){this.aabb=h,this.lastCascade=v}}class Bme{add(h,v){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],v.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],v.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],v.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],v.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],v.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],v.max[2])):this.receivers[h.key]=new n2(v,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,v,A){const D=i.d9.fromPoints(h.points);let F=0;for(const B in this.receivers){const W=this.receivers[B];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const ee=W.aabb.getCorners();for(let ae=0;ae1||be[1]<-1||be[1]>1){le=!1;break}}if(W.lastCascade=ae,F=Math.max(F,ae),le)break}}return F+1}}class ob{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Bme,this._depthMode=new Br(h.context.gl.LEQUAL,Br.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,v){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!v||!v.properties)return;const D=v.properties.get("shadow-intensity");if(!v.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((Re,Ie)=>{const Ze=A.style._mergedLayers[Ie];return Re+(Ze.hasShadowPass()&&!Ze.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,B=tp,W=tp;if(this._cascades.length===0||tp!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Re=0;Re<2;++Re){const Ie=A._shadowMapDebug,Ze=F.gl,Ve=F.createFramebuffer(B,W,Ie?1:0,"texture"),at=new i.T(F,{width:B,height:W,data:null},Ze.DEPTH_COMPONENT16);if(Ve.depthAttachment.set(at.texture),Ie){const ht=new i.T(F,{width:B,height:W,data:null},Ze.RGBA8);Ve.colorAttachment0.set(ht.texture)}this._cascades.push({framebuffer:Ve,texture:at,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=i2(v);let ee=0;if(h.elevation){const Re=h.elevation,Ie=[1e4,-1e4];Re.visibleDemTiles.filter(Ze=>Ze.dem).forEach(Ze=>{const Ve=Ze.dem.tree;Ie[0]=Math.min(Ie[0],Ve.minimums[0]),Ie[1]=Math.max(Ie[1],Ve.maximums[0])}),Ie[0]!==1e4&&(ee=(Ie[1]-Ie[0])*Re.exaggeration())}const ae=1.5*h.cameraToCenterDistance,le=3*ae,we=new Float64Array(16);for(let Re=0;Re=0)return{};const F=function(ee,ae,le){const we=le/(1<0&&(i.d8(F[1],F[1],[D[0]*B,0,0]),i.d8(F[2],F[2],[D[0]*B,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*B,0]),i.d8(F[1],F[1],[0,D[1]*B,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*B,0]),i.d8(F[3],F[3],[0,D[1]*B,0]));const W={};return W.vertices=F,W.planes=[a2(F[1],F[0],F[4]),a2(F[2],F[1],F[5]),a2(F[3],F[2],F[6]),a2(F[0],F[3],F[7])],W}addShadowReceiver(h,v,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,v,A))}getMaxCascadeForTile(h){const v=this._receivers.get(h);return v&&v.lastCascade?v.lastCascade:0}}function a2(T,h,v){const A=i.av([],v,h),D=i.av([],T,h),F=i.bI([],A,D),B=i.ag(F);return B===0?[0,0,1,0]:(i.c5(F,F,1/B),[F[0],F[1],F[2],-i.bJ(F,h)])}function i2(T){const h=T.properties.get("direction"),v=i.d4(h.x,h.y,h.z);v[2]=i.aA(v[2],0,75);const A=i.d6([v[0],v[1],v[2]]);return i.d5(A.x,A.y,A.z)}function ag(T,h,v){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),B=h.properties.get("direction"),W=[B.x,B.y,B.z],ee=v.properties.get("color-use-theme")==="none",ae=v.properties.get("color"),le=v.properties.get("intensity"),we=Math.max(i.bJ([0,0,1],W),0),be=[0,0,0];i.c5(be,ae.toPremultipliedRenderColor(ee?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(v.scope)).toArray01Linear().slice(0,3),we*F),i.db([be[0]>0?be[0]/(be[0]+Ne[0]):0,be[1]>0?be[1]/(be[1]+Ne[1]):0,be[2]>0?be[2]/(be[2]+Ne[2]):0])}function Sy(T,h,v,A,D,F){const B=T.zoom,W=T.scale,ee=T.worldSize,ae=1/ee,le=T.aspect,we=Math.sqrt(1+le*le)*Math.tan(.5*T.fovX),be=we*we,Ne=A-v,Re=A+v;let Ie,Ze;be>Ne/Re?(Ie=A,Ze=A*we):(Ie=.5*Re*(1+be),Ze=.5*Math.sqrt(Ne*Ne+2*(A*A+v*v)*be+Re*Re*be*be));const Ve=T.projection.pixelsPerMeter(T.center.lat,ee),at=T._camera.getCameraToWorldMercator(),ht=[0,0,-Ie*ae];i.af(ht,ht,at);let ot=Ze*ae;const At=T._edgeInsets;if(!(At.left===0&&At.top===0&&At.right===0&&At.bottom===0||At.left===At.right&&At.top===At.bottom)){const zs=T._camera.getWorldToCamera(T.worldSize,T.projection.zAxisUnit==="meters"?Ve:1),ir=T._camera.getCameraToClipPerspective(T._fov,T.width/T.height,v,A);ir[8]=2*-T.centerOffset.x/T.width,ir[9]=2*T.centerOffset.y/T.height;const br=new Float64Array(16);i.cP(br,ir,zs);const er=new Float64Array(16);i.bl(er,br);const Zs=i.cB.fromInvProjectionMatrix(er,ee,B,!0);for(const Dr of Zs.points){const Pr=((Nt=Dr)[0]/=W,Nt[1]/=W,Nt[2]=i.cf(Nt[2],T._center.lat),Nt);ot=Math.max(ot,i.c6(i.da([],ht,Pr)))}}var Nt;ot*=D/(D-1);const Ct=Math.acos(h[2]),wt=Math.atan2(-h[0],-h[1]),gt=new eC;gt.position=ht,gt.setPitchBearing(Ct,wt);const Dt=gt.getWorldToCamera(ee,Ve),Ht=ot*ee,Ut=Math.min(T._mercatorZfromZoom(17)*ee*-2,-2*Ht),es=gt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Ut,(Ht+F*Ve)/h[2]),ts=new Float64Array(16);i.aB(ts,es,Dt);const _s=i.d5(Math.floor(1e6*ht[0])/1e6*ee,Math.floor(1e6*ht[1])/1e6*ee,0),Ks=.5*D,Yt=[0,0,0];i.af(Yt,_s,ts),i.c5(Yt,Yt,Ks);const zt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],is=[0,0,0];i.av(is,Yt,zt),i.c5(is,is,-1/Ks);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,is),i.aB(ts,Jt,ts),[ts,Ht]}class $me extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,v){return i.dc(this.requestManager.transformRequest(v,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,v,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 ${v}: ${A.message}`)))})}load(h,v,A={forceReload:!1}){this.models[v]||(this.models[v]={});const D=Object.keys(h),F=[],B=[];for(const W of D){const ee=h[W];this.hasURLBeenRequested(ee)&&!A.forceReload||(this.modelByURL[ee]={modelId:W,scope:v},F.push(this.loadModel(W,ee)),B.push(W)),this.models[v][W]||(this.models[v][W]={model:null,numReferences:1})}this.numModelsLoading[v]=(this.numModelsLoading[v]||0)+B.length,Promise.allSettled(F).then(W=>{for(let ee=0;ee{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,v,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,v):this.getModelByURL(this.modelUris[v][h]))}getModel(h,v){return this.models[v]||(this.models[v]={}),this.models[v][h]?this.models[v][h].model:void 0}getModelByURL(h){if(!h)return null;const v=this.modelByURL[h];return v?this.models[v.scope][v.modelId].model:null}hasModelBeenAdded(h,v){return this.models[v]&&this.models[v][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,v,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(v);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:B}=this.modelByURL[D];this.models[F][B].numReferences++}else this.modelUris[A][h]=D,this.load({[h]:this.modelUris[A][h]},A)}addModelURLs(h,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const A=this.modelUris[v];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const A={};for(const D of h)this.hasModel(D,v,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[v][D].numReferences++:this.modelUris[v][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[v][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[v][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[v][D]);this.load(A,v)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,v,A=!1,D=!1){if(this.models[v]&&this.models[v][h]&&(this.models[v][h].numReferences--,this.models[v][h].numReferences===0||D)){const F=this.modelUris[v][h];A||delete this.modelUris[v][h],delete this.modelByURL[F];const B=this.models[v][h].model;if(!B)return;delete this.models[v][h],B.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const v of Object.keys(this.models[h])){const A=this.models[h][v].model;delete this.models[h][v],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,v){this.models[v]||(this.models[v]={});for(const A in this.models[v])this.models[v][A].model&&this.models[v][A].model.upload(h.context)}}const c6=i.a6.colorTheme,qme=new i.a9({data:new i.aa(c6.data)});function HR(T){if(!T.metadata||!T.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:v,top:A,width:D,height:F}=T.metadata.content_area,B=v*h,W=A*h;return[B,W,B+D*h,W+F*h]}function GR(T){if(T)return T.map(([h,v])=>[h*i.o.devicePixelRatio,v*i.o.devicePixelRatio])}class d6{constructor(h,v,A){this.id=h,this.scope=v,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 v=this.sourceCache.getVisibleCoordinates();if(v.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof Md))return h;const D=v.map(B=>this.sourceCache.getTile(B)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[B,W]of F)h.set(i.I.from({name:B,iconsetId:this.id}),W),this.pendingRequests.delete(B);for(const B of this.pendingRequests)this.missingRequests.add(B);return this.pendingRequests.clear(),h}}const Cy=(T,h)=>st(T,h&&h.filter(v=>v.identifier!=="source.canvas")),WR=i.aH(Ba,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),KR=i.aH(Ba,["setCenter","setZoom","setBearing","setPitch"]),sC=new Set(["background","sky","slot","custom"]),My={version:8,layers:[],sources:{}},o2={duration:300,delay:0};class sp extends i.E{constructor(h,v={}){super(),this.map=h,this.scope=v.scope||"",this.globalId=null,this.fragments=[],this.importDepth=v.importDepth||0,this.importsCache=v.importsCache||new Map,this.resolvedImports=v.resolvedImports||new Set,this.transition=Object.assign({},o2),this._buildingIndex=new Qw(this),this.crossTileSymbolIndex=new Bp,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=v.styleChanges||new Ce,this._hasDataDrivenEmissive=!1,this.dispatcher=v.dispatcher?v.dispatcher:new i.D(i.dh(),this),v.imageManager?this.imageManager=v.imageManager:(this.imageManager=new Ge(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=v.glyphManager?v.glyphManager:new i.di(h._requestManager,v.localFontFamily?i.dj.all:v.localIdeographFontFamily?i.dj.ideographs:i.dj.none,v.localFontFamily||v.localIdeographFontFamily),v.modelManager?this.modelManager=v.modelManager:(this.modelManager=new $me(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=v.configOptions?v.configOptions:new Map,this._configDependentLayers=v.configDependentLayers?v.configDependentLayers:new Set,this._indoorDependentLayers=v.indoorDependentLayers?v.indoorDependentLayers:new Set,this._config=v.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:v.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=v.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=sp.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,B)=>{if(i.dl(F),B&&B.every(W=>W))for(const W in A._sourceCaches){const ee=A._sourceCaches[W],ae=ee.getSource().type;ae!=="vector"&&ae!=="geojson"||ee.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 B in this._layers){const W=this._layers[B];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 v=i.dm(h);if(!v.startsWith("http"))try{return new URL(v,location.href).toString()}catch{return v}return v}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,v,A){this.globalId=this._getGlobalId(h);const D=(F,B)=>{try{B(null,this.setState(F,A))}catch(W){B(W,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),B=this.map._requestManager.transformRequest(F,i.R.Style);i.m(B,(W,ee)=>{W?this.fire(new i.y(W)):ee&&D(ee,v)})}else typeof h=="object"&&D(h,v)}loadURL(h,v={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof v.validate=="boolean"?v.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,v.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,(B,W)=>{if(this._request=null,B)this.fire(new i.y(B));else if(W)return this.importsCache.set(h,W),this._load(W,A)})}loadJSON(h,v={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,v.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(My,!1)}_loadImports(h,v,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 B=this._createFragmentStyle(F),W=new Promise(le=>{B.once("style.import.load",le),B.once("error",le)}).then(()=>this.mergeAll());if(D.push(W),this.resolvedImports.has(F.url)){B.loadEmpty();continue}const ee=F.data||this.importsCache.get(F.url);ee?(B.loadJSON(ee,{validate:v}),this._isInternalStyle(ee)&&(B.globalId=null)):F.url?B.loadURL(F.url,{validate:v}):B.loadEmpty();const ae={style:B,id:F.id,config:F.config};if(A){const le=this.fragments.findIndex(({id:we})=>we===A);this.fragments=this.fragments.slice(0,le).concat(ae).concat(this.fragments.slice(le))}else this.fragments.push(ae)}return Promise.allSettled(D)}getImportGlobalIds(h=this,v=new Set){for(const A of h.fragments)A.style.globalId&&v.add(A.style.globalId),this.getImportGlobalIds(A.style,v);return[...v.values()]}_createFragmentStyle(h){const v=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[v];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new sp(this.map,{scope:v,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,v){if(this._isInternalStyle(h)){const F=Object.assign({},My,{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,v)}if(this.updateConfig(this._config,h.schema),v&&Cy(this,Yr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const ee in h.sources)this.addSource(ee,h.sources[ee],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const ee in h.iconsets)this.addIconset(ee,h.iconsets[ee]);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=rv(this.stylesheet.layers);if(this._order=F.map(ee=>ee.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 ee=this.stylesheet.lights[0];this.light=new Ot(ee.properties,ee.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ot(this.stylesheet.light)),this._layers={};for(const ee of F){const ae=i.du(ee,this.scope,this._styleColorTheme.lut,this.options);ae.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ae.fqid),ae.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ae.fqid),this._hasAppearances=this._hasAppearances||ae.getAppearances().length!==0,ae.setEventedParent(this,{layer:{id:ae.id}}),this._layers[ae.id]=ae;const le=this.getOwnLayerSourceCache(ae),we=!!this.directionalLight&&this.directionalLight.shadowsEnabled();le&&ae.canCastShadows()&&we&&(le.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const B=this.stylesheet.terrain;B&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(B,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,v).then(()=>{this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load"))}).catch(ee=>{this.fire(new i.y(new Error("Failed to load imports",ee))),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(B=>{i.w(`Couldn't load color theme from the stylesheet: ${B}`),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,v,A,D,F,B,W,ee,ae,le;const we={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(be=>{if(be.stylesheet){if(be.light!=null&&(h=be.light),be.stylesheet.lights)for(const Ne of be.stylesheet.lights)Ne.type==="ambient"&&be.ambientLight!=null&&(v=be.ambientLight),Ne.type==="directional"&&be.directionalLight!=null&&(A=be.directionalLight);D=this._prioritizeTerrain(D,be.terrain,be.stylesheet.terrain),be.stylesheet.fog&&be.fog!=null&&(F=be.fog),be.stylesheet.snow&&be.snow!=null&&(B=be.snow),be.stylesheet.rain&&be.rain!=null&&(W=be.rain),be.stylesheet.camera!=null&&(le=be.stylesheet.camera),be.stylesheet.projection!=null&&(ee=be.stylesheet.projection),be.stylesheet.transition!=null&&(ae=be.stylesheet.transition),we[be.scope]=be._styleColorTheme}}),this.light=h,this.ambientLight=v,this.directionalLight=A,this.fog=F,this.snow=B,this.rain=W,this._styleColorThemeForScope=we,D===null?delete this.terrain:this.terrain=D,this.camera=le||{"camera-projection":"perspective"},this.projection=ee||{name:"mercator"},this.transition=Object.assign({},o2,ae),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const v=A=>{for(const D of A.fragments)v(D.style);h(A)};v(this)}_prioritizeTerrain(h,v,A){const D=h&&h.drapeRenderMode===0;return A===null?v&&v.drapeRenderMode===0?v:D?h:null:v!=null&&(!h||D||v&&v.drapeRenderMode===1)?v:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(v=>{h=this._prioritizeTerrain(h,v.terrain,v.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(v=>{v.stylesheet.projection!=null&&(h=v.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},v={},A={};this.forEachFragmentStyle(D=>{for(const F in D._sourceCaches){const B=i.B(F,D.scope);h[B]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const B=i.B(F,D.scope);v[B]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const B=i.B(F,D.scope);A[B]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=v,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const v of Object.values(h.stylesheet.indoor)){const A=v,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},v=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(B=>{for(const W of B._order){const ee=B._layers[W];if(ee.type==="slot"){const ae=i.dq(W);if(h[ae])continue;h[ae]=[]}ee.slot&&h[ee.slot]?h[ee.slot].push(ee):v.push(ee)}}),this._mergedOrder=[];let D=-1;const F=(B=[])=>{for(const W of B)if(W.type==="slot"){const ee=i.dq(W.id);h[ee]&&F(h[ee]),this._mergedSlots.push(ee)}else{const ee=i.B(W.id,W.scope);this._mergedOrder.push(ee),A[ee]=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(v),this._has3DLayers){const B={};for(let W=0;WB[W]-B[ee])}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(v,A,D,F){const B=Object.assign({},A);for(const ee of Object.keys(c6))B[ee]===void 0&&(B[ee]=c6[ee].default);const W=new i.a8(qme,v,new Map(D));return W.setTransitionOrValue(B,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 v=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 B=h;B.startsWith(F)||(B=F+B);const W=i.I.from("mapbox-reserved-lut"),ee=new Image;ee.src=B,ee.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},ee.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==v)return void A();this._styleColorTheme.lutLoading=!1;const{width:ae,height:le,data:we}=i.o.getImageData(ee);if(le>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ae!==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:ae,height:le},we),pixelRatio:1,sdf:!1,usvg:!1,version:0});const be=this.imageManager.getImage(W,this.scope);be?(this._styleColorTheme.lut={image:be.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const v=this._styleColorThemeForScope[h];return v?v.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(v,A,D){let F,B,W;const ee=i.o.devicePixelRatio>1?"@2x":"";let ae=i.m(A.transformRequest(A.normalizeSpriteURL(v,ee,".json"),i.R.SpriteJSON),(be,Ne)=>{ae=null,W||(W=be,F=Ne,we())}),le=i.n(A.transformRequest(A.normalizeSpriteURL(v,ee,".png"),i.R.SpriteImage),(be,Ne)=>{le=null,W||(W=be,B=Ne,we())});function we(){if(W)D(W);else if(F&&B){const be=i.o.getImageData(B),Ne={};for(const Re in F){const{width:Ie,height:Ze,x:Ve,y:at,sdf:ht,pixelRatio:ot,stretchX:At,stretchY:Nt,content:Ct}=F[Re],wt=new i.q({width:Ie,height:Ze});i.q.copy(be,wt,{x:Ve,y:at},{x:0,y:0},{width:Ie,height:Ze},null),Ne[Re]={data:wt,pixelRatio:ot!==void 0?ot:1,sdf:ht!==void 0&&ht,stretchX:At,stretchY:Nt,content:Ct,usvg:!1,version:0}}D(null,Ne)}}return{cancel(){ae&&(ae.cancel(),ae=null),le&&(le.cancel(),le=null)}}}(h,this.map._requestManager,(v,A)=>{if(this._spriteRequest=null,v)this.fire(new i.y(v));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,v){if(v.type==="sprite")return void this._loadSprite(v.url);const A=this.getOwnSourceCache(v.source);if(!A)return void this.fire(new i.y(new Error(`Source "${v.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 "${v.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 d6(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 v=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,B)=>{if(this._spriteRequest=null,F)v?this._loadSprite(h):this.fire(new i.y(F));else if(B){const W=new Map;for(const ee in B)W.set(i.I.from(ee),B[ee]);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,B)=>{if(F)return void D(F);const W={},ee=i.dg(new i.bt(B));for(const ae of ee.icons){const le={version:1,pixelRatio:i.o.devicePixelRatio,content:HR(ae),stretchX:ae.metadata?GR(ae.metadata.stretch_x_areas):void 0,stretchY:ae.metadata?GR(ae.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ae};W[ae.name]=le}D(null,W)}))}_validateLayer(h){const v=this.getOwnSource(h.source);if(!v)return;const A=h.sourceLayer;A&&(v.type==="geojson"||v.vectorLayerIds&&v.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${v.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,v)=>{const A=this.fragments[v];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const v in this._sourceCaches){const A=this._sourceCaches[v].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const v=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&v.push(D.serialize())}return v}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 v=this._mergedLayers[h];if(v._transitionablePaint&&v._transitionablePaint._values){const A=v._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 v=this.getOwnLayer(h);if(v)return v;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const v=this.getOwnSource(h);if(v)return v;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,v){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 B of F){const W=h.getDefaultProgramParams(B,v.zoom,this._styleColorTheme.lut);W&&(A.style=this,this.fog&&(A._fogVisible=!0,W.overrideFog=!0,A.getOrCreateProgram(B,W)),A._fogVisible=!1,W.overrideFog=!1,A.getOrCreateProgram(B,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,A.getOrCreateProgram(B,W)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const v=this.calculateLightsBrightness();h.brightness=v||0,v!==this._brightness&&(this._brightness=v,this.dispatcher.broadcast("setBrightness",v)),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 ee in W){const{updatedIds:ae,removedIds:le}=W[ee];(ae||le)&&(this._updateWorkerLayers(ee,ae,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 ee=this._mergedSourceCaches[W];F[W]=ee.used,ee.used=!1,ee.tileCoverLift=0}for(const W of this._mergedOrder){const ee=this._mergedLayers[W];if(ee.visibility!=="none"&&ee.recalculate(h,this._availableImages),!ee.isHidden(h.zoom)){const ae=this.getLayerSourceCache(ee);ae&&(ae.used=!0,ae.tileCoverLift=Math.max(ae.tileCoverLift,ee.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(ee,h)}):this.precompilePrograms(ee,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const B=this.imageManager.getPendingImageProviders();for(const W of B)W.sourceCache.used=!0;for(const W in F){const ee=this._mergedSourceCaches[W];F[W]!==ee.used&&ee.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:ee.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 v of h){const A=v.resolvePendingRequests(),D=this.getFragmentStyle(v.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const v in this._mergedSourceCaches){const A=this._mergedSourceCaches[v].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[v].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const v in h)this._changes.resetUpdatedImages(v)}_updateWorkerLayers(h,v,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:v?D._serializeLayers(v):[],scope:h,removedIds:A||[],options:D.options})}setState(h,v){if(this._checkLoaded(),Cy(this,Yr(h)))return!1;(h=i.dp(h)).layers=rv(h.layers);const A=function(B,W){if(!B)return[{command:Ba.setStyle,args:[W]}];let ee=[];try{if(!i.by(B.version,W.version))return[{command:Ba.setStyle,args:[W]}];if(i.by(B.center,W.center)||ee.push({command:Ba.setCenter,args:[W.center]}),i.by(B.zoom,W.zoom)||ee.push({command:Ba.setZoom,args:[W.zoom]}),i.by(B.bearing,W.bearing)||ee.push({command:Ba.setBearing,args:[W.bearing]}),i.by(B.pitch,W.pitch)||ee.push({command:Ba.setPitch,args:[W.pitch]}),i.by(B.sprite,W.sprite)||ee.push({command:Ba.setSprite,args:[W.sprite]}),i.by(B.glyphs,W.glyphs)||ee.push({command:Ba.setGlyphs,args:[W.glyphs]}),i.by(B.imports,W.imports)||function(Ne=[],Re=[],Ie){Re=Re||[];const Ze=(Ne=Ne||[]).map(nv),Ve=Re.map(nv),at=Ne.reduce(av,{}),ht=Re.reduce(av,{}),ot=Ze.slice();let At,Nt,Ct,wt;for(At=0,Nt=0;At{Ne.source&&ae[Ne.source]?ee.push({command:Ba.removeLayer,args:[Ne.id]}):we.push(Ne)});let be=B.terrain;be&&ae[be.source]&&(ee.push({command:Ba.setTerrain,args:[void 0]}),be=void 0),ee=ee.concat(le),i.by(be,W.terrain)||ee.push({command:Ba.setTerrain,args:[W.terrain]}),function(Ne,Re,Ie){Re=Re||[];const Ze=(Ne=Ne||[]).map(nv),Ve=Re.map(nv),at=Ne.reduce(av,{}),ht=Re.reduce(av,{}),ot=Ze.slice(),At=Object.create(null);let Nt,Ct,wt,gt,Dt,Ht,Ut;for(Nt=0,Ct=0;Nt!(B.command in KR));if(A.length===0)return!1;const D=A.filter(B=>!(B.command in WR));if(D.length>0)throw new Error(`Unimplemented: ${D.map(B=>B.command).join(", ")}.`);const F=[];return A.forEach(B=>{F.push(this[B.command](...B.args))}),v&&Promise.all(F).then(v).catch(v),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[v,A]of h.entries()){if(this.getImage(v))return this.fire(new i.y(new Error(`An image with the name "${v.name}" already exists.`)));this.imageManager.addImage(v,this.scope,A),this._changes.updateImage(v,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,v){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,v),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,v,A=!1){this.imageManager.updateImage(h,this.scope,v),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,v,A={}){return this._checkLoaded(),this._validate(je,`models.${h}`,v,null,A)||(this.modelManager.addModel(h,v,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,v,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!v.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(v).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(v.type)>=0&&this._validate(ui,`sources.${h}`,v,null,A))return;this.map&&this.map._collectResourceTiming&&(v.collectResourceTiming=!0);const D=Hl(h,v,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=B=>{const W=(B?"symbol:":"other:")+D.id,ee=i.B(W,this.scope),ae=this._sourceCaches[W]=new Il(ee,D,B);(B?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ae,ae.onAdd(this.map)};F(!1),v.type!=="vector"&&v.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const v=this.getOwnSource(h);if(!v)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,B])=>B.type==="source"&&B.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(),v.setEventedParent(null),v.onRemove&&v.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,v){this._checkLoaded(),this.getOwnSource(h).setData(v),this._changes.setDirty()}getOwnSource(h){const v=this.getOwnSourceCache(h);return v&&v.getSource()}getOwnSources(){const h=[];for(const v in this._otherSourceCaches){const A=this.getOwnSourceCache(v);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const v in h){const A=h[v]._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 v=this._getTransitionParameters();for(const F of h){if(this._validate(Wt,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const B=this.ambientLight;B.set(F),B.updateTransitions(v)}else this.ambientLight=new za(F,cl||(cl=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 B=this.directionalLight;B.set(F),B.updateTransitions(v)}else this.directionalLight=new za(F,ii||(ii=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(v,{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,v=this.ambientLight;if(!h||!v)return;const A=be=>.2126*(be[0]<=.03928?be[0]/12.92:Math.pow((be[0]+.055)/1.055,2.4))+.7152*(be[1]<=.03928?be[1]/12.92:Math.pow((be[1]+.055)/1.055,2.4))+.0722*(be[2]<=.03928?be[2]/12.92:Math.pow((be[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),B=h.properties.get("direction"),W=1-i.d4(B.x,B.y,B.z)[2]/90,ee=A(D)*F*W,ae=v.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),le=v.properties.get("intensity"),we=A(ae)*le;return Number(((ee+we)/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 v=i.ds(h),A=this.fragments.find(({id:F})=>F===v);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const v=this.fragments.find(({id:A})=>A===h);return v?v.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const v={},A=(D,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const B of h[D].selectors){if(B.featureNamespace){const ee=this.getOwnLayer(B.layer);if(!ee){i.w(`Layer is undefined for selector: ${B.layer}`);continue}const ae=A(ee.source,ee.sourceLayer);if(ae in v&&v[ae]!==B.featureNamespace){i.w(`"featureNamespace ${B.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}v[ae]=B.featureNamespace}let W;if(B.properties)for(const ee in B.properties){const ae=i.U(B.properties[ee]);ae.result==="success"&&(W=W||{},W[ee]=ae.value)}F.push({layerId:B.layer,namespace:B.featureNamespace,properties:W,uniqueFeatureID:B._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const v=this.getFragmentStyle(h);if(!v||!v.stylesheet.featuresets)return[];const A=[];for(const D in v.stylesheet.featuresets)A.push({featuresetId:D,importId:v.scope?v.scope:void 0});return A}getFeaturesetLayers(h,v){const A=this.getFragmentStyle(v),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 B of D[h].selectors){const W=A.getOwnLayer(B.layer);W&&F.push(W)}return F}getConfigProperty(h,v){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(v,A.scope),F=A.options.get(D),B=F?F.value||F.default:null;return B?B.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,v){const A=i.B(h,v);return this._mergedIndoor[A]}setIndoorData(h,v){this.map.indoor.setIndoorData(v)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,v,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[v])return;const B=i.U(A);if(B.result!=="success")return void Cy(this,B.value);const W=B.value.expression,ee=i.B(v,D.scope),ae=D.options.get(ee);if(!ae)return;let le;const{minValue:we,maxValue:be,stepValue:Ne,type:Re,values:Ie}=F[v],Ze=i.U(F[v].default);Ze.result==="success"&&(le=Ze.value.expression),le?(this.options.set(ee,Object.assign({},ae,{value:W,default:le,minValue:we,maxValue:be,stepValue:Ne,type:Re,values:Ie})),this.updateConfigDependencies(v)):this.fire(new i.y(new Error(`No schema defined for the config option "${v}" in the "${h}" fragment.`)))}getConfig(h){const v=this.getFragmentStyle(h);if(!v)return null;const A=v.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const B=i.B(F,v.scope),W=v.options.get(B),ee=W?W.value||W.default:null;D[F]=ee?ee.serialize():null}return D}setConfig(h,v){const A=this.getFragmentStyle(h);A&&(A.updateConfig(v,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const v=this.getFragmentStyle(h);return v?v.stylesheet.schema:null}setSchema(h,v){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=v,A.updateConfig(A._config,v),this.updateConfigDependencies())}updateConfig(h,v){if(this._config=h,h||v)if(v)for(const A in v){let D,F;const B=i.U(v[A].default);if(B.result==="success"&&(D=B.value.expression),h&&h[A]!==void 0){const be=i.U(h[A]);be.result==="success"&&(F=be.value.expression)}const{minValue:W,maxValue:ee,stepValue:ae,type:le,values:we}=v[A];if(D){const be=i.B(A,this.scope);this.options.set(be,{default:D,value:F,minValue:W,maxValue:ee,stepValue:ae,type:le,values:we})}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,v=()=>!0){for(const A of h){const D=this.getLayer(A);D&&v(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,v=>!h||v.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(v=>{const A=v._styleColorTheme.colorThemeOverride?v._styleColorTheme.colorThemeOverride:v._styleColorTheme.colorTheme;if(A){const D=v._evaluateColorThemeData(A);(!v._styleColorTheme.lut&&D!==""||v._styleColorTheme.lut&&D!==v._styleColorTheme.lut.data)&&v.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,v,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(Cy(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(ai,`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 B=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(B),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(B);let W=this._order.length;if(v){const we=this._order.indexOf(v);if(we===-1)return void this.fire(new i.y(new Error(`Layer with id "${v}" does not exist on this map.`)));F.slot===this._layers[v].slot?W=we:i.w(`Layer with id "${v}" 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 ee=this.getOwnLayerSourceCache(F),ae=!!this.directionalLight&&this.directionalLight.shadowsEnabled();ee&&F.canCastShadows()&&ae&&(ee.castsShadows=!0);const le=this._changes.getRemovedLayer(F);if(le&&F.source&&ee&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const we=i.B(F.source,F.scope);le.type!==F.type?this._changes.updateSourceCache(we,"clear"):(this._changes.updateSourceCache(we,"reload"),ee.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,v){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===v)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(v){const B=this._order.indexOf(v);if(B===-1)return void this.fire(new i.y(new Error(`Layer with id "${v}" does not exist on this map.`)));A.slot===this._layers[v].slot?F=B:i.w(`Layer with id "${v}" 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 v=this._checkLayer(h);if(!v)return;v.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(v.fqid),this._indoorDependentLayers.delete(v.fqid),this._changes.removeLayer(v);const D=this.getOwnLayerSourceCache(v);if(D&&D.castsShadows){let F=!1;for(const B in this._layers)if(this._layers[B].source===v.source&&this._layers[B].canCastShadows()){F=!0;break}D.castsShadows=F}v.onRemove&&v.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const v in this._layers)if(this._layers[v].type===h)return!0;return!1}setLayerZoomRange(h,v,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===v&&D.maxzoom===A||(v!=null&&(D.minzoom=v),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,v){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==v&&(A.slot=v,this._updateLayer(A))}setFilter(h,v,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,v))return v==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Aa,`layers.${D.id}.filter`,v,{layerType:D.type},A)||(D.filter=i.dp(v),this._updateLayer(D)))}getFilter(h){const v=this._checkLayer(h);if(v)return i.dp(v.filter)}setLayoutProperty(h,v,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(v),A)){if(A!=null&&(!D||D.validate!==!1)&&Cy(F,$t.call(Yr,{key:`layers.${h}.layout.${v}`,layerType:F.type,objectKey:v,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(v,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,v,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(v==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(v)?this.setPaintProperty(h,v,A,D):this.setLayoutProperty(h,v,A,D))}getLayoutProperty(h,v){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(v)}setPaintProperty(h,v,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(v),A)||A!=null&&(!D||D.validate!==!1)&&Cy(F,no.call(Yr,{key:`layers.${h}.paint.${v}`,layerType:F.type,objectKey:v,value:A,styleSpec:i.a6})))return;const B=F.setPaintProperty(v,A);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),B&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,v){const A=this._checkLayer(h);if(A)return A.getPaintProperty(v)}setFeatureState(h,v){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:ee,importId:ae}=h.target,le=this.getFragmentStyle(ae),we=le.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ne}of we)le.setFeatureState({id:h.id,source:be,sourceLayer:Ne},v)}else if("layerId"in h.target){const{layerId:ee}=h.target,ae=this.getLayer(ee);this.setFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},v)}return}const A=h.source,D=h.sourceLayer,F=this._checkSource(A);if(!F)return;const B=F.type;if(B==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(B==="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 ee of W)ee.setFeatureState(D,h.id,v)}removeFeatureState(h,v){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:ee,importId:ae}=h.target,le=this.getFragmentStyle(ae),we=le.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ne}of we)le.removeFeatureState({id:h.id,source:be,sourceLayer:Ne},v)}else if("layerId"in h.target){const{layerId:ee}=h.target,ae=this.getLayer(ee);this.removeFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},v)}return}const A=h.source,D=this._checkSource(A);if(!D)return;const F=D.type,B=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!B)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(v&&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 ee of W)ee.removeFeatureState(B,h.id,v)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:B,importId:W}=h.target,ee=this.getFragmentStyle(W),ae=ee.getFeaturesetLayers(B);for(const{source:le,sourceLayer:we}of ae){const be=ee.getFeatureState({id:h.id,source:le,sourceLayer:we});if(be&&!F)F=be;else if(!i.by(F,be))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:B}=h.target,W=this.getLayer(B);F=this.getFeatureState({id:h.id,source:W.source,sourceLayer:W.sourceLayer})}return F}const v=h.source,A=h.sourceLayer,D=this._checkSource(v);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(v)[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(),v=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:v,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 v of Object.values(this._mergedLayers))h(v)&&this._updateLayer(v)}_updateLayer(h){this._changes.updateLayer(h);const v=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&v&&v.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),v.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const v=W=>this._mergedLayers[W].is3D(!!this.terrain),A=this.order,D={},F=[];for(let W=A.length-1;W>=0;W--){const ee=A[W];if(v(ee)){D[ee]=W;for(const ae of h){const le=ae[ee];if(le)for(const we of le)F.push(we)}}}F.sort((W,ee)=>ee.intersectionZ-W.intersectionZ);const B=[];for(let W=A.length-1;W>=0;W--){const ee=A[W];if(v(ee))for(let ae=F.length-1;ae>=0;ae--){const le=F[ae].feature;if(le.layer&&D[le.layer.id]{if(sC.has(le.type))return;const we=this.getOwnLayerSourceCache(le),be=F[we.id]=F[we.id]||{sourceCache:we,layers:{},has3DLayers:!1};le.is3D(!!this.terrain)&&(be.has3DLayers=!0),be.layers[le.fqid]=be.layers[le.fqid]||{styleLayer:le,targets:[]},be.layers[le.fqid].targets.push({filter:D})};if(v&&v.layers){if(!Array.isArray(v.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const le of v.layers){const we=this._layers[le];if(!we)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.`))),[];B(we)}}else for(const le in this._layers)B(this._layers[le]);const W=this._queryRenderedFeatures(h,F,A),ee=this._flattenAndSortRenderedFeatures(W),ae=[];for(const le of ee)i.dw(le.layer.id)===this.scope&&ae.push(le);return ae}queryRenderedFeatureset(h,v,A){let D;v&&!Array.isArray(v)&&v.filter&&(this._validate(Aa,"queryRenderedFeatures.filter",v.filter,null,v),D=i.b6(v.filter));const F="mock",B=[];if(v&&v.target)B.push(Object.assign({},v,{targetId:F,filter:D}));else{const le=this.getFeaturesetDescriptors();for(const we of le)B.push({targetId:F,filter:D,target:we});for(const{style:we}of this.fragments){const be=we.getFeaturesetDescriptors();for(const Ne of be)B.push({targetId:F,filter:D,target:Ne})}}const W=this.queryRenderedTargets(h,B,A),ee=[],ae=new Set;for(const le of W)for(const we of le.variants[F])_y(we,le,ae)||ee.push(new i.dx(le,we));return ee}queryRenderedTargets(h,v,A){const D={},F=(W,ee,ae,le)=>{const we=D[ee.id]=D[ee.id]||{sourceCache:ee,layers:{},has3DLayers:!1};if(we.layers[W.fqid]=we.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(we.has3DLayers=!0),!le)return ae.uniqueFeatureID=!1,void we.layers[W.fqid].targets.push(ae);we.layers[W.fqid].targets.push(Object.assign({},ae,{namespace:le.namespace,properties:le.properties,uniqueFeatureID:le.uniqueFeatureID}))};for(const W of v)if("featuresetId"in W.target){const{featuresetId:ee,importId:ae}=W.target,le=this.getFragmentStyle(ae);if(!le||!le._featuresetSelectors)continue;const we=le._featuresetSelectors[ee];if(!we){this.fire(new i.y(new Error(`The featureset '${ee}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const be of we){const Ne=le.getOwnLayer(be.layerId);Ne&&!sC.has(Ne.type)&&F(Ne,le.getOwnLayerSourceCache(Ne),W,be)}}else if("layerId"in W.target){const{layerId:ee}=W.target,ae=this.getLayer(ee);if(!ae||sC.has(ae.type))continue;F(ae,this.getLayerSourceCache(ae),W)}const B=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(B)}_queryRenderedFeatures(h,v,A){const D=[],F=!!this.map._showQueryGeometry,B=mo.createFromScreenPoints(h,A);for(const W in v){const ee=J1(B,v[W],this._availableImages,A,F);Object.keys(ee).length&&D.push(ee)}if(this.placement)for(const W in v){if(!v[W].sourceCache._onlySymbols)continue;const ee=eb(B.screenGeometry,v[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(ee).length&&D.push(ee)}return D}querySourceFeatures(h,v){const A=v&&v.filter;A&&this._validate(Aa,"querySourceFeatures.filter",A,null,v);let D=[];const F=this.getOwnSourceCaches(h);for(const B of F)D=D.concat(tb(B,v));return D}addSourceType(h,v,A){return sp.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(sp.setSourceType(h,v),v.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:v.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,v,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 B=this._getTransitionParameters();this.light.setLight(h,v,A),this.light.updateTransitions(B)}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,v=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),v===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(v===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),B={};if(this.terrain&&D){F.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&(B.style=W.serialize())}if(this._validate(Hr,"terrain",F,B))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&v!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,v),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,B=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],B[W])){F.set(h,this.options),this.stylesheet.terrain=h;const ee=this._getTransitionParameters({duration:0});F.updateTransitions(ee),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const v=this.fog=new Dn(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=v.get();const A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}_createSnow(h){const v=this.snow=new fl(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=v.get();const A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}_createRain(h){const v=this.rain=new ho(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=v.get();const A=this._getTransitionParameters({duration:0});v.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 v=this.fog;if(!i.by(v.get(),h)){v.set(h,this.options),this.stylesheet.fog=v.get();const A=this._getTransitionParameters({duration:0});v.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 v=this.snow;if(!i.by(v.get(),h)){v.set(h,this.options),this.stylesheet.snow=v.get();const A=this._getTransitionParameters({duration:0});v.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 v=this.rain;if(!i.by(v.get(),h)){v.set(h,this.options),this.stylesheet.rain=v.get();const A=this._getTransitionParameters({duration:0});v.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()},v=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!v)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(v);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,v){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=v,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],v=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):v.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...v)}_createTerrain(h,v){const A=this.terrain=new qt(h,v,this.scope,this.options,this.map.getWorldview());v===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 v=this._layers[h];v.type==="fill-extrusion"&&this._updateLayer(v)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const v=this._layers[h];v.type==="symbol"&&this._updateLayer(v)}}_validate(h,v,A,D,F={}){if(F&&F.validate===!1)return!1;const B=Object.assign({},this.serialize());return Cy(this,h.call(Yr,Object.assign({key:v,style:B,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 v=this.getSourceCaches(h);for(const A of v)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const v=this._mergedLayers[h];v._clear&&v._clear()}}reloadSource(h){const v=this.getSourceCaches(h);for(const A of v)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 v;this.directionalLight&&(v=i2(this.directionalLight));const A=new Set,D=new Set;for(const F in this._mergedLayers){const B=this._mergedLayers[F];B.type==="building"&&A.add(B.source),B.hasElevation()&&!D.has(B.source)&&D.add(B.source)}for(const F in this._mergedSourceCaches){const B=this._mergedSourceCaches[F],W=D.has(B._source.id);A.has(B._source.id)&&(B._source.reparseOverscaled=!1),B.update(h,void 0,void 0,v,W)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const v=this._sourceCaches[h];v.resume(),v.reload()}}_updatePlacement(h,v,A,D,F,B,W=!1){let ee=!1,ae=!1;const le={},we={};for(const Ie of this._mergedOrder){const Ze=this._mergedLayers[Ie];if(Ze.type!=="symbol")continue;const Ve=i.B(Ze.source,Ze.scope);let at=le[Ve];if(!at){const ot=this.getLayerSourceCache(Ze);if(!ot)continue;const At=ot.getRenderableIds(!0).map(Nt=>ot.getTileByID(Nt));we[Ve]=At.slice(),at=le[Ve]=At.sort((Nt,Ct)=>Ct.tileID.overscaledZ-Nt.tileID.overscaledZ||(Nt.tileID.isLessThan(Ct.tileID)?-1:1))}const ht=this.crossTileSymbolIndex.addLayer(Ze,at,v.center.lng,v.projection);ee=ee||ht}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),W=W||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const be=!!(this.placement&&!v.equals(this.placement.transform)),Ne=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!B||this.placement.lastReplacementSourceUpdateTime!==B.updateTime)),Re=(be||Ne||ee||this.placement&&this.placement.isStale())&&D===0;if((W||!this.pauseablePlacement||Re||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),v.zoom))&&(this.pauseablePlacement=new Ec(v,this._mergedOrder,W||D===0,A,D,F,this.placement,this.fog&&v.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,we,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ae=!0),ee&&this.pauseablePlacement.placement.setStale()),ae||ee){this._buildingIndex.onNewFrame(v.zoom);for(let Ie=0;IeF===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(!v)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===v);return D===-1&&this.fire(new i.y(new Error(`Import with id "${v}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,v)}updateImport(h,v){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof v=="string"?(this.setImportUrl(h,v),this):(v.url&&v.url!==A[D].url&&this.setImportUrl(h,v.url),i.by(v.config,A[D].config)||this.setImportConfig(h,v.config,v.data.schema),i.by(v.data,A[D].data)||this.setImportData(h,v.data),this)}moveImport(h,v){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(v);if(F===-1)return this;const B=A[D],W=this.fragments[D];return A=A.filter(({id:ee})=>ee!==h),this.fragments=this.fragments.filter(({id:ee})=>ee!==h),this.stylesheet.imports=A.slice(0,F).concat(B).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(W).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,v){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=v;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(v),this}setImportData(h,v){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:v?(this.fragments[A].style.setState(v),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,v,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;v?F[D].config=v:delete F[D].config;const B=this.fragments[D];A&&B.style.stylesheet&&(B.style.stylesheet.schema=A);const W=B.style.stylesheet&&B.style.stylesheet.schema;return B.config=v,B.style.updateConfig(v,W),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const v=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(v.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const v=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return v===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),v}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const v in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[v];A&&h.push(A.getSource())}return h}getSource(h,v){const A=this.getSourceCache(h,v);return A&&A.getSource()}getLayerSource(h){const v=this.getLayerSourceCache(h);return v&&v.getSource()}getSourceCache(h,v){const A=i.B(h,v);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const v=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[v]:this._mergedOtherSourceCaches[v]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const v=[];return this._mergedOtherSourceCaches[h]&&v.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&v.push(this._mergedSymbolSourceCaches[h]),v}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const v in h){const A=h[v];A==="reload"?this.reloadSource(v):A==="clear"&&this.clearSource(v)}}updateLayers(h){const v=this._changes.getUpdatedPaintProperties();for(const A of v){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,v,A){this.imageManager.getImages(v.images,v.scope,A),this._updateTilesForChangedImages();const D=B=>{if(B){const W=v.images.map(ee=>i.I.toString(ee));B.setDependencies(v.tileID.key,v.type,W)}},F=i.B(v.source,v.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),v.images.some(B=>B.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,v,A){this.imageManager.rasterizeImages(v,A)}getGlyphs(h,v,A){this.glyphManager.getGlyphs(v.stacks,A)}getResource(h,v,A){return i.dz(v,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const v=[];return this._otherSourceCaches[h]&&v.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&v.push(this._symbolSourceCaches[h]),v}_isSourceCacheLoaded(h){const v=this.getOwnSourceCaches(h);return v.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):v.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,v){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||v&&v.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)}}sp.getSourceType=function(T){return Zm[T]},sp.setSourceType=function(T,h){Zm[T]=h},sp.registerForPluginStateChange=i.dA;class ZR 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[v,A]of Object.entries(h.buildings))if(this._buildings[v])for(const D of A.floorIds)this._buildings[v].floors[D]||(this._buildings[v].floors[D]=A.floors[D]);else this._buildings[v]=A;for(const v of h.activeFloors)this._activeFloors.add(v);this._updateIndoorSelector()}getIndoorTileOptions(h,v){const A=this._style.getIndoorSourceLayers(h,v);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,v,A){const D=function(F,B,W,ee){let ae=null,le=Number.MAX_SAFE_INTEGER;if(ee<16)return null;for(const[we,be]of Object.entries(F)){const Ne=be.center;if(Ne){const Re=B.distanceTo(i.aT.convert(Ne));Re({id:B,name:A.floors[B].name,zIndex:A.floors[B].zIndex})).sort((B,W)=>W.zIndex-B.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 lb=` #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`,cb=` #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;}`,u6=` #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`,rC="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;}",mm=` #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`,nC=`#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`,sr=`#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`,h6=`#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`,aC=`#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;}`,iC=`#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`,m6=`#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 l2=/#include\s+"([^"]+)"/g,Wf=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,p6=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,cv=new Set(["ifdef","ifndef","elif","if","defined"]),dv=new Set;Ay(lb,dv),Ay(u6,dv),Ay(cb,dv);const Ty={"_prelude_fog.vertex.glsl":nC,"_prelude_terrain.vertex.glsl":mm,"_prelude_shadow.vertex.glsl":iC,"_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":sr,"_prelude_shadow.fragment.glsl":m6,"_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":h6,"_prelude_raster_particle.glsl":aC},oC={};Ua("",mm),Ua(sr,nC),Ua(m6,iC),Ua(h6,""),Ua(aC,"");const YR=Ua(cb,u6),lC=lb,Ume=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",lC,YR.fragmentSource].join(` `),QR=["precision highp float;",lC,YR.vertexSource].join(` `);var f6={background:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`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:Ua(`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:Ua(`#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:Ua("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:Ua(`#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:Ua(`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:Ua("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:Ua("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:Ua("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:Ua(`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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`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:Ua(`#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:Ua(`#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:Ua(`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:Ua(`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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`#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:Ua("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:Ua("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:Ua(`#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:Ua(`#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:Ua(`#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:Ua("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:Ua(`#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 }`,rC),skyboxGradient:Ua(`#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 }`,rC),skyboxCapture:Ua(` 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:Ua(`#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:Ua(`#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:Ua(`#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:Ua(`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:Ua(`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:Ua("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:Ua("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:Ua("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:Ua("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 Ay(T,h){const v=T.split(` `);for(let A of v){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(p6);if(D)for(const F of D)cv.has(F)||h.add(F)}}function Ua(T,h){const v=new Set,A=[],D=[];T=T.replace(l2,(B,W)=>(D.push(W),"")),h=h.replace(l2,(B,W)=>(A.push(W),""));let F=new Set(dv);Ay(T,F),Ay(h,F);for(const B of[...A,...D])oC[B]||(oC[B]=new Set,Ay(Ty[B],oC[B])),F=new Set([...F,...oC[B]]);return{fragmentSource:T=T.replace(Wf,(B,W,ee,ae,le)=>(v.add(le),W==="define"?` #ifndef HAS_UNIFORM_u_${le} in ${ee} ${ae} ${le}; #else uniform ${ee} ${ae} u_${le}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${le} ${ee} ${ae} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${ee} ${ae} ${le}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Wf,(B,W,ee,ae,le)=>{const we=`MATERIAL_ATTRIBUTE_OFFSET_${le}`,be=ae==="float"?"vec2":ae,Ne=`GET_ATTRIBUTE_${be}(a_${le}, materialInfo, ${we})`,Re=le.match(/color/)?"color":be;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${ee} ${ae} a_${le}; #endif `:v.has(le)?W==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${we}) in ${ee} ${be} a_${le}; #endif out ${ee} ${ae} ${le}; #else uniform ${ee} ${ae} u_${le}; #endif `:W==="initialize"?Re==="vec4"?` #ifndef HAS_UNIFORM_u_${le} ${le} = a_${le}; #else ${ee} ${ae} ${le} = u_${le}; #endif `:` #if !defined(HAS_UNIFORM_u_${le}) #ifdef ${we} ${le} = unpack_mix_${Re}(${Ne}, u_${le}_t); #else ${le} = unpack_mix_${Re}(a_${le}, u_${le}_t); #endif #else ${ee} ${ae} ${le} = u_${le}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${ee} ${ae} a_${le}; out ${ee} ${ae} ${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(${we}) in ${ee} ${be} a_${le}; #endif #else uniform ${ee} ${ae} u_${le}; #endif `:W==="define-instanced"?Re==="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 ${ee} ${ae} u_${le}; #endif `:` #ifdef INSTANCED_ARRAYS in ${ee} ${be} a_${le}; #else uniform ${ee} ${ae} u_${le}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${le} ${ee} ${ae} ${le} = a_${le}; #endif `:Re==="vec4"?` #ifndef HAS_UNIFORM_u_${le} #ifdef ${we} ${ee} ${ae} ${le} = ${Ne}; #else ${ee} ${ae} ${le} = a_${le}; #endif #else ${ee} ${ae} ${le} = u_${le}; #endif `:` #ifndef HAS_UNIFORM_u_${le} #ifdef ${we} ${ee} ${ae} ${le} = unpack_mix_${Re}(${Ne}, u_${le}_t); #else ${ee} ${ae} ${le} = unpack_mix_${Re}(a_${le}, u_${le}_t); #endif #else ${ee} ${ae} ${le} = u_${le}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class Vme{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,v,A,D,F,B,W,ee){this.context=h;let ae=this.boundPaintVertexBuffers.length!==D.length;for(let we=0;!ae&&we{const At=ht.paint.get("hillshade-shadow-color"),Nt=ht.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Ct=ht.paint.get("hillshade-highlight-color"),wt=ht.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",gt=ht.paint.get("hillshade-accent-color"),Dt=ht.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=ht.paint.get("hillshade-emissive-strength");let Ut=i.an(ht.paint.get("hillshade-illumination-direction"));if(ht.paint.get("hillshade-illumination-anchor")==="viewport")Ut-=Ve.transform.angle;else if(Ve.style&&Ve.style.enable3dLights()&&Ve.style.directionalLight){const ts=Ve.style.directionalLight.properties.get("direction"),_s=i.d4(ts.x,ts.y,ts.z);Ut=i.an(_s[1])}const es=!Ve.options.moving;return{u_matrix:ot||Ve.transform.calculateProjMatrix(at.tileID.toUnwrapped(),es),u_image:0,u_latrange:Hme(0,at.tileID),u_light:[ht.paint.get("hillshade-exaggeration"),Ut],u_shadow:At.toPremultipliedRenderColor(Nt?null:ht.lut),u_highlight:Ct.toPremultipliedRenderColor(wt?null:ht.lut),u_emissive_strength:Ht,u_accent:gt.toPremultipliedRenderColor(Dt?null:ht.lut)}})(T,v,A,T.terrain?h.projMatrix:null);T.uploadCommonUniforms(W,be,h.toUnwrapped());const{tileBoundsBuffer:Re,tileBoundsIndexBuffer:Ie,tileBoundsSegments:Ze}=T.getTileBoundsBuffers(v);be.draw(T,ee.TRIANGLES,D,F,B,gn.disabled,Ne,A.id,Re,Ie,Ze)}function x6(T,h,v){if(!h.needsDEMTextureUpload)return;const A=T.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||T.getTileTexture(v.stride);const F=v.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Wme(T,h,v){const A=T.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),x6(T,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const B=F.dim;A.activeTexture.set(D.TEXTURE0);let W=h.hillshadeFBO;if(!W){const be=new i.T(A,{width:B,height:B,data:null},D.RGBA8);be.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=h.hillshadeFBO=A.createFramebuffer(B,B,1,"renderbuffer"),W.colorAttachment0.set(be.texture)}A.bindFramebuffer.set(W.framebuffer),A.viewport.set([0,0,B,B]);const{tileBoundsBuffer:ee,tileBoundsIndexBuffer:ae,tileBoundsSegments:le}=T.getMercatorTileBoundsBuffers(),we=[];T.linearFloatFilteringSupported()&&we.push("TERRAIN_DEM_FLOAT_FORMAT"),T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&we.push("USE_MRT1"),T.getOrCreateProgram("hillshadePrepare",{defines:we}).draw(T,D.TRIANGLES,Br.disabled,bn.disabled,Gn.unblended,gn.disabled,((be,Ne)=>{const Re=Ne.stride,Ie=i.bC();return i.ce(Ie,0,i.al,-i.al,0,0,1),i.br(Ie,Ie,[0,-i.al,0]),{u_matrix:Ie,u_image:1,u_dimension:[Re,Re],u_zoom:be.overscaledZ}})(h.tileID,F),v.id,ee,ae,le),h.needsHillshadePrepare=!1}class xo{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 Kme extends xo{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const v=this.current;(h.r!==v.r||h.g!==v.g||h.b!==v.b||h.a!==v.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class XR extends xo{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class g6 extends xo{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class cC extends xo{getDefault(){return[!0,!0,!0,!0]}set(h){const v=this.current;(h[0]!==v[0]||h[1]!==v[1]||h[2]!==v[2]||h[3]!==v[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class y6 extends xo{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class uv extends xo{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class db extends xo{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const v=this.current;(h.func!==v.func||h.ref!==v.ref||h.mask!==v.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class c2 extends xo{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const v=this.current;(h[0]!==v[0]||h[1]!==v[1]||h[2]!==v[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class ub extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;h?v.enable(v.STENCIL_TEST):v.disable(v.STENCIL_TEST),this.current=h,this.dirty=!1}}class JR extends xo{getDefault(){return[0,1]}set(h){const v=this.current;(h[0]!==v[0]||h[1]!==v[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class v6 extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;h?v.enable(v.DEPTH_TEST):v.disable(v.DEPTH_TEST),this.current=h,this.dirty=!1}}class eF extends xo{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class hb extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;h?v.enable(v.BLEND):v.disable(v.BLEND),this.current=h,this.dirty=!1}}class dC extends xo{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const v=this.current;(h[0]!==v[0]||h[1]!==v[1]||h[2]!==v[2]||h[3]!==v[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class uC extends xo{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const v=this.current;(h.r!==v.r||h.g!==v.g||h.b!==v.b||h.a!==v.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class b6 extends xo{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 hC extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;h?v.enable(v.CULL_FACE):v.disable(v.CULL_FACE),this.current=h,this.dirty=!1}}class d2 extends xo{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class tF extends xo{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let sF=class extends xo{getDefault(){return null}set(T){(T!==this.current||this.dirty)&&(this.gl.useProgram(T),this.current=T,this.dirty=!1)}};class rF extends xo{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class mb extends xo{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const v=this.current;(h[0]!==v[0]||h[1]!==v[1]||h[2]!==v[2]||h[3]!==v[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class nF extends xo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.bindFramebuffer(v.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class Zme extends xo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.bindRenderbuffer(v.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class Yme extends xo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.bindTexture(v.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Qme extends xo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.bindBuffer(v.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class _6 extends xo{getDefault(){return null}set(h){const v=this.gl;v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class w6 extends xo{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class j6 extends xo{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class N6 extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class aF extends xo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class mC extends xo{constructor(h,v){super(h),this.context=h,this.parent=v}getDefault(){return null}}class pC extends mC{constructor(h,v,A=0){super(h,v),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 v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachmentPoint,v.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class pb extends mC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferRenderbuffer(v.FRAMEBUFFER,this.attachment(),v.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class u2 extends mC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachment(),v.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class iF extends pb{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const pm=(T,h,v,A)=>({u_matrix:T,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:v,u_emissive_texture_available:A}),fC=(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze)=>({u_proj_matrix:Float32Array.from(T),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:v,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:B,u_frustum_tr:W,u_frustum_br:ee,u_frustum_bl:ae,u_globe_pos:le,u_globe_radius:we,u_viewport:be,u_grid_matrix:Ze?Float32Array.from(Ze):new Float32Array(9),u_skirt_height:Ne,u_far_z_cutoff:Re,u_emissive_texture_available:Ie});function h2(T,h){return T!=null&&h!=null&&!(!T.hasData()||!h.hasData())&&T.demTexture!=null&&h.demTexture!=null&&T.tileID.key!==h.tileID.key}const ig=new class{constructor(){this.operations={}}newMorphing(T,h,v,A,D){if(T in this.operations){const F=this.operations[T];F.to.tileID.key!==v.tileID.key&&(F.queued=v)}else this.operations[T]={startTime:A,phase:0,duration:D,from:h,to:v,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 v=this.operations[h];for(v.phase=(T-v.startTime)/v.duration;v.phase>=1||!this._validOp(v);)if(!this._nextOp(v,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()}},xC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function gC(T,h,v){if(h===0)return 0;const A=h<1&&v===514?.25/h:1;return 6*Math.pow(1.5,22-T)*Math.max(h,1)*A}function k6(T,h){const v=1<({u_matrix:T});function p2(T,h,v,A,D){if(D>0){const F=i.o.now(),B=(F-T.timeAdded)/D,W=h?(F-h.timeAdded)/D:-1,ee=v.getSource(),ae=A.coveringZoomLevel({tileSize:ee.tileSize,roundZoom:ee.roundZoom}),le=!h||Math.abs(h.tileID.overscaledZ-ae)>Math.abs(T.tileID.overscaledZ-ae),we=le&&T.refreshedUponExpiration?1:i.aA(le?B:1-W,0,1);return h?{opacity:1,mix:1-we,isFading:B<1}:{opacity:we,mix:0,isFading:B<1}}return{opacity:1,mix:0,isFading:!1}}class yC extends Il{constructor(h){const v=Hl("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",v,!1),v.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,v){h.state="loaded",v(null)}}class S6 extends Il{constructor(h){const v=Hl("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",v,!1),v.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,v,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,B)=>{if(F[B.key]="",!this._tiles[B.key]){const W=new Qm(B,this._source.tileSize*B.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[B.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 v=this.proxyCachedFBO[h];if(v!==void 0){const A=Object.values(v);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,v,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=v,this.projMatrix=A}}class M6 extends i.bV{constructor(h,v){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(ee){const ae=new i.bd,le=new i.b0,we=131;ae.reserve(17161),le.reserve(33800);const be=i.al/128,Ne=i.al+be/2,Re=Ne+be;for(let Ze=-be;ZeNe||Ze<0||Ze>Ne?24575:0,ht=i.aA(Math.round(Ve),0,i.al),ot=i.aA(Math.round(Ze),0,i.al);ae.emplaceBack(ht+at,ot)}const Ie=(Ze,Ve)=>{const at=Ve*we+Ze;le.emplaceBack(at+1,at,at+we),le.emplaceBack(at+we,at+we+1,at+1)};for(let Ze=1;Ze<129;Ze++)for(let Ve=1;Ve<129;Ve++)Ie(Ve,Ze);return[0,129].forEach(Ze=>{for(let Ve=0;Ve<130;Ve++)Ie(Ve,Ze),Ie(Ze,Ve)}),[ae,le,32768]}(),B=h.context;this.gridBuffer=B.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=B.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 S6(v.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=B.gl;this._overlapStencilMode=new bn({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=v,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new yC(v.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,v,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,B=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const W=h.terrain&&h.terrain.scope,ee=D.get("source"),ae=F?this._mockSourceCache:h.getSourceCache(ee,W);if(!ae)return void i.w(`Couldn't find terrain source "${ee}".`);if(this.sourceCache=ae,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=B?this.calculateExaggeration(v):D.get("exaggeration"),!v.projection.requiresDraping&&B&&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 we=this.getScaledDemTileSize();this.sourceCache.update(v,we,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,le(),this._initializing=!0),le(),v.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(v),this._emptyDEMTextureDirty=!0,this._previousZoom=v.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const v=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=v!=null?A-v:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,B=this._style.terrain;if(!this._previousUpdateTimestamp)return B.getExaggeration(F);let W=F-this._previousZoom;const ee=this._previousUpdateTimestamp;let ae=F;this._evaluationZoom!=null&&(ae=this._evaluationZoom,Math.abs(F-ae)>.5&&(W=.5*(F-ae+W)),W*D<0&&(ae+=W)),this._evaluationZoom=ae;const le=B.getExaggeration(ae),we=le===B.getExaggeration(Math.max(0,ae-.1));if(we&&Math.abs(le-this._exaggeration)<.01)return le;let be=Math.min(.1,.00375*(this._updateTimestamp-ee));return(we||le<.1||Math.abs(W)<1e-4)&&(be=Math.min(.2,4*be)),i.ak(this._exaggeration,le,be)}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 v=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=v.getIds().map(ee=>{const ae=v.getTileByID(ee).tileID;return ae.projMatrix=A.calculateProjMatrix(ae.toUnwrapped()),ae});(function(ee,ae){const le=ae.transform.pointCoordinate(ae.transform.getCameraPoint()),we=new i.P(le.x,le.y);ee.sort((be,Ne)=>{if(Ne.overscaledZ-be.overscaledZ)return Ne.overscaledZ-be.overscaledZ;const Re=new i.P(be.canonical.x+(1<{this.proxyToSource[ee.key]={}}),this.terrainTileForTile={};const B=this._style._mergedSourceCaches;for(const ee in B){const ae=B[ee];if(!ae.used||(ae!==this.sourceCache&&this.resetTileLookupCache(ae.id),this._setupProxiedCoordsForOrtho(ae,h[ee],F),ae.usedForTerrain))continue;const le=h[ee];ae.getSource().reparseOverscaled&&this._assignTerrainTiles(le)}this.proxiedCoords[v.id]=D.map(ee=>new C6(ee,ee.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const ae=this.terrainTileForTile[ee.key];if(!ae)continue;const le=ae.tileID.key;le in W||(this._visibleDemTiles.push(ae),W[le]=le)}}_assignTerrainTiles(h){this._initializing||h.forEach(v=>{if(this.terrainTileForTile[v.key])return;const A=this._findTileCoveringTileID(v,this.sourceCache);A&&(this.terrainTileForTile[v.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,v=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(v.TEXTURE1),x6(this.painter,D,F))}}_prepareDemTileUniforms(h,v,A,D){if(!v||v.demTexture==null)return!1;const F=h.tileID.canonical,B=Math.pow(2,v.tileID.canonical.z-F.z),W=D||"";return A[`u_dem_tl${W}`]=[F.x*B%1,F.y*B%1],A[`u_dem_scale${W}`]=B,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const v=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?v/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,v=h.gl;h.activeTexture.set(v.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,v.R32F,{premultiply:!1}),F}setupElevationDraw(h,v,A){const D=this.painter.context,F=D.gl,B={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};B.u_exaggeration=this.exaggeration();let W=null,ee=null,ae=1;if(A&&A.morphing&&this._useVertexMorphing){const Ne=A.morphing.srcDemTile,Re=A.morphing.dstDemTile;ae=A.morphing.phase,Ne&&Re&&(this._prepareDemTileUniforms(h,Ne,B,"_prev")&&(ee=Ne),this._prepareDemTileUniforms(h,Re,B)&&(W=Re))}const le=Ne=>Ne&&Ne.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let we=null;var be;if(this.enabled?ee&&W?(we=W.demTexture,D.activeTexture.set(F.TEXTURE4),ee.demTexture.bind(le(ee),F.CLAMP_TO_EDGE),B.u_dem_lerp=ae):(W=this.terrainTileForTile[h.tileID.key],we=this._prepareDemTileUniforms(h,W,B)?W.demTexture:this.emptyDEMTexture):we=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),we&&(B.u_dem_size=(be=we).size[0]===1?1:be.size[0]-2,we.bind(le(W),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,v,B),A&&A.useMeterToDem&&W){const Ne=(1<{if(Ve===ts)return;const _s=[xC[ts],"PROJECTION_GLOBE_VIEW"];ht&&_s.push("CUSTOM_ANTIALIASING");const Ks=ae.isTileAffectedByFog(es);Ze=ae.getOrCreateProgram("globeRaster",{defines:_s,overrideFog:Ks}),Ve=ts},At=ae.colorModeForRenderPass(),Nt=new Br(Ie.LEQUAL,Br.ReadWrite,ae.depthRangeFor3D);ig.update(Ne);const Ct=i.dF(at),wt=[i.aF(at.center.lng),i.aJ(at.center.lat)],gt=ae.globeSharedBuffers,Dt=[at.width*i.o.devicePixelRatio,at.height*i.o.devicePixelRatio],Ht=Float32Array.from(at.globeMatrix),Ut={useDenormalizedUpVectorScale:!0};{const es=ae.transform,ts=gC(es.zoom,le.exaggeration(),le.sourceCache._source.tileSize);Ve=-1;const _s=Ie.TRIANGLES;for(const Ks of be){const Yt=we.getTile(Ks),zt=bn.disabled,is=le.prevTerrainTileForTile[Ks.key],Jt=le.terrainTileForTile[Ks.key];h2(is,Jt)&&ig.newMorphing(Ks.key,is,Jt,Ne,250),fb(ae,Yt.emissiveTexture),Re.activeTexture.set(Ie.TEXTURE0),Yt.texture&&Yt.texture.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const zs=ig.getMorphValuesForProxy(Ks.key),ir=zs?1:0;zs&&Object.assign(Ut,{morphing:{srcDemTile:zs.from,dstDemTile:zs.to,phase:i.dD(zs.phase)}});const br=i.dG(Ks.canonical),er=i.dH(br.getCenter().lat),Zs=i.dI(Ks.canonical,br,er,es.worldSize/es._pixelsPerMercatorPixel),Dr=i.bk(i.dJ(Ks.canonical)),Pr=ae.emissiveMode==="mrt-fallback"?1:0,pr=fC(es.expandedFarZProjMatrix,Ht,Ct,Dr,i.aj(es.zoom),wt,es.frustumCorners.TL,es.frustumCorners.TR,es.frustumCorners.BR,es.frustumCorners.BL,es.globeCenterInViewSpace,es.globeRadius,Dt,ts,es._farZ,Pr,Zs);if(ot(Ks,ir),Ze&&(le.setupElevationDraw(Yt,Ze,Ut),ae.uploadCommonUniforms(Re,Ze,Ks.toUnwrapped()),gt)){const[wr,Qr,On]=gt.getGridBuffers(er,ts!==0);Ze.draw(ae,_s,Nt,zt,At,gn.backCCW,pr,"globe_raster",wr,Qr,On)}}}if(gt&&(ae.renderDefaultNorthPole||ae.renderDefaultSouthPole)){const es=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ht&&es.push("CUSTOM_ANTIALIASING"),Ze=ae.getOrCreateProgram("globeRaster",{defines:es});for(const ts of be){const{x:_s,y:Ks,z:Yt}=ts.canonical,zt=Ks===0,is=Ks===(1<wr.draw(ae,Ie.TRIANGLES,Nt,bn.disabled,At,gn.disabled,fC(at.expandedFarZProjMatrix,Zs,Zs,Dr,0,wt,at.frustumCorners.TL,at.frustumCorners.TR,at.frustumCorners.BR,at.frustumCorners.BL,at.globeCenterInViewSpace,at.globeRadius,Dt,0,at._farZ,Pr),"globe_pole_raster",Qr,ir,br);le.setupElevationDraw(er,Ze,Ut),ae.uploadCommonUniforms(Re,Ze,ts.toUnwrapped()),zt&&ae.renderDefaultNorthPole&&pr(Ze,Jt),is&&ae.renderDefaultSouthPole&&(Zs=i.cS(i.bC(),Zs,[1,-1,1]),pr(Ze,zs))}}}})(D,F,B,W,ee);else{const ae=D.context,le=ae.gl;let we,be;const Ne=D.shadowRenderer,Re=ky(D,D.longestCutoffRange),Ie=At=>{if(be===At)return;const Nt=[];Nt.push(xC[At]),Re.shouldRenderCutoff&&Nt.push("RENDER_CUTOFF"),Ne&&(Nt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ne.useNormalOffset&&Nt.push("NORMAL_OFFSET")),we=D.getOrCreateProgram("terrainRaster",{defines:Nt}),be=At},Ze=D.colorModeForRenderPass(),Ve=new Br(le.LEQUAL,Br.ReadWrite,D.depthRangeFor3D);ig.update(ee);const at=D.transform,ht=gC(at.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let ot=[0,0,0];if(Ne){const At=D.style.directionalLight,Nt=D.style.ambientLight;At&&Nt&&(ot=ag(D.style,At,Nt))}{be=-1;const At=le.TRIANGLES,[Nt,Ct]=[F.gridIndexBuffer,F.gridSegments];for(const wt of W){const gt=B.getTile(wt),Dt=bn.disabled,Ht=F.prevTerrainTileForTile[wt.key],Ut=F.terrainTileForTile[wt.key];h2(Ht,Ut)&&ig.newMorphing(wt.key,Ht,Ut,ee,250),fb(D,gt.emissiveTexture),ae.activeTexture.set(le.TEXTURE0),gt.texture&>.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const es=ig.getMorphValuesForProxy(wt.key),ts=es?1:0;let _s;es&&(_s={morphing:{srcDemTile:es.from,dstDemTile:es.to,phase:i.dD(es.phase)}});const Ks=D.emissiveMode==="mrt-fallback"?1:0,Yt=pm(wt.projMatrix,k6(wt.canonical,at.renderWorldCopies)?ht/10:ht,ot,Ks);if(Ie(ts),!we)continue;F.setupElevationDraw(gt,we,_s);const zt=wt.toUnwrapped();Ne&&Ne.setupShadows(zt,we),D.uploadCommonUniforms(ae,we,zt,null,Re),we.draw(D,At,Ve,Dt,Ze,gn.backCCW,Yt,"terrain_raster",F.gridBuffer,Nt,Ct)}}}}(v,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,v.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const v=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],B=this._drapedRenderBatches.shift(),W=v.style.order,ee=[];this._updateFBOs(v.emissiveMode==="mrt-fallback");let ae=0;for(const le of F){const we=D.getTileByID(le.proxyTileKey),be=D.proxyCachedFBO[le.key]?D.proxyCachedFBO[le.key][h]:void 0,Ne=be!==void 0?D.renderCache[be]:this.pool[ae++],Re=be!==void 0;if(we.texture=Ne.tex,we.emissiveTexture=Ne.emissiveTex,Re&&!Ne.dirty){ee.push(we.tileID);continue}A.bindFramebuffer.set(Ne.fb.framebuffer);const Ie=A.gl;let Ze;Ie.drawBuffers(v.emissiveMode==="mrt-fallback"?[Ie.COLOR_ATTACHMENT0,Ie.COLOR_ATTACHMENT1]:[Ie.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Ne.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),Ne.dirty=!1);for(let Ve=B.start;Ve<=B.end;++Ve){const at=v.style._mergedLayers[W[Ve]];if(at.isHidden(v.transform.zoom))continue;const ht=v.style.getLayerSourceCache(at),ot=ht?this.proxyToSource[le.key][ht.id]:[le];if(!ot)continue;const At=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),Ze!==(ht?ht.id:null)&&(this._setupStencil(Ne,ot,at,ht),Ze=ht?ht.id:null),v.renderLayer(v,ht,at,At)}if(Ie.drawBuffers([Ie.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Ve of this._pendingGroundEffectLayers){const at=v.style._mergedLayers[W[Ve]];if(at.isHidden(v.transform.zoom))continue;const ht=v.style.getLayerSourceCache(at),ot=ht?this.proxyToSource[le.key][ht.id]:[le];if(!ot)continue;const At=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),Ze!==(ht?ht.id:null)&&(this._setupStencil(Ne,ot,at,ht),Ze=ht?ht.id:null),v.renderLayer(v,ht,at,At)}this.renderedToTile?(Ne.dirty=!0,ee.push(we.tileID)):Re||--ae,ae===5&&(ae=0,this.renderToBackBuffer(ee))}return this.renderToBackBuffer(ee),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,v.width,v.height]),B.end+1}postRender(){}isLayerOrderingCorrect(h){const v=h.order.length;let A=-1,D=v;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(v=>v.dem).forEach(v=>{h=Math.min(h,v.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,v,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const B=F.tileID,W=1<(F.t!==null?F.t:Number.MAX_VALUE)-(B.t!==null?B.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const B=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,v,A);if(B!=null)return B}return null}_createFBO(){const h=this.painter.context,v=h.gl,A=this.drapeBufferSize;h.activeTexture.set(v.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},v.RGBA8);D.bind(v.LINEAR,v.CLAMP_TO_EDGE);const F=h.createFramebuffer(A[0],A[1],1,null);let B;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(B=new i.T(h,{width:A[0],height:A[1],data:null},v.R8),B.bind(v.LINEAR,v.CLAMP_TO_EDGE),F.createColorAttachment(h,1),F.colorAttachment1.set(B.texture)),F.depthAttachment=new iF(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&&v.texParameterf(v.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:B,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const v of this.pool)this._updateFBO(v,h);for(const v of this.proxySourceCache.renderCache)this._updateFBO(v,h);this._emissiveTexture=h}}_updateFBO(h,v){const A=h.fb,D=this.painter.context,F=D.gl,B=this.drapeBufferSize;if(v){const W=new i.T(D,{width:B[0],height:B[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 v=this._style._mergedLayers[h],A=v.isHidden(this.painter.transform.zoom);return v.type==="hillshade"||v.type==="custom"?!A&&v.shouldRedrape():!A&&v.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof $f){h=!0;break}if(!h)return;const v={};for(let A=0;Aee>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 v=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,v.renderCache.length>v.renderCachePool.length){const B=Object.values(v.proxyCachedFBO);v.proxyCachedFBO={};for(let W=0;W=0;B--){const W=A[B];if(v.getTileByID(W.key),v.proxyCachedFBO[W.key]!==void 0){const ee=h[W.key],ae=this.proxyToSource[W.key];let le=0;for(const we in ae){const be=ae[we],Ne=ee[we];if(!Ne||Ne.length!==be.length||be.some((Re,Ie)=>Re!==Ne[Ie]||D[we]&&D[we].hasOwnProperty(Re.key))){le=-1;break}++le}for(const we in v.proxyCachedFBO[W.key])v.renderCache[v.proxyCachedFBO[W.key][we]].dirty=le<0||le!==Object.values(ee).length}}const F=[...this._drapedRenderBatches];F.sort((B,W)=>W.end-W.start-(B.end-B.start));for(const B of F)for(const W of A){if(v.proxyCachedFBO[W.key])continue;let ee=v.renderCachePool.pop();ee===void 0&&v.renderCache.length<50&&(ee=v.renderCache.length,v.renderCache.push(this._createFBO())),ee!==void 0&&(v.proxyCachedFBO[W.key]={},v.proxyCachedFBO[W.key][B.start]=ee,v.renderCache[ee].dirty=!0)}this._tilesDirty={}}_setupStencil(h,v,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,B=F.gl;if(v.length<=1)return void(this._overlapStencilType=!1);let W;if(A.isTileClipped())W=v.length,this._overlapStencilMode.test={func:B.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(v[0].overscaledZ>v[v.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:B.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(v,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):bn.disabled}_renderTileClippingMasks(h,v){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(Gn.disabled),D.setDepthMode(Br.disabled);const B=A.getOrCreateProgram("clippingMask");for(const W of h){const ee=A._tileClippingMaskIDs[W.key]=--v;B.draw(A,F.TRIANGLES,Br.disabled,new bn({func:F.ALWAYS,mask:0},ee,255,F.KEEP,F.KEEP,F.REPLACE),Gn.disabled,gn.disabled,m2(W.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const v=this.painter.transform;if(h.x<0||h.x>v.width||h.y<0||h.y>v.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,v.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=v.worldSize,A[1]/=v.worldSize;const D=v._camera.position,F=i.cf(1,v.center.lat),B=[D[0],D[1],D[2]/F,0],W=i.da([],A.slice(0,3),B);i.aw(W,W);const ee=this.raycast(B,W,this._exaggeration);return ee!==null&&ee?(i.bH(B,B,W,ee),B[3]=B[2],B[2]*=F,B):null}_setupProxiedCoordsForOrtho(h,v,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,v,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let ee=0;eele.overscaledZ-ae.overscaledZ)}_setupProxiedCoordsForImageSource(h,v,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,B=h.getSource(),W=B.tileID;if(!W)return;const ee=new i.P(W.x,W.y)._div(1<(we.min.x=Math.min(we.min.x,be.x-ee.x),we.min.y=Math.min(we.min.y,be.y-ee.y),we.max.x=Math.max(we.max.x,be.x-ee.x),we.max.y=Math.max(we.max.y,be.y-ee.y),we),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),le=(we,be)=>{const Ne=we.wrap+we.canonical.x/(1<Ze+ae.max.x||Re+IeVe+ae.max.y};for(let we=0;weB.key===v.tileID.key);if(F)return F}if(v.tileID.key!==h.key){const F=h.canonical.z-v.tileID.canonical.z;let B,W,ee;D=i.bC();const ae=v.tileID.wrap-h.wrap<0?(B=i.al>>F,W=B*((v.tileID.canonical.x<=we){const be=h.canonical.z-we;v.getSource().reparseOverscaled?(W=Math.max(h.canonical.z+2,v.transform.tileZoom),B=new i.aQ(W,h.wrap,we,h.canonical.x>>be,h.canonical.y>>be)):be!==0&&(W=we,B=new i.aQ(W,h.wrap,we,h.canonical.x>>be,h.canonical.y>>be))}B.key!==h.key&&(ae.push(B.key),A=v.getTile(B))}const le=we=>{ae.forEach(be=>{D[be]=we}),ae.length=0};for(W-=1;W>=ee&&(!A||!A.hasData());W--){A&&le(A.tileID.key);const we=B.calculateScaledKey(W);if(A=v.getTileByID(we),A&&A.hasData())break;const be=D[we];if(be===null)break;be===void 0?ae.push(we):A=v.getTileByID(be)}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,v){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[v.key]=!0}}function xb(T,h,v){const A=function(W,ee,ae){const le=i.bJ(ee,W),we=i.bJ(ae,[.2126,.7152,.0722]),be=(Re,Ie,Ze)=>(1-Ze)*Re+Ze*Ie,Ne=be(1-.3*Math.min(we,1),1,Math.min(le+1,1));return be(.92,1,Math.asin(i.aA(ee[2],-1,1))/Math.PI+.5)*Ne}(T,[0,0,1],h),D=[0,0,0];i.c5(D,v.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),T[2]);const B=[0,0,0];return i.d8(B,D,F),i.db(B)}const Xme=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Jme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class oF{static cacheKey(h,v,A,D){const F=[v];D&&F.push(D.cacheKey);for(const B of A)h.usedDefines.has(B)&&F.push(B);return F.join("/")}constructor(h,v,A,D,F,B){const W=h.gl;this.program=W.createProgram(),this.configuration=D,this.name=v,this.fixedDefines=[...B];const ee=`#version 300 es ${(D?D.defines():[]).concat(B.map(Ie=>`#define ${Ie}`)).join(` `)}`,ae=[ee,Ume];for(const Ie of A.fragmentIncludes)ae.push(Ty[Ie]);ae.push(A.fragmentSource);const le=ae.join(` `),we=[ee,QR];for(const Ie of A.vertexIncludes)we.push(Ty[Ie]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&we.push("uniform int u_instanceID;"),we.push(A.vertexSource);let be=we.join(` `);this.forceManualRenderingForInstanceIDShaders&&(be=be.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 Re=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(Re,be),W.compileShader(Re),W.attachShader(this.program,Re),this.attributes={},W.linkProgram(this.program),W.deleteShader(Re),W.deleteShader(Ne),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ie=>({u_instanceID:new i.ch(Ie)}))(h)),(B.includes("TERRAIN")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(Ie=>({u_dem:new i.ch(Ie),u_dem_prev:new i.ch(Ie),u_dem_tl:new i.ck(Ie),u_dem_scale:new i.cj(Ie),u_dem_tl_prev:new i.ck(Ie),u_dem_scale_prev:new i.cj(Ie),u_dem_size:new i.cj(Ie),u_dem_lerp:new i.cj(Ie),u_exaggeration:new i.cj(Ie),u_depth:new i.ch(Ie),u_depth_size_inv:new i.ck(Ie),u_depth_range_unpack:new i.ck(Ie),u_occluder_half_size:new i.cj(Ie),u_occlusion_depth_offset:new i.cj(Ie),u_meter_to_dem:new i.cj(Ie),u_label_plane_matrix_inv:new i.cl(Ie)}))(h)),B.includes("GLOBE")&&(this.globeUniforms=(Ie=>({u_tile_tl_up:new i.ci(Ie),u_tile_tr_up:new i.ci(Ie),u_tile_br_up:new i.ci(Ie),u_tile_bl_up:new i.ci(Ie),u_tile_up_scale:new i.cj(Ie)}))(h)),B.includes("FOG")&&(this.fogUniforms=(Ie=>({u_fog_matrix:new i.cl(Ie),u_fog_range:new i.ck(Ie),u_fog_color:new i.d3(Ie),u_fog_horizon_blend:new i.cj(Ie),u_fog_vertical_limit:new i.ck(Ie),u_fog_temporal_offset:new i.cj(Ie),u_frustum_tl:new i.ci(Ie),u_frustum_tr:new i.ci(Ie),u_frustum_br:new i.ci(Ie),u_frustum_bl:new i.ci(Ie),u_globe_pos:new i.ci(Ie),u_globe_radius:new i.cj(Ie),u_globe_transition:new i.cj(Ie),u_is_globe:new i.ch(Ie),u_viewport:new i.ck(Ie)}))(h)),B.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ie=>({u_cutoff_params:new i.d3(Ie)}))(h)),B.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ie=>({u_lighting_ambient_color:new i.ci(Ie),u_lighting_directional_dir:new i.ci(Ie),u_lighting_directional_color:new i.ci(Ie),u_ground_radiance:new i.ci(Ie)}))(h)),B.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ie=>({u_light_matrix_0:new i.cl(Ie),u_light_matrix_1:new i.cl(Ie),u_fade_range:new i.ck(Ie),u_shadow_normal_offset:new i.ci(Ie),u_shadow_intensity:new i.cj(Ie),u_shadow_texel_size:new i.cj(Ie),u_shadow_map_resolution:new i.cj(Ie),u_shadow_direction:new i.ci(Ie),u_shadow_bias:new i.ci(Ie),u_shadowmap_0:new i.ch(Ie),u_shadowmap_1:new i.ch(Ie)}))(h)))}getAttributeLocation(h,v){let A=this.attributes[v];return A===void 0&&(A=this.attributes[v]=h.getAttribLocation(this.program,v)),A}setTerrainUniformValues(h,v){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in v)A[D]&&A[D].set(this.program,D,v[D])}}setGlobeUniformValues(h,v){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in v)A[D]&&A[D].set(this.program,D,v[D])}}setFogUniformValues(h,v){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setCutoffUniformValues(h,v){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setLightsUniformValues(h,v){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setShadowUniformValues(h,v){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}_drawDebugWireframe(h,v,A,D,F,B,W,ee,ae,le){const we=h.options.wireframe;if(we.terrain===!1&&we.layers2D===!1&&we.layers3D===!1)return;const be=h.context;if(!(!(!we.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!we.layers2D||h._terrain&&h._terrain.renderingToTexture||!Xme.includes(this.name))||!(!we.layers3D||!Jme.includes(this.name))))return;const Ne=be.gl,Re=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,be);if(!Re)return;const Ie=[...this.fixedDefines,"DEBUG_WIREFRAME"],Ze=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ie});be.program.set(Ze.program);const Ve=(ot,At,Nt)=>{if(At[ot]&&Nt[ot])for(const Ct in At[ot])Nt[ot][Ct]&&Nt[ot][Ct].set(Nt.program,Ct,At[ot][Ct].current)};ae&&ae.setUniforms(Ze.program,be,Ze.binderUniforms,W,{zoom:ee}),Ve("fixedUniforms",this,Ze),Ve("terrainUniforms",this,Ze),Ve("globeUniforms",this,Ze),Ve("fogUniforms",this,Ze),Ve("lightsUniforms",this,Ze),Ve("shadowUniforms",this,Ze),Re.bind(),be.setColorMode(new Gn([Ne.ONE,Ne.ONE_MINUS_SRC_ALPHA,Ne.ZERO,Ne.ONE],i.ao.transparent,[!0,!0,!0,!1])),be.setDepthMode(new Br(v.func===Ne.LESS?Ne.LEQUAL:v.func,Br.ReadOnly,v.range)),be.setStencilMode(bn.disabled);const at=3*B.primitiveLength*2,ht=3*B.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const ot=le||1;for(let At=0;At1?Ne.drawElementsInstanced(Ne.LINES,at,Ne.UNSIGNED_SHORT,ht,le):Ne.drawElements(Ne.LINES,at,Ne.UNSIGNED_SHORT,ht);F.bind(),be.program.set(this.program),be.setDepthMode(v),be.setStencilMode(A),be.setColorMode(D)}checkUniforms(h,v,A){if(this.fixedDefines.includes(v)){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 ${v} being defined`)}}draw(h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze){const Ve=h.context,at=Ve.gl;if(this.failedToCreate)return;Ve.program.set(this.program),Ve.setDepthMode(A),Ve.setStencilMode(D),Ve.setColorMode(F),Ve.setCullFace(B);for(const[wt,gt]of this.fixedUniformsEntries)gt.set(this.program,wt,W[wt]);Re&&Re.setUniforms(this.program,Ve,this.binderUniforms,be,{zoom:Ne});const ht={[at.POINTS]:1,[at.LINES]:2,[at.TRIANGLES]:3,[at.LINE_STRIP]:1}[v];this.checkUniforms(ee,"RENDER_SHADOWS",this.shadowUniforms);const ot=Ie||[],At=Re?Re.getPaintVertexBuffers():[],Nt=v===at.TRIANGLES&&le,Ct=Ze&&Ze>0?1:void 0;for(const wt of we.get()){const gt=wt.vaos||(wt.vaos={});if((gt[ee]||(gt[ee]=new Vme)).bind(Ve,this,ae,At,le,wt.vertexOffset,ot,Ct),this.forceManualRenderingForInstanceIDShaders){const Dt=Ze||1;for(let Ht=0;Ht1?at.drawElementsInstanced(v,wt.primitiveLength*ht,at.UNSIGNED_SHORT,wt.primitiveOffset*ht*2,Ze):le?at.drawElements(v,wt.primitiveLength*ht,at.UNSIGNED_SHORT,wt.primitiveOffset*ht*2):at.drawArrays(v,wt.vertexOffset,wt.vertexLength);Nt&&this._drawDebugWireframe(h,A,D,F,le,wt,be,Ne,Re,Ze)}}}function lF(T,h,v=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),B=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,B>>16],u_pixel_coord_lower:[65535&F,65535&B],u_pattern_transition:v}}const vC={terrain:0,flat:1},epe=i.bC(),bC=(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve)=>{const at=h.style.light,ht=at.properties.get("position"),ot=[ht.x,ht.y,ht.z],At=i.dO();at.properties.get("anchor")==="viewport"&&(i.dP(At,-h.transform.angle),i.dQ(ot,ot,At));const Nt=at.properties.get("color").toPremultipliedRenderColor(null),Ct=h.transform,wt={u_matrix:T,u_lightpos:ot,u_lightintensity:at.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_vertical_gradient:+v,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:epe,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:vC[ae],u_base_type:vC[le],u_ao:D,u_edge_radius:F,u_width_scale:B,u_flood_light_color:Re,u_vertical_scale:Ie,u_flood_light_intensity:Ze,u_ground_shadow_factor:Ve};return Ct.projection.name==="globe"&&(wt.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:T,u_edge_radius:h,u_width_scale:v,u_vertical_scale:A,u_height_type:vC[D],u_base_type:vC[F]}),cF=(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve)=>{const at=bC(T,h,v,A,D,F,B,W,ae,le,we,be,Ne,Re,Ie,Ze,1,[0,0,0]),ht={u_height_factor:-Math.pow(2,W.overscaledZ)/ee.tileSize/8};return Object.assign(at,lF(h,ee,Ve),ht)},gb=(T,h,v,A,D,F,B,W,ee,ae,le)=>({u_matrix:h,u_opacity:v,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:B,u_flood_light_color:W,u_attenuation:ee,u_edge_radius:ae,u_fb:0,u_fb_size:le,u_dynamic_offset:1}),A6=(T,h,v)=>({u_matrix:T,u_emissive_strength:h,u_ground_shadow_factor:v}),E6=(T,h,v,A,D,F=0)=>Object.assign(A6(T,h,D),lF(v,A,F)),dF=(T,h,v,A)=>({u_matrix:T,u_world:v,u_emissive_strength:h,u_ground_shadow_factor:A}),P6=(T,h,v,A,D,F,B=0)=>Object.assign(E6(T,h,v,A,F,B),{u_world:D}),Ey=(T,h)=>({u_matrix:T,u_ground_shadow_factor:h}),hv=(T,h,v,A,D)=>({u_matrix:T,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:v,u_height_scale:A,u_reset_depth:D}),_C=(T,h,v,A,D,F,B,W,ee)=>({u_matrix:T,u_normal_matrix:h,u_opacity:v,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:B,u_flood_light_color:W,u_flood_light_intensity:ee}),uF=T=>({u_matrix:T}),Py=T=>({u_matrix:T}),I6=(T,h,v,A,D,F,B,W)=>{const ee=i.al/F.tileSize;return{u_matrix:T,u_inv_rot_matrix:h,u_camera_to_center_distance:v.getCameraToCenterDistance(W),u_extrude_scale:[v.pixelsToGLUnits[0]/ee,v.pixelsToGLUnits[1]/ee],u_zoom_transition:A,u_tile_id:B,u_merc_center:D}},f2=(T,h,v=1)=>({u_matrix:T,u_color:h,u_overlay:0,u_overlay_scale:v}),hF=i.bC(),mF=(T,h,v,A,D,F,B)=>{const W=T.transform,ee=W.projection.name==="globe",ae=ee?i.dR(W.zoom,h.canonical)*W._pixelsPerMercatorPixel:i.ay(v,1,F),le={u_matrix:h.projMatrix,u_extrude_scale:ae,u_intensity:B,u_inv_rot_matrix:hF,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(ee){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:v,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:le.mix,u_opacity:le.opacity*we.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:we.paint.get("raster-brightness-min"),u_brightness_high:we.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(we.paint.get("raster-saturation")),u_contrast_factor:i.dS(we.paint.get("raster-contrast")),u_spin_weights:fF(we.paint.get("raster-hue-rotate")),u_perspective_transform:be,u_raster_elevation:Ne,u_zoom_transition:B,u_merc_center:W,u_cutoff_params:ee,u_colorization_mix:wC(i.dU,Ie,Ve),u_colorization_offset:jC(i.dU,Ze,Ve),u_color_ramp:Re,u_texture_offset:[ht/(at+2*ht),at/(at+2*ht)],u_texture_res:[at+2*ht,at+2*ht],u_emissive_strength:ot});function fF(T){T*=Math.PI/180;const h=Math.sin(T),v=Math.cos(T);return[(2*v+1)/3,(-Math.sqrt(3)*h-v+1)/3,(Math.sqrt(3)*h-v+1)/3]}const Kf=.05,tpe=(T,h,v,A,D,F,B,W,ee,ae,le,we)=>({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:v,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:le.mix,u_opacity:le.opacity,u_image0:0,u_image1:1,u_raster_elevation:we,u_zoom_transition:B,u_merc_center:W,u_cutoff_params:ee}),spe=(T,h,v,A,D,F,B,W,ee,ae)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_tile_offset:v,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:B,u_uv_offset:W,u_data_scale:[255*ee[0],255*ee[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Kf,Kf]}),xF=(T,h,v,A,D,F,B,W,ee,ae)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_velocity:v,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:B,u_rand_seed:Math.random(),u_uv_offset:W,u_data_scale:[255*ee[0],255*ee[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Kf,Kf]}),gF=i.bC(),NC=(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve,at,ht,ot,At,Nt,Ct)=>{const wt=D.transform,gt={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(at),u_rotate_symbol:+v,u_aspect_ratio:wt.width/wt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:B,u_coord_matrix:W,u_is_text:+ae,u_elevation_from_sea:ee?1:0,u_pitch_with_map:+A,u_texsize:le,u_texsize_icon:we,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:gF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:gF,u_up_vector:[0,-1,0],u_color_adj_mat:At,u_icon_transition:Nt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(at)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Ct||1,u_ground_shadow_factor:ht,u_inv_matrix:i.bl(i.bC(),B),u_normal_scale:ot,u_lutTexture:Kc.LUT};return at.name==="globe"&&(gt.u_tile_id=[Ne.canonical.x,Ne.canonical.y,1<({u_matrix:T,u_emissive_strength:h,u_opacity:v,u_color:A}),Iy=(T,h,v,A,D,F,B,W,ee)=>Object.assign(function(ae,le,we,be,Ne,Re){const{width:Ie,height:Ze}=be.imageManager.getPixelSize(le),Ve=Math.pow(2,Re.tileID.overscaledZ),at=Re.tileSize*Math.pow(2,be.transform.tileZoom)/Ve,ht=at*(Re.tileID.canonical.x+Re.tileID.wrap*Ve),ot=at*Re.tileID.canonical.y;return{u_image:0,u_pattern_tl:we.tl,u_pattern_br:we.br,u_texsize:[Ie,Ze],u_pattern_size:we.displaySize,u_pattern_units_to_pixels:Ne?[be.transform.width,-1*be.transform.height]:[1/i.ay(Re,1,be.transform.tileZoom),1/i.ay(Re,1,be.transform.tileZoom)],u_pixel_coord_upper:[ht>>16,ot>>16],u_pixel_coord_lower:[65535&ht,65535&ot]}}(0,F,B,A,W,ee),{u_matrix:T,u_emissive_strength:h,u_opacity:v}),yb=new Float32Array(i.bA([])),mv=(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne=[0,0,0],Re,Ie,Ze)=>{const Ve=D.style.light,at=Ve.properties.get("position"),ht=[-at.x,-at.y,at.z],ot=i.dO();Ve.properties.get("anchor")==="viewport"&&(i.dP(ot,-D.transform.angle),i.dQ(ht,ht,ot));const At=le.alphaMode==="MASK",Nt=Ve.properties.get("color").toNonPremultipliedRenderColor(null),Ct=be.paint.get("model-ambient-occlusion-intensity"),wt=be.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return wt.a=be.paint.get("model-color-mix-intensity").constantOr(0),Ze&&(wt.r=Ze[0],wt.g=Ze[1],wt.b=Ze[2],wt.a=Ze[3]),Ie&&(wt.r=Ie.color.r,wt.g=Ie.color.g,wt.b=Ie.color.b,wt.a=Ie.colorMix,we=Ie.emissionStrength,F*=Ie.opacity),{u_matrix:T,u_lighting_matrix:h,u_normal_matrix:v,u_node_matrix:A||yb,u_lightpos:ht,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:+At,u_alphaCutoff:le.alphaCutoff,u_baseColorFactor:B.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:ee,u_roughnessFactor:ae,u_baseColorTexture:Kc.BaseColor,u_metallicRoughnessTexture:Kc.MetallicRoughness,u_normalTexture:Kc.Normal,u_occlusionTexture:Kc.Occlusion,u_emissionTexture:Kc.Emission,u_lutTexture:Kc.LUT,u_color_mix:wt.toArray01(),u_aoIntensity:Ct,u_emissive_strength:we,u_occlusionTextureTransform:Re||[0,0,0,0]}},L6=(T,h=yb,v=yb)=>({u_matrix:T,u_instance:h,u_node_matrix:v}),kC={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 qp{constructor(h,v,A,D){this.id=qp.uniqueIdxCounter,qp.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,v.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||v.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=qp.uniqueIdxCounter,qp.uniqueIdxCounter++;const v=this.context.gl;this.context.unbindVAO(),this.bind(),v.bufferSubData(v.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}qp.uniqueIdxCounter=0;const D6={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class yF{constructor(h,v,A,D,F,B){this.length=v.length,this.attributes=A,this.itemSize=v.bytesPerElement,this.dynamicDraw=D,this.instanceCount=B,this.context=h;const W=h.gl;this.buffer=W.createBuffer(),h.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.STATIC_DRAW),this.dynamicDraw||F||v.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const v=this.context.gl;this.bind(),v.bufferSubData(v.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,v){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class vF{constructor(h,v,A,D,F){this.context=h,this.width=v,this.height=A;const B=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new pC(h,B,0)),D>1&&(this.colorAttachment1=new pC(h,B,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new pb(h,B):new u2(h,B))}createColorAttachment(h,v){v===0?this.colorAttachment0=new pC(h,this.framebuffer,0):v===1&&(this.colorAttachment1=new pC(h,this.framebuffer,1))}removeColorAttachment(h,v){const A=this.context.gl;let D;v===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):v===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const v=this.colorAttachment0.get();v&&h.deleteTexture(v)}if(this.colorAttachment1){const v=this.colorAttachment1.get();v&&h.deleteTexture(v)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const v=this.depthAttachment.get();v&&h.deleteRenderbuffer(v)}else{const v=this.depthAttachment.get();v&&h.deleteTexture(v)}h.deleteFramebuffer(this.framebuffer)}}class vb{constructor(h,v){this.gl=h,this.clearColor=new Kme(this),this.clearDepth=new XR(this),this.clearStencil=new g6(this),this.colorMask=new cC(this),this.depthMask=new y6(this),this.stencilMask=new uv(this),this.stencilFunc=new db(this),this.stencilOp=new c2(this),this.stencilTest=new ub(this),this.depthRange=new JR(this),this.depthTest=new v6(this),this.depthFunc=new eF(this),this.blend=new hb(this),this.blendFunc=new dC(this),this.blendColor=new uC(this),this.blendEquation=new b6(this),this.cullFace=new hC(this),this.cullFaceSide=new d2(this),this.frontFace=new tF(this),this.program=new sF(this),this.activeTexture=new rF(this),this.viewport=new mb(this),this.bindFramebuffer=new nF(this),this.bindRenderbuffer=new Zme(this),this.bindTexture=new Yme(this),this.bindVertexBuffer=new Qme(this),this.bindElementBuffer=new _6(this),this.bindVertexArrayOES=new w6(this),this.pixelStoreUnpack=new j6(this),this.pixelStoreUnpackPremultiplyAlpha=new N6(this),this.pixelStoreUnpackFlipY=new aF(this),this.options=v?Object.assign({},v):{},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=v&&!!v.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,v,A){return new qp(this,h,v,A)}createVertexBuffer(h,v,A,D,F){return new yF(this,h,v,A,D,F)}createRenderbuffer(h,v,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,v,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,v,A,D){return new vF(this,h,v,A,D)}clear({color:h,depth:v,stencil:A,colorMask:D}){const F=this.gl;let B=0;h&&(B|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),v!==void 0&&(B|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(v),this.depthMask.set(!0)),A!==void 0&&(B|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),F.clear(B)}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,Gn.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 pv;function Cr(T,h,v,A,D,F,B){const W=T.context,ee=W.gl,ae=T.transform,le=[i.aF(ae.center.lng),i.aJ(ae.center.lat)],we=v.layout.get("symbol-placement"),be=v.layout.get("text-variable-anchor"),Ne=v.layout.get("icon-rotation-alignment")==="map",Re=v.layout.get("text-rotation-alignment")==="map",Ie=we!=="point",Ze=[];let Ve=0,at=0;for(let gt=0;gt0){const pr=i.bC(),wr=er;i.cP(pr,Ut.placementInvProjMatrix,ae.glCoordMatrix),i.cP(pr,pr,Ut.placementViewportMatrix),Ze.push({circleArray:Dr,circleOffset:at,transform:wr,invTransform:pr,projection:Ut.getProjection()}),Ve+=Dr.length/4,at=Ve}if(!Zs)continue;T.terrain&&T.terrain.setupElevationDraw(Ht,br);const Pr=zs?[Dt.canonical.x,Dt.canonical.y,1<=0&&(Ne[ht.associatedIconIndex]={x:Ut,y:es,z:ts,angle:is})}else zp(Nt,we)}if(ae){be.clear();const at=T.icon.placedSymbolArray;for(let ht=0;ht{let Va=[0,0,0];if(fi){const Zn=T.style.directionalLight,eo=T.style.ambientLight;Zn&&eo&&(Va=ag(T.style,Zn,eo))}return Va},ei=fi=>{gt.depthOcclusionForSymbolsAndCircles&&(v.hasOcclusionOpacityProperties||T.terrain)&&(fi.push("DEPTH_D24"),fi.push("DEPTH_OCCLUSION"))},En=fi=>{v.lut&&!Nt&&(v.lut.texture||(v.lut.texture=new i.d$(T.context,v.lut.image,[v.lut.image.height,v.lut.image.height,v.lut.image.height],Ct.gl.RGBA8)),Ct.activeTexture.set(Ct.gl.TEXTURE0+Kc.LUT),v.lut.texture&&v.lut.texture.bind(Ct.gl.LINEAR,Ct.gl.CLAMP_TO_EDGE),fi.push("APPLY_LUT_ON_GPU"))},pi=()=>{const fi=Dt&&v.layout.get("symbol-placement")!=="point",Va=[];ei(Va),En(Va);const Zn=fi||On,eo=Zs.elevationType==="road",Ko=T.shadowRenderer,ko=eo&&Ut&&!!Ko&&Ko.enabled,Ri=Fr(ko),Vu=eo&&Ut&&!T.terrain?Yt:Ks,Ed=v.paint.get("icon-image-cross-fade");T.terrainRenderModeElevated()&&Ut&&Va.push("PITCH_WITH_MAP_TERRAIN"),Dr&&(Va.push("PROJECTION_GLOBE_VIEW"),Zn&&Va.push("PROJECTED_POS_ON_VIEWPORT")),Ed>0&&Zs.hasAnySecondaryIcon&&Va.push("ICON_TRANSITION"),!Zs.icon.zOffsetVertexBuffer||eo&&T.terrain||Va.push("Z_OFFSET"),Ve===0&&at===0&&ht===0&&ot===1||Va.push("COLOR_ADJUSTMENT"),Zs.sdfIcons&&Va.push("RENDER_SDF"),ko&&Va.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),eo&&Ut&&!T.terrain&&Zs.icon.orientationVertexBuffer&&Va.push("ELEVATED_ROADS");const Kl=Zs.icon.programConfigurations.get(v.id),Wd=T.getOrCreateProgram("symbol",{config:Kl,defines:Va}),Kd=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ld=Zs.iconSizeData,gm=i.bK(ld,gt.zoom),ip=Ut||!gt.isOrthographic,xh=Js(pr,er.tileID.canonical,Ut,Dt,gt,Zs.getProjection(),wr),Ro=vn(pr,er.tileID.canonical,Ut,Dt,gt,Zs.getProjection(),wr),nl=T.translatePosMatrix(Ro,er,W,ae,!0),Fi=T.translatePosMatrix(pr,er,W,ae),xl=Zn?g2:xh,Ao=Dt&&!Ut&&!fi;let So=ir;!Jt&&!gt.mercatorFromTransition||Dt||(So=og(gt));const op=Dr?So:ir,A2=v.getColorAdjustmentMatrix(Ve,at,ht,ot),Hp=NC(ld.kind,gm,Ao,Ut,T,Fi,xl,nl,At,!1,Kd,[0,0],0,br,Pr,zt,Sa,op,Zs.getProjection(),Ri,oi,A2,Ed,null),E2=er.imageAtlasTexture?er.imageAtlasTexture:null,Mb=v.layout.get("icon-size").constantOr(0)!==1||Zs.iconsNeedLinear,Jf=Zs.sdfIcons||T.options.rotating||T.options.zooming||Mb||ip?wt.LINEAR:wt.NEAREST,xg=Zs.sdfIcons&&v.paint.get("icon-halo-width").constantOr(1)!==0,Tb=T.terrain&&Ut&&fi?i.bl(i.bC(),xh):g2;if(fi&&Zs.icon){const zy=i.bV.getAtTileOffsetFunc(br,gt.center.lat,gt.worldSize,Zs.getProjection()),gg=yn(pr,er.tileID.canonical,Ut,Dt,gt,Zs.getProjection(),wr),Gp=v.layout.get("icon-size-scale-range"),yg=i.aA(T.scaleFactor,Gp[0],Gp[1]);sg(Zs,pr,T,!1,gg,Ro,Ut,Ie,zy,br,yg)}return{program:Wd,buffers:Zs.icon,uniformValues:Hp,atlasTexture:E2,atlasTextureIcon:null,atlasInterpolation:Jf,atlasInterpolationIcon:null,isSDF:Zs.sdfIcons,hasHalo:xg,depthMode:Vu,tile:er,renderWithShadows:ko,labelPlaneMatrixInv:Tb}},Ti=()=>{const fi=Ht&&v.layout.get("symbol-placement")!=="point",Va=[],Zn=fi||is||On,eo=Zs.elevationType==="road",Ko=T.shadowRenderer,ko=eo&&es&&!!Ko&&Ko.enabled,Ri=Fr(ko),Vu=eo&&es&&!T.terrain?Yt:Ks;T.terrainRenderModeElevated()&&es&&Va.push("PITCH_WITH_MAP_TERRAIN"),Dr&&(Va.push("PROJECTION_GLOBE_VIEW"),Zn&&Va.push("PROJECTED_POS_ON_VIEWPORT")),!Zs.text.zOffsetVertexBuffer||eo&&T.terrain||Va.push("Z_OFFSET"),Zs.iconsInText&&Va.push("RENDER_TEXT_AND_SYMBOL"),Va.push("RENDER_SDF"),ko&&Va.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),eo&&es&&!T.terrain&&Zs.text.orientationVertexBuffer&&Va.push("ELEVATED_ROADS"),ei(Va);const Ed=Zs.text.programConfigurations.get(v.id),Kl=T.getOrCreateProgram("symbol",{config:Ed,defines:Va});let Wd,Kd=[0,0],ld=null;const gm=Zs.textSizeData;Zs.iconsInText&&(Kd=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ld=er.imageAtlasTexture?er.imageAtlasTexture:null,Wd=es||!gt.isOrthographic||T.options.rotating||T.options.zooming||gm.kind==="composite"||gm.kind==="camera"?wt.LINEAR:wt.NEAREST);const ip=er.glyphAtlasTexture?er.glyphAtlasTexture.size:[0,0],xh=v.layout.get("text-size-scale-range"),Ro=i.aA(T.scaleFactor,xh[0],xh[1]),nl=i.bK(gm,gt.zoom,Ro),Fi=Js(pr,er.tileID.canonical,es,Ht,gt,Zs.getProjection(),wr),xl=vn(pr,er.tileID.canonical,es,Ht,gt,Zs.getProjection(),wr),Ao=T.translatePosMatrix(xl,er,ee,le,!0),So=T.translatePosMatrix(pr,er,ee,le),op=Zn?g2:Fi,A2=Ht&&!es&&!fi;let Hp=ir;!Jt&&!gt.mercatorFromTransition||Ht||(Hp=og(gt));const E2=NC(gm.kind,nl,A2,es,T,So,op,Ao,At,!0,ip,Kd,0,br,Pr,zt,Sa,Dr?Hp:ir,Zs.getProjection(),Ri,oi,null,null,Ro),Mb=er.glyphAtlasTexture?er.glyphAtlasTexture:null,Jf=wt.LINEAR,xg=v.paint.get("text-halo-width").constantOr(1)!==0,Tb=T.terrain&&es&&fi?i.bl(i.bC(),Fi):g2;if(fi&&Zs.text){const zy=i.bV.getAtTileOffsetFunc(br,gt.center.lat,gt.worldSize,Zs.getProjection()),gg=yn(pr,er.tileID.canonical,es,Ht,gt,Zs.getProjection(),wr);sg(Zs,pr,T,!0,gg,xl,es,Ze,zy,br,Ro)}return{program:Kl,buffers:Zs.text,uniformValues:E2,atlasTexture:Mb,atlasTextureIcon:ld,atlasInterpolation:Jf,atlasInterpolationIcon:Wd,isSDF:!0,hasHalo:xg,depthMode:Vu,tile:er,renderWithShadows:ko,labelPlaneMatrixInv:Tb}},ji=Zs.icon.segments.get().length,Xa=Zs.text.segments.get().length,Kn=ji&&!B.onlyText?pi():null,hi=Xa&&!B.onlyIcons?Ti():null,To=v.paint.get("icon-opacity").constantOr(1),oo=v.paint.get("text-opacity").constantOr(1);if(ts&&Zs.canOverlap){_s=!0;const fi=To&&!B.onlyText?Zs.icon.segments.get():[],Va=oo&&!B.onlyIcons?Zs.text.segments.get():[];for(const Zn of fi)zs.push({segments:new i.bg([Zn]),sortKey:Zn.sortKey,state:Kn});for(const Zn of Va)zs.push({segments:new i.bg([Zn]),sortKey:Zn.sortKey,state:hi})}else B.onlyText||zs.push({segments:To?Zs.icon.segments:new i.bg([]),sortKey:0,state:Kn}),B.onlyIcons||zs.push({segments:oo?Zs.text.segments:new i.bg([]),sortKey:0,state:hi})}_s&&zs.sort((br,er)=>br.sortKey-er.sortKey);for(const br of zs){const er=br.state;if(er)if(T.terrain?T.terrain.setupElevationDraw(er.tile,er.program,{useDepthForOcclusion:gt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:er.labelPlaneMatrixInv}):T.setupDepthForOcclusion(gt.depthOcclusionForSymbolsAndCircles,er.program),Ct.activeTexture.set(wt.TEXTURE0),er.atlasTexture&&er.atlasTexture.bind(er.atlasInterpolation,wt.CLAMP_TO_EDGE,!0),er.atlasTextureIcon&&(Ct.activeTexture.set(wt.TEXTURE1),er.atlasTextureIcon&&er.atlasTextureIcon.bind(er.atlasInterpolationIcon,wt.CLAMP_TO_EDGE,!0)),er.renderWithShadows&&T.shadowRenderer.setupShadows(er.tile.tileID.toUnwrapped(),er.program,"vector-tile"),T.uploadCommonLightUniforms(T.context,er.program),er.hasHalo){const Zs=er.uniformValues;Zs.u_is_halo=1,O6(er.buffers,br.segments,v,T,er.program,er.depthMode,D,F,Zs,2),Zs.u_is_halo=0}else{if(er.isSDF){const Zs=er.uniformValues;er.hasHalo&&(Zs.u_is_halo=1,O6(er.buffers,br.segments,v,T,er.program,er.depthMode,D,F,Zs,1)),Zs.u_is_halo=0}O6(er.buffers,br.segments,v,T,er.program,er.depthMode,D,F,er.uniformValues,1)}}}function O6(T,h,v,A,D,F,B,W,ee,ae){const le=[T.dynamicLayoutVertexBuffer,T.opacityVertexBuffer,T.iconTransitioningVertexBuffer,T.globeExtVertexBuffer,T.zOffsetVertexBuffer,T.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,B,W,gn.disabled,ee,v.id,T.layoutVertexBuffer,T.indexBuffer,h,v.paint,A.transform.zoom,T.programConfigurations.get(v.id),le,ae)}function bF(T,h){const v=1<=$p?1:Ne.pitch/$p))),2*Re}(T.transform),ae=T.transform.getFreeCameraOptions().position,le="elevatedStructuresDepthReconstruct",we=T.getOrCreateProgram(le,{defines:["DEPTH_RECONSTRUCTION"]}),be=T.getOrCreateProgram(le);for(const Ne of A){const Re=h.getTile(Ne),Ie=Re.getBucket(v);if(!Ie)continue;const Ze=Ie.elevatedStructures;if(!Ze)continue;const Ve=Ie.elevationBufferData.heightRange,at=bF(Ne.toUnwrapped(),ae),ht=T.translatePosMatrix(Ne.projMatrix,Re,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));let ot,At,Nt,Ct;if(D==="initialize"){if(!Ve||Ve.min>=1||Ze.depthSegments.segments[0].primitiveLength===0)continue;ot=hv(ht,at,ee,1,0),At=B,Nt=Ze.depthSegments,Ct=we}else if(D==="reset"){if(!Ve||Ve.min>=0||Ze.maskSegments.segments[0].primitiveLength===0)continue;ot=hv(ht,at,0,0,1),At=W,Nt=Ze.maskSegments,Ct=we}else if(D==="geometry"){if(Ze.depthSegments.segments[0].primitiveLength===0)continue;ot=hv(ht,at,ee,1,0),At=B,Nt=Ze.depthSegments,Ct=be}Ct.draw(T,F.TRIANGLES,At,bn.disabled,Gn.disabled,gn.disabled,ot,v.id,Ze.vertexBuffer,Ze.indexBuffer,Nt,v.paint,T.transform.zoom)}}function CC(T,h,v,A){const{painter:D,sourceCache:F,layer:B,coords:W,colorMode:ee,elevationType:ae,terrainEnabled:le,pass:we}=T,be=D.context.gl,Ne=B.paint.get("fill-pattern"),Re=B.paint.get("fill-pattern-cross-fade"),Ie=Ne.constantOr(null);let Ze=ae;ae!=="road"||h&&!le||(Ze="none");const Ve=Ze==="road",at=T.painter.shadowRenderer,ht=Ve&&!!at&&at.enabled,ot=new Br(D.context.gl.LEQUAL,Br.ReadOnly,D.depthRangeFor3D);let At=[0,0,0];if(ht){const gt=D.style.directionalLight,Dt=D.style.ambientLight;gt&&Dt&&(At=ag(D.style,gt,Dt))}const Nt=Ne&&Ne.constantOr(1),Ct=D.terrain&&D.terrain.renderingToTexture,wt=(gt,Dt)=>{let Ht,Ut,es,ts,_s;Dt?(Ht=Nt&&!B.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",es=be.LINES):(Ht=Nt?"fillPattern":"fill",es=be.TRIANGLES);for(const Ks of W){const Yt=F.getTile(Ks);if(Nt&&!Yt.patternsLoaded())continue;const zt=Yt.getBucket(B);if(!zt)continue;const is=h?zt.elevationBufferData:zt.bufferData;if(is.isEmpty())continue;D.prepareDrawTile();const Jt=is.programConfigurations.get(B.id),zs=D.isTileAffectedByFog(Ks),ir=[],br=[];Ve&&(ir.push("ELEVATED_ROADS"),br.push(is.elevatedLayoutVertexBuffer)),ht&&ir.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Ct&&v&&ir.push("USE_MRT1"),Nt&&(D.context.activeTexture.set(be.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let er=!1;if(Ie&&Yt.imageAtlas){const wr=Yt.imageAtlas,Qr=i.e3.from(Ie),On=Qr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),Sa=Qr.getSecondary(),oi=wr.patternPositions.get(On),Fr=Sa?wr.patternPositions.get(Sa.scaleSelf(i.o.devicePixelRatio).toString()):null;er=!!oi&&!!Fr,oi&&Jt.setConstantPatternPositions(oi,Fr)}Re>0&&(er||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&ir.push("FILL_PATTERN_TRANSITION");const Zs=D.getOrCreateProgram(Ht,{config:Jt,overrideFog:zs,defines:ir}),Dr=D.translatePosMatrix(Ks.projMatrix,Yt,B.paint.get("fill-translate"),B.paint.get("fill-translate-anchor"));ht&&at.setupShadows(Yt.tileID.toUnwrapped(),Zs,"vector-tile");const Pr=B.paint.get("fill-emissive-strength");if(Dt){ts=is.lineIndexBuffer,_s=is.lineSegments;const wr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[be.drawingBufferWidth,be.drawingBufferHeight];Ut=Ht==="fillOutlinePattern"&&Nt?P6(Dr,Pr,D,Yt,wr,At,Re):dF(Dr,Pr,wr,At)}else ts=is.indexBuffer,_s=is.triangleSegments,Ut=Nt?E6(Dr,Pr,D,Yt,At,Re):A6(Dr,Pr,At);D.uploadCommonUniforms(D.context,Zs,Ks.toUnwrapped());let pr=gt;(ae==="road"&&!le||ae==="offset")&&(pr=ot),Zs.draw(D,es,pr,A||D.stencilModeForClipping(Ks),ee,gn.disabled,Ut,B.id,is.layoutVertexBuffer,ts,_s,B.paint,D.transform.zoom,Jt,br)}};D.renderPass===we&&wt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Br.ReadWrite:Br.ReadOnly),!1),Ze==="none"&&D.renderPass==="translucent"&&B.paint.get("fill-antialias")&&wt(D.depthModeForSublayer(B.getPaintProperty("fill-outline-color")?2:0,Br.ReadOnly),!0)}function MC(T,h,v,A,D,F,B,W){v.resetLayerRenderingStats(T);const ee=T.context,ae=ee.gl,le=T.transform,we=v.paint.get("fill-extrusion-pattern"),be=v.paint.get("fill-extrusion-pattern-cross-fade"),Ne=we.constantOr(null),Re=we.constantOr(1),Ie=v.paint.get("fill-extrusion-opacity"),Ze=T.style.enable3dLights(),Ve=v.paint.get(Ze&&!Re?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),at=[v.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ve],ht=v.layout.get("fill-extrusion-edge-radius"),ot=ht>0&&!v.paint.get("fill-extrusion-rounded-roof"),At=ot?0:ht,Nt=le.projection.name==="globe"?i.eb():0,Ct=le.projection.name==="globe",wt=Ct?i.aj(le.zoom):0,gt=[i.aF(le.center.lng),i.aJ(le.center.lat)],Dt=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ht=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Dt?null:v.lut).toArray01().slice(0,3),Ut=v.paint.get("fill-extrusion-flood-light-intensity"),es=v.paint.get("fill-extrusion-vertical-scale"),ts=v.paint.get("fill-extrusion-line-width").constantOr(1)!==0,_s=v.paint.get("fill-extrusion-height-alignment"),Ks=v.paint.get("fill-extrusion-base-alignment"),Yt=ky(T,v.paint.get("fill-extrusion-cutoff-fade-range")),zt=[];let is;Ct&&zt.push("PROJECTION_GLOBE_VIEW"),at[0]>0&&zt.push("FAUX_AO"),ot&&zt.push("ZERO_ROOF_RADIUS"),W&&zt.push("HAS_CENTROID"),Ut>0&&zt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&zt.push("RENDER_CUTOFF"),ts&&zt.push("RENDER_WALL_MODE");const Jt=T.renderPass==="shadow",zs=T.shadowRenderer,ir=Jt&&!!zs,br=Jt?gn.disabled:gn.backCCW;T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0);let er=[0,0,0];if(zs){const Pr=T.style.directionalLight,pr=T.style.ambientLight;Pr&&pr&&(er=ag(T.style,Pr,pr)),Jt||(zt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),zs.useNormalOffset&&zt.push("NORMAL_OFFSET")),is=zt.concat(["SHADOWS_SINGLE_CASCADE"])}const Zs=ir?"fillExtrusionDepth":Re?"fillExtrusionPattern":"fillExtrusion",Dr=v.getLayerRenderingStats();for(const Pr of A){const pr=h.getTile(Pr),wr=pr.getBucket(v);if(!wr||wr.projection.name!==le.projection.name)continue;let Qr=!1;zs&&(Qr=zs.getMaxCascadeForTile(Pr.toUnwrapped())===0);const On=T.isTileAffectedByFog(Pr),Sa=wr.programConfigurations.get(v.id);let oi=!1;if(Ne&&pr.imageAtlas){const Xa=pr.imageAtlas,Kn=i.e3.from(Ne),hi=Kn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),To=Kn.getSecondary(),oo=Xa.patternPositions.get(hi),fi=To?Xa.patternPositions.get(To.scaleSelf(i.o.devicePixelRatio).toString()):null;oi=!!oo&&!!fi,oo&&Sa.setConstantPatternPositions(oo,fi)}be>0&&(oi||Sa.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&zt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Fr=T.getOrCreateProgram(Zs,{config:Sa,defines:Qr?is:zt,overrideFog:On});if(T.terrain&&T.terrain.setupElevationDraw(pr,Fr,{useMeterToDem:!0}),!wr.centroidVertexBuffer){const Xa=Fr.getAttributeLocation(ae,"a_centroid_pos");Xa!==-1&&ae.vertexAttrib2f(Xa,0,0)}!Jt&&zs&&zs.setupShadows(pr.tileID.toUnwrapped(),Fr,"vector-tile"),Re&&(T.context.activeTexture.set(ae.TEXTURE0),pr.imageAtlasTexture&&pr.imageAtlasTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),Sa.updatePaintBuffers());const ei=v.paint.get("fill-extrusion-vertical-gradient"),En=1/wr.tileToMeter;let pi;if(Jt&&zs){if(cg(pr.tileID,wr.maxHeight,T))continue;const Xa=zs.calculateShadowPassMatrixFromTile(pr.tileID.toUnwrapped());pi=T6(Xa,At,En,es,_s,Ks)}else{const Xa=T.translatePosMatrix(Pr.expandedProjMatrix,pr,v.paint.get("fill-extrusion-translate"),v.paint.get("fill-extrusion-translate-anchor")),Kn=le.projection.createInversionMatrix(le,Pr.canonical);pi=Re?cF(Xa,T,ei,Ie,at,At,En,Pr,pr,Nt,_s,Ks,wt,gt,Kn,Ht,es,be):bC(Xa,T,ei,Ie,at,At,En,Pr,Nt,_s,Ks,wt,gt,Kn,Ht,es,Ut,er)}T.uploadCommonUniforms(ee,Fr,Pr.toUnwrapped(),null,Yt);let Ti=wr.segments;if(le.projection.name==="mercator"&&!Jt&&(Ti=wr.getVisibleSegments(pr.tileID,T.terrain,T.transform.getFrustum(0)),!Ti.get().length))continue;if(Dr)if(Jt)for(const Xa of Ti.get())Dr.numRenderedVerticesInShadowPass+=Xa.primitiveLength;else for(const Xa of Ti.get())Dr.numRenderedVerticesInTransparentPass+=Xa.primitiveLength;const ji=[];(T.terrain||W)&&ji.push(wr.centroidVertexBuffer),Ct&&ji.push(wr.layoutVertexExtBuffer),ts&&ji.push(wr.wallVertexBuffer),Fr.draw(T,ee.gl.TRIANGLES,D,F,B,br,pi,v.id,wr.layoutVertexBuffer,wr.indexBuffer,Ti,v.paint,T.transform.zoom,Sa,ji)}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1)}class R6{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function lg(T,h,v,A,D,F,B,W,ee,ae,le,we,be,Ne,Re,Ie,Ze,Ve,at,ht){const ot=h.context,At=ot.gl,Nt=h.transform,Ct=h.transform.zoom,wt=[],gt=T.translate,Dt=T.translateAnchor,Ht=T.edgeRadius,Ut=ky(h,T.cutoffFadeRange);le==="clear"?(wt.push("CLEAR_SUBPASS"),ht&&(wt.push("CLEAR_FROM_TEXTURE"),ot.activeTexture.set(At.TEXTURE0),ht.bind(At.LINEAR,At.CLAMP_TO_EDGE))):le==="sdf"?wt.push("SDF_SUBPASS"):le==="emissive"&&(wt.push("USE_MRT1"),ot.activeTexture.set(At.TEXTURE0),ht.bind(At.LINEAR,At.CLAMP_TO_EDGE)),Ve&&wt.push("HAS_CENTROID"),Ut.shouldRenderCutoff&&wt.push("RENDER_CUTOFF");const es=(ts,_s,Ks,Yt,zt)=>{let is=wt;_s.groundRadiusBuffer!=null&&(is=wt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=_s.programConfigurations.get(A.id),zs=h.isTileAffectedByFog(ts),ir=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:is,overrideFog:zs}),br=gb(h,Yt,we,ae,zt,[be,Ne*zt],Re,Ie,Ze,Ct>=17?0:Ht*zt,ht?ht.size[0]:0),er=[];Ve&&er.push(_s.hiddenByLandmarkVertexBuffer),_s.groundRadiusBuffer!=null&&er.push(_s.groundRadiusBuffer),h.uploadCommonUniforms(ot,ir,ts.toUnwrapped(),null,Ut),ir.draw(h,ot.gl.TRIANGLES,F,B,W,ee,br,A.id,_s.vertexBuffer,_s.indexBuffer,Ks,A.paint,Ct,Jt,er)};for(const ts of D){const _s=v.getTile(ts),Ks=_s.getBucket(A);if(!Ks||Ks.projection.name!==Nt.projection.name||!Ks.groundEffect||Ks.groundEffect&&!Ks.groundEffect.hasData())continue;const Yt=Ks.groundEffect,zt=1/Ks.tileToMeter;{const is=h.translatePosMatrix(ts.projMatrix,_s,gt,Dt),Jt=Yt.getDefaultSegment();es(ts,Yt,Jt,is,zt)}if(at)for(let is=0;is<4;is++){const Jt=i.e9[is](ts),zs=v.getTile(Jt);if(!zs)continue;const ir=zs.getBucket(A);if(!ir||ir.projection.name!==Nt.projection.name||!ir.groundEffect||ir.groundEffect&&!ir.groundEffect.hasData())continue;const br=ir.groundEffect;let er,Zs;is===0?(er=[-i.al,0,0],Zs=1):is===1?(er=[i.al,0,0],Zs=0):is===2?(er=[0,-i.al,0],Zs=3):(er=[0,i.al,0],Zs=2);const Dr=br.regionSegments[Zs];if(!Dr)continue;const Pr=new Float32Array(16);i.br(Pr,ts.projMatrix,er),es(ts,br,Dr,h.translatePosMatrix(Pr,_s,gt,Dt),zt)}}}function rpe(T,h,v,A,D,F,B){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const W=F?F.findDEMTileFor(v):null;if(!(W&&W.dem||B))return;F&&W&&W.dem&&A.selfDEMTileTimestamp!==W.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=W.dem._timestamp);const ee=Ve=>new i.P(Math.ceil((Ve+i.ed)*i.ee),0),ae=Ve=>{const at=h.getSource().minzoom,ht=At=>{const Nt=h.getTileByID(At);if(Nt&&Nt.hasData())return Nt.getBucket(D)},ot=[0,-1,1];for(const At of ot){if(Ve.overscaledZ+At(le[0]=Math.min(Ve.min.y,at.min.y),le[1]=Math.max(Ve.max.y,at.max.y),le[2]=i.al-at.min.x>Ve.max.x?at.min.x-i.al:Ve.max.x,le),be=(Ve,at)=>(le[0]=Math.min(Ve.min.x,at.min.x),le[1]=Math.max(Ve.max.x,at.max.x),le[2]=i.al-at.min.y>Ve.max.y?at.min.y-i.al:Ve.max.y,le),Ne=[(Ve,at)=>we(Ve,at),(Ve,at)=>we(at,Ve),(Ve,at)=>be(Ve,at),(Ve,at)=>be(at,Ve)],Re=(Ve,at,ht,ot,At,Nt,Ct)=>{if(!F)return 0;const wt=[[Nt?ht:Ve,Nt?Ve:ht,0],[Nt?ht:at,Nt?at:ht,0]],gt=Ct<0?i.al+Ct:Ct,Dt=[Nt?gt:(Ve+at)/2,Nt?(Ve+at)/2:gt,0];return ht===0&&Ct<0||ht!==0&&Ct>0?F.getForTilePoints(At,[Dt],!0,ot):wt.push(Dt),F.getForTilePoints(v,wt,!0,W),Math.max(wt[0][2],wt[1][2],Dt[2])/F.exaggeration()};for(let Ve=0;Ve<4;Ve++){const at=A.borderFeatureIndices[Ve];if(at.length===0)continue;const ht=i.e9[Ve](v),ot=ae(ht);if(!(ot&&ot instanceof i.ea))continue;const At=F?F.findDEMTileFor(ht):null;if(!(At&&At.dem||B)||(F&&At&&At.dem&&A.borderDEMTileTimestamp[Ve]!==At.dem._timestamp&&(A.borderDoneWithNeighborZ[Ve]=-1,A.borderDEMTileTimestamp[Ve]=At.dem._timestamp),A.borderDoneWithNeighborZ[Ve]===ot.canonical.z))continue;ot.centroidVertexArray.length===0&&ot.createCentroidsBuffer();const Nt=(Ve<2?1:5)-Ve,Ct=ot.borderDoneWithNeighborZ[Nt]!==A.canonical.z,wt=ot.borderFeatureIndices[Nt];let gt=0;if(A.canonical.z!==ot.canonical.z){for(const Dt of at)A.showCentroid(A.featuresOnBorder[Dt]);if(Ct)for(const Dt of wt)ot.showCentroid(ot.featuresOnBorder[Dt]);A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}for(const Dt of at){const Ht=A.featuresOnBorder[Dt],Ut=A.centroidData[Ht.centroidDataIndex],es=Ht.borders[Ve];let ts;for(;gtes[0]+3||_s[0]>es[0]-3)break;ot.showCentroid(ts),gt++}if(ts&>es[1]-3)&&(Ks++,++gt!==wt.length);)ts=ot.featuresOnBorder[wt[gt]];ts=ot.featuresOnBorder[wt[_s]];let Yt=!1;if(Ks>=1){const Jt=ts.borders[Nt];Math.abs(es[0]-Jt[0])<3&&Math.abs(es[1]-Jt[1])<3&&(Ks=1,Yt=!0,gt=_s+1)}else if(Ks===0){A.showCentroid(Ht);continue}const zt=ot.centroidData[ts.centroidDataIndex];B&&Yt&&(((Ie=Ut).flags|(Ze=zt).flags)&i.ec?(Ie.flags|=i.ec,Ze.flags|=i.ec):(Ie.flags&=~i.ec,Ze.flags&=~i.ec));const is=Ht.intersectsCount()>1||ts.intersectsCount()>1;if(Ks>1)gt=_s,Ut.centroidXY=zt.centroidXY=new i.P(0,0);else if(At&&At.dem&&!is){const Jt=Ne[Ve](Ut,zt),zs=Ve%2?i.al-1:0,ir=Re(Jt[0],Math.min(i.al-1,Jt[1]),zs,At,ht,Ve<2,Jt[2]);Ut.centroidXY=zt.centroidXY=ee(ir)}else is?Ut.centroidXY=zt.centroidXY=new i.P(0,0):(Ut.centroidXY=A.encodeBorderCentroid(Ht),zt.centroidXY=ot.encodeBorderCentroid(ts));A.writeCentroidToBuffer(Ut),ot.writeCentroidToBuffer(zt)}else A.showCentroid(Ht)}A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}var Ie,Ze;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(T)}const zh=[1,0,0],F6=[0,1,0],qu=[0,0,1];function cg(T,h,v){const A=v.transform,D=v.shadowRenderer;if(!D)return!0;const F=T.toUnwrapped(),B=A.tileSize*D._cascades[v.currentShadowCascade].scale;let W=h;if(A.elevation){const Ie=A.elevation.getMinMaxForTile(T);Ie&&(W+=Ie.max)}const ee=[...D.shadowDirection];ee[2]=-ee[2];const ae=D.computeSimplifiedTileShadowVolume(F,W,B,ee);if(!ae)return!1;const le=[zh,F6,qu,ee,[ee[0],0,ee[2]],[0,ee[1],ee[2]]],we=A.projection.name==="globe",be=A.scaleZoom(B),Ne=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,be,!we),Re=D.getCurrentCascadeFrustum();return Ne.intersectsPrecise(ae.vertices,ae.planes,le)===0||Re.intersectsPrecise(ae.vertices,ae.planes,le)===0}function v2(T){const{painter:h,source:v,layer:A,coords:D}=T;let F=T.defines;const B=h.context,W=h.renderPass==="shadow",ee=h.renderPass==="light-beam",ae=h.shadowRenderer,le=i.ef(h.transform.center.lat,h.transform.zoom),we=ky(h,A.paint.get("building-cutoff-fade-range"));we.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),T.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const be of D){const Ne=v.getTile(be),Re=Ne.getBucket(A);if(!Re)continue;ae&&ae.getMaxCascadeForTile(be.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ie=Re.programConfigurations.get(A.id);let Ze,Ve,at,ht=h.translatePosMatrix(be.expandedProjMatrix,Ne,[0,0],"map");if(ht=i.cS(i.bC(),ht,[1,1,T.verticalScale]),W&&ae){if(cg(Ne.tileID,Re.maxHeight*le,h))continue;let At=ae.calculateShadowPassMatrixFromTile(Ne.tileID.toUnwrapped());At=i.cS(i.bC(),At,[1,1,T.verticalScale]),at=Py(At),Ze=Ve=h.getOrCreateProgram("buildingDepth",{config:Ie,defines:F,overrideFog:!1})}else if(ee)Ze=Ve=h.getOrCreateProgram("buildingBloom",{config:Ie,defines:F,overrideFog:!1}),at=uF(ht);else{const At=h.transform.calculatePosMatrix(be.toUnwrapped(),h.transform.worldSize);i.cS(At,At,[1,1,T.verticalScale]);const Nt=i.bC();i.cS(Nt,At,[1,-1,1/le]),i.bl(Nt,Nt),i.eg(Nt,Nt);const Ct=h.transform.getFreeCameraOptions().position,wt=1<{if(ee){const Ct=At.entranceBloom;Nt.draw(h,B.gl.TRIANGLES,T.depthMode,bn.disabled,T.blendMode,gn.disabled,at,A.id,Ct.layoutVertexBuffer,Ct.indexBuffer,Ct.segmentsBucket,A.paint,h.transform.zoom,Ie,[Ct.layoutAttenuationBuffer,Ct.layoutColorBuffer])}else{const Ct=At.segmentsBucket;let wt=[At.layoutNormalBuffer,At.layoutCentroidBuffer,At.layoutColorBuffer,At.layoutFloodLightDataBuffer];At.layoutFacadePaintBuffer&&(wt=wt.concat([At.layoutFacadeDataBuffer,At.layoutFacadeVerticalRangeBuffer,At.layoutFacadePaintBuffer])),Nt.draw(h,B.gl.TRIANGLES,T.depthMode,bn.disabled,T.blendMode,W?gn.disabled:gn.backCW,at,A.id,At.layoutVertexBuffer,At.indexBuffer,Ct,A.paint,h.transform.zoom,Ie,wt)}};h.uploadCommonUniforms(B,Ve,be.toUnwrapped(),null,we),Re.buildingWithoutFacade&&ot(Re.buildingWithoutFacade,Ve),Re.buildingWithFacade&&(Ze!==Ve&&h.uploadCommonUniforms(B,Ze,be.toUnwrapped(),null,we),ot(Re.buildingWithFacade,Ze))}}function TC(T,h,v,A,D,F,B,W,ee,ae,le,we,be){const Ne=T.context.gl,Re=T.depthModeForSublayer(1,Br.ReadOnly,Ne.LEQUAL,!0),Ie=.1*(1-(Ze=le))+3*Ze;var Ze;const Ve=T._showOverdrawInspector,at=we,ht=new R6;Ve||lg(ht,T,h,v,A,Re,new bn({func:Ne.ALWAYS,mask:255},255,255,Ne.KEEP,Ne.KEEP,Ne.REPLACE),new Gn([Ne.ONE,Ne.ONE,Ne.ONE,Ne.ONE],i.ao.transparent,[!1,!1,!1,!0],Ne.MIN),gn.disabled,D,"sdf",F,B,W,ee,ae,Ie,at,!1);{const ot=Ve?bn.disabled:new bn({func:Ne.EQUAL,mask:255},255,255,Ne.KEEP,Ne.DECR,Ne.DECR),At=Ve?T.colorModeForRenderPass():new Gn([Ne.ONE_MINUS_DST_ALPHA,Ne.DST_ALPHA,Ne.ONE,Ne.ONE],i.ao.transparent,[!0,!0,!0,!0]);lg(ht,T,h,v,A,Re,ot,At,gn.disabled,D,"color",F,B,W,ee,ae,Ie,at,!1)}}function AC(T){return[T[0]*i.eh,T[1]*i.eh,T[2]*i.eh,0]}function b2(T,h,v,A,D,F,B,W,ee){const ae=A.getSource(),le=v.globeSharedBuffers;if(!le)return;let we,be,Ne;if(h&&(we=A.getTile(h)),ae instanceof i.aU?(be=ae.texture,Ne=i.dK(0,0,v.transform)):we&&h&&(be=we.texture,Ne=i.dK(h.canonical.z,h.canonical.x,v.transform)),!be||!Ne)return;T||(Ne=i.cS(i.bC(),Ne,[1,-1,1]));const Re=v.context,Ie=Re.gl,Ze=D.paint.get("raster-resampling")==="nearest"?Ie.NEAREST:Ie.LINEAR,Ve=v.colorModeForDrapableLayerRenderPass(F),at=B.defines;at.push("GLOBE_POLES");const ht=new Br(Ie.LEQUAL,Br.ReadWrite,v.depthRangeFor3D),ot=Float32Array.from(v.transform.expandedFarZProjMatrix),At=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));v.terrain&&v.terrain.prepareDrawTile(),Re.activeTexture.set(Ie.TEXTURE0),be.bind(Ze,Ie.CLAMP_TO_EDGE),Re.activeTexture.set(Ie.TEXTURE1),be.bind(Ze,Ie.CLAMP_TO_EDGE),"useMipmap"in be&&Re.extTextureFilterAnisotropic&&v.transform.pitch>20&&Ie.texParameterf(Ie.TEXTURE_2D,Re.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Re.extTextureFilterAnisotropicMax);const[Nt,Ct,wt,gt]=h?le.getPoleBuffers(h.canonical.z,!1):le.getPoleBuffers(0,!0),Dt=D.paint.get("raster-elevation");let Ht;T?(Ht=Nt,v.renderDefaultNorthPole=Dt!==0):(Ht=Ct,v.renderDefaultSouthPole=Dt!==0);const Ut=AC(B.mix),es=((_s,Ks,Yt,zt,is,Jt,zs,ir,br,er,Zs,Dr,Pr)=>pF(_s,Ks,Yt,new Float32Array(16),new Float32Array(9),[0,0],zt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],ir,2,er,Zs,Dr,1,0,Pr))(ot,At,Ne,i.aj(v.transform.zoom),0,D,0,Dt,0,Ut,B.offset,B.range,F),ts=v.getOrCreateProgram("raster",{defines:at});v.uploadCommonUniforms(Re,ts,null),ts.draw(v,Ie.TRIANGLES,ht,ee,Ve,W,es,D.id,Ht,wt,gt)}function _F(T){const h=T._nearZ,v=T.projection.farthestPixelDistance(T),A=v-h,D=.2*T.height,F=h+D;return[h,v,(F-D-h)/A,(F-h)/A]}function dg(T,h,v,A){if(T)return h instanceof Md&&T instanceof Ad?h.getTextureDescriptor(T,v,!0):{texture:T.texture,mix:AC(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Yi=i.ei([{name:"a_index",type:"Int16",components:1}]);class EC{constructor(h,v,A,D){const F={width:A[0],height:A[1],data:null},B=h.gl;this.targetColorTexture=new i.T(h,F,B.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,B.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(v,D),this.lastInvalidatedAt=0}updateParticleTexture(h,v){if(this.particleTextureDimension===v.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=v.width*v.height;this.particleTexture0=new i.T(this.context,v,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,v,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let B=0;B0){const Ut=i.bj(v.canonical,ee),es=i.el(Ut);be=i.aB(new Float32Array(16),ee.globeMatrix,es),i.aB(be,ee.projMatrix,be)}const Ne=i.bC();Ne[12]+=2*D/(i.o.devicePixelRatio*ee.width),Ne[13]+=2*F/(i.o.devicePixelRatio*ee.height),i.aB(be,Ne,be);const Re=T.getOrCreateProgram("debug",{defines:we}),Ie=h.getTileByID(v.key);T.terrain&&T.terrain.setupElevationDraw(Ie,Re);const Ze=Br.disabled,Ve=bn.disabled,at=T.colorModeForRenderPass(),ht="$debug";W.activeTexture.set(ae.TEXTURE0),T.emptyTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),le?Ie._makeGlobeTileDebugBuffers(T.context,ee):Ie._makeDebugTileBoundsBuffers(T.context,ee.projection);const ot=Ie._tileDebugBuffer||T.debugBuffer,At=Ie._tileDebugIndexBuffer||T.debugIndexBuffer,Nt=Ie._tileDebugSegments||T.debugSegments;if(Re.draw(T,ae.LINE_STRIP,Ze,Ve,at,gn.disabled,f2(be,A.toPremultipliedRenderColor(null)),ht,ot,At,Nt,null,null,null,[Ie._globeTileDebugBorderBuffer]),B){const Ut=Ie.latestRawTileData,es=Math.floor((Ut&&Ut.byteLength||0)/1024);let ts=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(ts+=` => ${v.overscaledZ}`),ts+=` ${Ie.state}`,ts+=` ${es}kb`,function(_s,Ks){_s.initDebugOverlayCanvas();const Yt=_s.debugOverlayCanvas,zt=_s.context.gl,is=_s.debugOverlayCanvas.getContext("2d");is.clearRect(0,0,Yt.width,Yt.height),is.shadowColor="white",is.shadowBlur=2,is.lineWidth=1.5,is.strokeStyle="white",is.textBaseline="top",is.font="bold 36px Open Sans, sans-serif",is.fillText(Ks,5,5),is.strokeText(Ks,5,5),_s.debugOverlayTexture.update(Yt),_s.debugOverlayTexture.bind(zt.LINEAR,zt.CLAMP_TO_EDGE)}(T,ts)}const Ct=h.getTile(v).tileSize,wt=512/Math.min(Ct,512)*(v.overscaledZ/ee.zoom)*.5,gt=Ie._tileDebugTextBuffer||T.debugBuffer,Dt=Ie._tileDebugTextIndexBuffer||T.quadTriangleIndexBuffer,Ht=Ie._tileDebugTextSegments||T.debugSegments;Re.draw(T,ae.TRIANGLES,Ze,Ve,Gn.alphaBlended,gn.disabled,f2(be,i.ao.transparent.toPremultipliedRenderColor(null),wt),ht,gt,Dt,Ht,null,null,null,[Ie._globeTileDebugTextBuffer])}function gv(T,h,v,A){Kt(T,0,h+v/2,T.transform.width,v,A)}function Oo(T,h,v,A){Kt(T,h-v/2,0,v,T.transform.height,A)}function Kt(T,h,v,A,D,F){const B=T.context,W=B.gl;W.enable(W.SCISSOR_TEST),W.scissor(h*i.o.devicePixelRatio,v*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),B.clear({color:F}),W.disable(W.SCISSOR_TEST)}const SF=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:PC}=SF;function Zf(T,h,v,A){T.emplaceBack(h,v,A)}class IC{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Zf(this.vertexArray,-1,-1,1),Zf(this.vertexArray,1,-1,1),Zf(this.vertexArray,-1,1,1),Zf(this.vertexArray,1,1,1),Zf(this.vertexArray,-1,-1,-1),Zf(this.vertexArray,1,-1,-1),Zf(this.vertexArray,-1,1,-1),Zf(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,PC),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function yv(T,h,v,A,D,F){const B=T.context.gl,W=h.paint.get("sky-atmosphere-color"),ee=h.paint.get("sky-atmosphere-halo-color"),ae=h.paint.get("sky-atmosphere-sun-intensity"),le=((we,be,Ne,Re,Ie)=>({u_matrix_3f:we,u_sun_direction:be,u_sun_intensity:Ne,u_color_tint_r:[Re.r,Re.g,Re.b,Re.a],u_color_tint_m:[Ie.r,Ie.g,Ie.b,Ie.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ae,W.toPremultipliedRenderColor(null),ee.toPremultipliedRenderColor(null));B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),v.draw(T,B.TRIANGLES,Br.disabled,bn.disabled,Gn.unblended,gn.frontCW,le,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const CF=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class bb{constructor(h){const v=new i.ep;v.emplaceBack(-1,1,1,0,0),v.emplaceBack(1,1,1,1,0),v.emplaceBack(1,-1,1,1,1),v.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(v,CF.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 npe=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 ape{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class MF{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Gn([1,Hf,1,Hf],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Gn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new ape,this.updateNeeded=!0}update(h){const v=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new bb(v);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(le){const we=i.eq(30),be=[];for(let Ne=0;Ne{const wt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Ct&&wt.push("ALPHA_PASS");const gt=h.getOrCreateProgram("globeAtmosphere",{defines:wt}),Dt=((Ut,es,ts,_s,Ks,Yt,zt,is,Jt,zs,ir,br)=>({u_frustum_tl:Ut,u_frustum_tr:es,u_frustum_br:ts,u_frustum_bl:_s,u_horizon:Ks,u_transition:Yt,u_fadeout_range:zt,u_atmosphere_fog_color:is.toArray01(),u_high_color:Jt.toArray01(),u_space_color:zs.toArray01(),u_temporal_offset:ir,u_horizon_angle:br}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,W,Ze,le,be,Re,at,At);h.uploadCommonUniforms(A,gt);const Ht=this.atmosphereBuffer;Ht&>.draw(h,D.TRIANGLES,B,bn.disabled,Ct?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,gn.backCW,Dt,Ct?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};Nt(!1),Nt(!0)}drawStars(h,v){const A=i.aA(v.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,B=h.transform,W=h.getOrCreateProgram("stars"),ee=i.c7([]);i.c9(ee,ee,-B._pitch),i.c8(ee,ee,-B.angle),i.c9(ee,ee,i.an(B._center.lat)),i.et(ee,ee,-i.an(B._center.lng));const ae=i.cc(new Float32Array(16),ee),le=i.aB([],B.starsProjMatrix,ae),we=i.eo([],ae),be=i.eu([],we),Ne=[0,1,0];i.dQ(Ne,Ne,be),i.c5(Ne,Ne,this.params.sizeMultiplier);const Re=[1,0,0];i.dQ(Re,Re,be),i.c5(Re,Re,this.params.sizeMultiplier);const Ie=(Ze=Ne,Ve=Re,at=A,{u_matrix:Float32Array.from(le),u_up:Ze,u_right:Ve,u_intensity_multiplier:at});var Ze,Ve,at;h.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(h,F.TRIANGLES,Br.disabled,bn.disabled,this.colorModeAlphaBlendedWriteRGB,gn.disabled,Ie,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class LC{constructor(){this.visibleTiles=[]}updateBorders(h,v){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const ee of F){const ae=h.getTile(ee);if(!ae.hasData())continue;const le=ae.getBucket(v);le&&(le.isEmpty()||(A.push(ee.key),D.push({bucket:le,tileID:ee.canonical})))}let B=A.length!==this.visibleTiles.length;if(!B){A.sort();for(let ee=0;eeee.tileID.z-ae.tileID.z||ee.tileID.x-ae.tileID.x||ee.tileID.y-ae.tileID.y);for(const ee of D){const ae=new Array,le=new Array,we=ee.bucket;for(const be of we.featuresOnBorder)W.has(be.featureId)?le.push(be.footprintIndex):(W.add(be.featureId),ae.push(be.footprintIndex));we.updateFootprintHiddenFlags(ae,i.ev,!1),we.updateFootprintHiddenFlags(le,i.ev,!0)}}}function DC(T,h){const v=[...T],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(v,D,v),i.aB(v,h.worldToFogMatrix,v),v}function OC(T,h,v,A,D){const F=v.material,B=A.context,{baseColorTexture:W,metallicRoughnessTexture:ee}=F.pbrMetallicRoughness,{normalTexture:ae,occlusionTexture:le,emissionTexture:we}=F;function be(Re,Ie,Ze){if(Re&&(T.push(Ie),B.activeTexture.set(B.gl.TEXTURE0+Ze),Re.gfxTexture)){const{minFilter:Ve,magFilter:at,wrapS:ht,wrapT:ot}=Re.sampler;Re.gfxTexture.bindExtraParam(Ve,at,ht,ot)}}be(W,"HAS_TEXTURE_u_baseColorTexture",Kc.BaseColor),be(ee,"HAS_TEXTURE_u_metallicRoughnessTexture",Kc.MetallicRoughness),be(ae,"HAS_TEXTURE_u_normalTexture",Kc.Normal),be(le,"HAS_TEXTURE_u_occlusionTexture",Kc.Occlusion),be(we,"HAS_TEXTURE_u_emissionTexture",Kc.Emission),D&&(D.texture||(D.texture=new i.d$(A.context,D.image,[D.image.height,D.image.height,D.image.height],B.gl.RGBA8)),B.activeTexture.set(B.gl.TEXTURE0+Kc.LUT),D.texture&&D.texture.bind(B.gl.LINEAR,B.gl.CLAMP_TO_EDGE),T.push("APPLY_LUT_ON_GPU")),v.texcoordBuffer&&(T.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(v.texcoordBuffer)),v.colorBuffer&&(T.push(v.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(v.colorBuffer)),v.normalBuffer&&(T.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(v.normalBuffer)),v.pbrBuffer&&(T.push("HAS_ATTRIBUTE_a_pbr"),T.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(v.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 RC(T,h,v,A,D,F){const B=T.modelOpacity,W=h.context,ee=new Br(h.context.gl.LEQUAL,T.isLightMesh?Br.ReadOnly:Br.ReadWrite,h.depthRangeFor3D),ae=h.transform,le=T.mesh,we=le.material,be=we.pbrMetallicRoughness,Ne=h.style.fog;let Re;Re=h.transform.projection.zAxisUnit==="pixels"?[...T.nodeModelMatrix]:i.aB([],A.zScaleMatrix,T.nodeModelMatrix),i.aB(Re,A.negCameraPosMatrix,Re);const Ie=i.bl([],Re);i.eg(Ie,Ie);const Ze=v.paint.get("model-color-use-theme").constantOr("default")==="none",Ve=v.paint.get("model-emissive-strength").constantOr(0),at=mv(new Float32Array(T.worldViewProjection),new Float32Array(Re),new Float32Array(Ie),null,h,B,be.baseColorFactor,we.emissiveFactor,be.metallicFactor,be.roughnessFactor,we,Ve,v,void 0,void 0,T.materialOverride,T.modelColor),ht={defines:[]},ot=[],At=h.shadowRenderer;At&&(At.useNormalOffset=!1),OC(ht.defines,ot,le,h,Ze?null:v.lut);let Nt=null;if(Ne){const gt=DC(T.nodeModelMatrix,h.transform);if(Nt=new Float32Array(gt),ae.projection.name!=="globe"){const Dt=le.aabb.min,Ht=le.aabb.max,[Ut,es]=Ne.getOpacityForBounds(gt,Dt[0],Dt[1],Ht[0],Ht[1]);ht.overrideFog=Ut>=Ns||es>=Ns}}const Ct=ky(h,v.paint.get("model-cutoff-fade-range"));Ct.shouldRenderCutoff&&ht.defines.push("RENDER_CUTOFF");const wt=h.getOrCreateProgram("model",ht);h.uploadCommonUniforms(W,wt,null,Nt,Ct),h.renderPass!=="shadow"&&At&&At.setupShadowsFromMatrix(T.nodeModelMatrix,wt),wt.draw(h,W.gl.TRIANGLES,ee,D,F,le.material.doubleSided?gn.disabled:gn.backCCW,at,v.id,le.vertexBuffer,le.indexBuffer,le.segments,v.paint,h.transform.zoom,void 0,ot)}function _2(T,h){return T.style._importedAsBasemap?"basemap":h.scope}function vv(T,h,v,A,D,F,B,W,ee,ae){const le=T.transform,we=!!h.isGeometryBloom&&h.isGeometryBloom;if(we&&T.renderPass==="shadow")return;const be=le.projection.name==="globe"?i.eD(v,le):[...v];i.aB(be,be,h.globalMatrix);const Ne=i.aB([],A,be);if(h.meshes)for(const Re of h.meshes){const Ie=W.get(Re.material.name);if(Ie&&Ie.opacity<=0)continue;if(Re.material.alphaMode!=="BLEND"){B.push({mesh:Re,depth:0,modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:be,isLightMesh:we,materialOverride:Ie,modelOpacity:ee,modelColor:ae});continue}const Ze=i.af([],Re.centroid,Ne);!le.isOrthographic&&Ze[2]<=0||F.push({mesh:Re,depth:Ze[2],modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:be,isLightMesh:we,materialOverride:Ie,modelOpacity:ee,modelColor:ae})}if(h.children)for(const Re of h.children)vv(T,Re,v,A,D,F,B,W,ee,ae)}function Up(T,h,v,A){const D=v.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),B=D.getShadowPassColorMode(),W=D.calculateShadowPassMatrixFromMatrix(h),ee=L6(W);v.getOrCreateProgram("modelDepth",{defines:v._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(v,v.context.gl.TRIANGLES,F,bn.disabled,B,gn.disabled,ee,A.id,T.vertexBuffer,T.indexBuffer,T.segments,A.paint,v.transform.zoom,void 0,void 0)}function TF(T,h,v,A,D,F){for(const B of D){const W=Object.assign({},A);W.part=B;const ee={type:"Unknown",id:h,properties:W},ae={orientation:T.paint.get("model-rotation").evaluate(ee,v)};F.set(B,ae)}}function AF(T,h,v,A,D,F){for(const B of D){const W=Object.assign({},A);W.part=B;const ee={type:"Unknown",id:h,properties:W},ae={color:T.paint.get("model-color").evaluate(ee,v),colorMix:T.paint.get("model-color-mix-intensity").evaluate(ee,v),opacity:T.paint.get("model-opacity").evaluate(ee,v),emissionStrength:T.paint.get("model-emissive-strength").evaluate(ee,v)};F.set(B,ae)}}function EF(T,h,v,A,D){let F=!1;for(const W of A)W.modelOpacity!==1&&(RC(W,T,h,D[W.modelIndex],bn.disabled,Gn.disabled),F=!0);for(const W of A)RC(W,T,h,D[W.modelIndex],W.modelOpacity!==1?T.stencilModeFor3D():bn.disabled,T.colorModeForRenderPass());F&&T.resetStencilClippingMasks();const B=Gn.additive;for(const W of v)RC(W,T,h,D[W.modelIndex],bn.disabled,W.isLightMesh?B:T.colorModeForRenderPass())}function PF(T,h,v){const A=h.updateZoomBasedPaintProperties(),D=function(F,B,W){let ee,ae,le,we=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&we>0){const be=F.terrain,Ne=be.findDEMTileFor(W);Ne&&Ne.dem?ee=i.eF.create(be,W,Ne):we=0}if(we===0&&(B.terrainElevationMin=0,B.terrainElevationMax=0),we===B.validForExaggeration&&(we===0||ee&&ee._demTile&&ee._demTile.tileID===B.validForDEMTile.id&&ee._dem._timestamp===B.validForDEMTile.timestamp))return!1;for(const be in B.instancesPerModel){const Ne=B.instancesPerModel[be];for(let Re=0;Reae&&(ae=Ne.max)}const le=i.aA(A.x,F,B)-A.x,we=i.aA(A.y,W,ee)-A.y,be=i.cf(ae,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(le*le+we*we+be*be))}function IF(T,h,v,A,D,F,B){const W=T.context,ee=T.renderPass==="shadow",ae=T.shadowRenderer,le=ee&&ae?ae.getShadowPassDepthMode():new Br(W.gl.LEQUAL,Br.ReadWrite,T.depthRangeFor3D),we=T.isTileAffectedByFog(F),be=T.transform.projection.name==="globe";if(v.meshes)for(const Ne of v.meshes){const Re=be?[]:["MODEL_POSITION_ON_GPU"],Ie=[];let Ze,Ve,at;const ht=!be&&A.instancedDataArray.length>20;ht&&Re.push("INSTANCED_ARRAYS");const ot=ky(T,h.paint.get("model-cutoff-fade-range"));if(ot.shouldRenderCutoff&&Re.push("RENDER_CUTOFF"),ee&&ae)Ze=T.getOrCreateProgram("modelDepth",{defines:Re}),Ve=L6(B.shadowTileMatrix,B.shadowTileMatrix,Float32Array.from(v.globalMatrix)),at=ae.getShadowPassColorMode();else{OC(Re,Ie,Ne,T,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),Ze=T.getOrCreateProgram("model",{defines:Re,overrideFog:we});const Nt=Ne.material,Ct=Nt.pbrMetallicRoughness,wt=h.paint.get("model-opacity").constantOr(1),gt=h.paint.get("model-emissive-strength").constantOr(0);Ve=mv(F.expandedProjMatrix,Float32Array.from(v.globalMatrix),new Float32Array(16),null,T,wt,Ct.baseColorFactor,Nt.emissiveFactor,Ct.metallicFactor,Ct.roughnessFactor,Nt,gt,h,D),ae&&(B.shadowUniformsInitialized?Ze.setShadowUniformValues(W,ae.getShadowUniformValues()):(ae.setupShadows(F.toUnwrapped(),Ze,"model-tile"),B.shadowUniformsInitialized=!0)),at=ot.shouldRenderCutoff||wt<1||Nt.alphaMode!=="OPAQUE"?Gn.alphaBlended:Gn.unblended}T.uploadCommonUniforms(W,Ze,F.toUnwrapped(),null,ot);const At=Ne.material.doubleSided?gn.disabled:gn.backCCW;if(ht)Ie.push(A.instancedDataBuffer),Ze.draw(T,W.gl.TRIANGLES,le,bn.disabled,at,At,Ve,h.id,Ne.vertexBuffer,Ne.indexBuffer,Ne.segments,h.paint,T.transform.zoom,void 0,Ie,A.instancedDataArray.length);else{const Nt=ee?"u_instance":"u_normal_matrix";for(let Ct=0;Ctee[1]?B:ee,F[0]=v.max[0],B=i.aC(i.eG(),F,D),W=B[1]ee[1]?B:ee,F[1]=v.min[1],B=i.aC(i.eG(),F,D),W=B[1]ee[1]?B:ee;const ae=i.aA(A[0],0,1),le=100*h.pixelsPerMeter*i.aA(A[1],0,1),we=i.aA(A[2],0,1),be=i.eH(i.eG(),W,ee,ae),Ne=Math.tan(.5*h.fovX),Re=-be[2]*Ne;if(le===0)return be[1]<-Math.abs(Re)?we:1;const Ie=(-Math.abs(Re)-be[1])/le,Ze=(at,ht,ot)=>(1-ot)*at+ot*ht,Ve=i.aA(Ze(1,we,Ie),we,1);return Ze(1,Ve,i.aA((h.pitch-20)/20,0,1))}class LF{}class Dy{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,v,A){{const we=this._storage.get(v.id);if(we)return we.lastUsedFrameIdx=h,we.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),B=new ArrayBuffer(F),W=new Int16Array(B);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(B));const ee=new i.eJ;for(let we=0;we30&&(A.buf.destroy(),this._storage.delete(v))}destroy(){for(const[h,v]of this._storage)v.buf.destroy(),this._storage.delete(h)}}class _b{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const wb=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 ug{constructor(h){this.revealStart=11,this.revealRange=2}}const B6=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class $6{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,v){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const B=new i.eK,W=new i.b0;B.emplaceBack(-1,-1),B.emplaceBack(1,-1),B.emplaceBack(1,1),B.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(B,B6.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 B={u_vignetteShape:(F={vignetteShape:[v.start,v.range,Math.pow(10,v.fadePower)],vignetteColor:[v.color.r,v.color.g,v.color.b,v.color.a*v.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Br.disabled,bn.disabled,Gn.alphaBlended,gn.disabled,B,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class q6{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,v){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),B=i.an(F.lng),W=i.an(F.lat),ee=h.pixelsPerMeter/v,ae=B*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 we=-this._offsetYPrev+le,be=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ae)*ee,this._accumulatedOffsetY+=we*ee,this._accumulatedElevation+=be*ee,this._offsetXPrev=ae,this._offsetYPrev=le,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function FC(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 fm(T){const h=i.eq(1323123451230),v=[];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 v=h.context;if(!this.particlesVx){const A=fm(this.particlesCount),D=new i.eN,F=new i.b0;let B=0;const W=i.eq(1323123451230);for(let ee=0;eeA)return;const D=ph(0,1,v.revealStart,v.revealStart+v.revealRange,A);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let B=[-F.direction.x,F.direction.y,-100];i.aw(B,B);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),B=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 ee=this.updateOnRender(h,F.timeFactor),ae=h.context,le=ae.gl,we=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ae,{width:h.width,height:h.height,data:null},le.RGBA8)),F.distortionStrength>0&&(ae.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 be=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ae,be),ae.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],Re=(Ie,Ze)=>{const Ve=FC(this._movement.getPosition(),Ie),at=F.dropletSizeX,ht=F.dropletSizeX*F.dropletSizeYScale,ot=h.width/2,At=h.height/2,Nt=ph(0,F.screenThinning.start,0,1,F.screenThinning.intensity),Ct=ph(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),wt=ph(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),gt=(Dt={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ve,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ie,rainDropletSize:[at,ht],distortionStrength:F.distortionStrength,rainDirection:B,color:Ne,screenSize:[we.width,we.height],thinningCenterPos:[ot,At],thinningShape:[Nt,Ct,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:wt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:Ze?0:1},{u_modelview:Float32Array.from(Dt.modelview),u_projection:Float32Array.from(Dt.projection),u_time:Dt.time,u_cam_pos:Dt.camPos,u_texScreen:0,u_velocityConeAperture:Dt.velocityConeAperture,u_velocity:Dt.velocity,u_boxSize:Dt.boxSize,u_rainDropletSize:Dt.rainDropletSize,u_distortionStrength:Dt.distortionStrength,u_rainDirection:Dt.rainDirection,u_color:Dt.color,u_screenSize:Dt.screenSize,u_thinningCenterPos:Dt.thinningCenterPos,u_thinningShape:Dt.thinningShape,u_thinningAffectedRatio:Dt.thinningAffectedRatio,u_thinningParticleOffset:Dt.thinningParticleOffset,u_shapeDirectionalPower:Dt.shapeDirectionalPower,u_shapeNormalPower:Dt.shapeNormalPower,u_mode:Dt.mode});var Dt;const Ht=Math.round(F.intensity*this.particlesCount),Ut=i.bg.simpleSegment(0,0,4*Ht,2*Ht);be.draw(h,le.TRIANGLES,Br.disabled,bn.disabled,Gn.alphaBlended,gn.disabled,gt,"rain_particles",this.particlesVx,this.particlesIdx,Ut)};F.distortionStrength>0&&Re(F.boxSize,!0),Re(F.boxSize,!1),this._vignette.draw(h,W)}}const U6=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 V6 extends bv{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 ug("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 v=h.context;if(!this.particlesVx){const A=fm(this.particlesCount),D=new i.eO,F=new i.b0;let B=0;const W=i.eq(1323123451230);for(let ee=0;eeB)return;const W=ph(0,1,F.revealStart,F.revealStart+F.revealRange,B);D.strength*=W,v.overrideStyleParameters||(v.intensity=h.style.snow.state.density,v.timeFactor=h.style.snow.state.intensity,v.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),v.screenThinning.intensity=h.style.snow.state.centerThinning,v.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const ee=this.updateOnRender(h,v.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ae=h.context,le=ae.gl,we=h.transform,be=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ae,be),((Ne,Re,Ie)=>{const Ze=FC(this._movement.getPosition(),Ne),Ve=we.width/2,at=we.height/2,ht=ph(0,Ie.screenThinning.start,0,1,Ie.screenThinning.intensity),ot=ph(.001,Ie.screenThinning.range,0,1,Ie.screenThinning.intensity),At=ph(0,Ie.screenThinning.particleOffset,0,1,Ie.screenThinning.intensity),Nt=(Ct={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ze,velocityConeAperture:Ie.velocityConeAperture,velocity:Ie.velocity,horizontalOscillationRadius:Ie.horizontalOscillationRadius,horizontalOscillationRate:Ie.horizontalOscillationRate,boxSize:Ne,billboardSize:1*Ie.billboardSize,simpleShapeParameters:[Ie.shapeFadeStart,Ie.shapeFadePower],screenSize:[we.width,we.height],thinningCenterPos:[Ve,at],thinningShape:[ht,ot,Math.pow(10,Ie.screenThinning.fadePower)],thinningAffectedRatio:Ie.screenThinning.affectedRatio,thinningParticleOffset:At,color:[Ie.color.r,Ie.color.g,Ie.color.b,Ie.color.a],direction:A},{u_modelview:Float32Array.from(Ct.modelview),u_projection:Float32Array.from(Ct.projection),u_time:Ct.time,u_cam_pos:Ct.camPos,u_velocityConeAperture:Ct.velocityConeAperture,u_velocity:Ct.velocity,u_horizontalOscillationRadius:Ct.horizontalOscillationRadius,u_horizontalOscillationRate:Ct.horizontalOscillationRate,u_boxSize:Ct.boxSize,u_billboardSize:Ct.billboardSize,u_simpleShapeParameters:Ct.simpleShapeParameters,u_screenSize:Ct.screenSize,u_thinningCenterPos:Ct.thinningCenterPos,u_thinningShape:Ct.thinningShape,u_thinningAffectedRatio:Ct.thinningAffectedRatio,u_thinningParticleOffset:Ct.thinningParticleOffset,u_particleColor:Ct.color,u_direction:Ct.direction});var Ct;const wt=Math.round(Ie.intensity*this.particlesCount),gt=i.bg.simpleSegment(0,0,4*wt,2*wt);this.particlesVx&&this.particlesIdx&&be.draw(h,le.TRIANGLES,Br.disabled,bn.disabled,Gn.alphaBlended,gn.disabled,Nt,"snow_particles",this.particlesVx,this.particlesIdx,gt)})(v.boxSize,0,v),this._vignette.draw(h,D)}}const Oy={symbol:function(T,h,v,A,D){if(T.renderPass!=="translucent")return;const F=bn.disabled,B=T.colorModeForRenderPass(),W=v.layout.get("text-variable-anchor"),ee=v.layout.get("text-size-scale-range"),ae=i.aA(T.scaleFactor,ee[0],ee[1]);W&&function(be,Ne,Re,Ie,Ze,Ve,at,ht){const ot=Ne.transform,At=Ze==="map",Nt=Ve==="map";for(const Ct of be){const wt=Ie.getTile(Ct),gt=wt.getBucket(Re);if(!gt||!gt.text||!gt.text.segments.get().length)continue;const Dt=i.bK(gt.textSizeData,ot.zoom,ht),Ht=Xm(Ct,gt.getProjection(),ot),Ut=ot.calculatePixelsToTileUnitsMatrix(wt),es=Js(Ht,wt.tileID.canonical,Nt,At,ot,gt.getProjection(),Ut),ts=gt.hasIconTextFit()&>.hasIconData();Dt&&an(gt,At,Nt,at,ot,es,Ct,Math.pow(2,ot.zoom-wt.tileID.overscaledZ),Dt,ts)}}(A,T,v,h,v.layout.get("text-rotation-alignment"),v.layout.get("text-pitch-alignment"),D,ae);const le=v.paint.get("icon-opacity").constantOr(1)!==0,we=v.paint.get("text-opacity").constantOr(1)!==0;v.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(le||we)?y2(T,h,v,A,F,B):(le&&y2(T,h,v,A,F,B,{onlyIcons:!0}),we&&y2(T,h,v,A,F,B,{onlyText:!0})),h.map.showCollisionBoxes&&(Cr(T,h,v,A,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),!0),Cr(T,h,v,A,v.paint.get("icon-translate"),v.paint.get("icon-translate-anchor"),!1))},circle:function(T,h,v,A){if(T.renderPass!=="translucent")return;const D=v.paint.get("circle-opacity"),F=v.paint.get("circle-stroke-width"),B=v.paint.get("circle-stroke-opacity"),W=v.layout.get("circle-sort-key").constantOr(1)!==void 0,ee=v.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||B.constantOr(1)===0))return;const ae=T.context,le=ae.gl,we=T.transform,be=!(!T.terrain||!T.terrain.enabled),Ne=v.layout.get("circle-elevation-reference"),Re=T.depthModeForSublayer(0,Br.ReadOnly),Ie=new Br(T.context.gl.LEQUAL,Br.ReadOnly,T.depthRangeFor3D),Ze=Ne==="none"||be?Re:Ie,Ve=bn.disabled,at=T.colorModeForDrapableLayerRenderPass(ee),ht=we.projection.name==="globe",ot=[i.aF(we.center.lng),i.aJ(we.center.lat)],At=[];for(let Ct=0;CtCt.sortKey-wt.sortKey);const Nt={useDepthForOcclusion:we.depthOcclusionForSymbolsAndCircles};for(const Ct of At){const{programConfiguration:wt,program:gt,layoutVertexBuffer:Dt,dynamicBuffers:Ht,indexBuffer:Ut,uniformValues:es,tile:ts}=Ct.state,_s=Ct.segments;T.terrain&&T.terrain.setupElevationDraw(ts,gt,Nt),T.uploadCommonUniforms(ae,gt,ts.tileID.toUnwrapped()),gt.draw(T,le.TRIANGLES,Ze,Ve,at,gn.disabled,es,v.id,Dt,Ut,_s,v.paint,we.zoom,wt,Ht)}},heatmap:function(T,h,v,A){if(v.paint.get("heatmap-opacity")!==0)if(T.renderPass==="offscreen"){const D=T.context,F=D.gl,B=bn.disabled,W=new Gn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(Ne,Re,Ie,Ze){const Ve=Ne.gl,at=Re.width*Ze,ht=Re.height*Ze;Ne.activeTexture.set(Ve.TEXTURE1),Ne.viewport.set([0,0,at,ht]);let ot=Ie.heatmapFbo;if(!ot||ot&&(ot.width!==at||ot.height!==ht)){ot&&ot.destroy();const At=Ve.createTexture();Ve.bindTexture(Ve.TEXTURE_2D,At),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=Ie.heatmapFbo=Ne.createFramebuffer(at,ht,1,null),function(Nt,Ct,wt,gt,Dt,Ht){const Ut=Nt.gl;Ut.texImage2D(Ut.TEXTURE_2D,0,Nt.extRenderToTextureHalfFloat?Ut.RGBA16F:Ut.RGBA,Dt,Ht,0,Ut.RGBA,Nt.extRenderToTextureHalfFloat?Ut.HALF_FLOAT:Ut.UNSIGNED_BYTE,null),gt.colorAttachment0.set(wt)}(Ne,0,At,ot,at,ht)}else Ve.bindTexture(Ve.TEXTURE_2D,ot.colorAttachment0.get()),Ne.bindFramebuffer.set(ot.framebuffer)})(D,T,v,T.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const ee=T.transform,ae=ee.projection.name==="globe",le=ae?["PROJECTION_GLOBE_VIEW"]:[],we=ae?gn.frontCCW:gn.disabled,be=[i.aF(ee.center.lng),i.aJ(ee.center.lat)];for(let Ne=0;Ne({u_image:0,u_color_ramp:1,u_opacity:we.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(T,v))},line:function(T,h,v,A){if(T.renderPass!=="translucent")return;const D=v.paint.get("line-opacity"),F=v.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const B=v.paint.get("line-emissive-strength").isConstant(),W=v.paint.get("line-emissive-strength").constantOr(0),ee=v.paint.get("line-occlusion-opacity"),ae=v.layout.get("line-elevation-reference"),le=v.layout.get("line-width-unit")==="meters",we=ae==="sea",be=!(!T.terrain||!T.terrain.enabled),Ne=T.context,Re=Ne.gl;if(v.hasElevatedBuckets&&T.transform.projection.name==="globe")return;const Ie=v.layout.get("line-cross-slope"),Ze=Ie!==void 0,Ve=Ie<1,at=T.colorModeForDrapableLayerRenderPass(B?W:null),ht=T.terrain&&T.terrain.renderingToTexture,ot=ht?1:i.o.devicePixelRatio,At=v.paint.get("line-dasharray"),Nt=At.constantOr(1),Ct=v.layout.get("line-cap"),wt=At.constantOr(null),gt=Ct.constantOr(null),Dt=v.paint.get("line-pattern"),Ht=Dt.constantOr(1),Ut=v.paint.get("line-pattern-cross-fade"),es=Dt.constantOr(null),ts=v.paint.get("line-opacity").constantOr(1);let _s=!Ht&&ts!==1||T.depthOcclusion&&ee>0&&ee<1;const Ks=v.paint.get("line-gradient"),Yt=Ht?"linePattern":"line",zt=i.e2(v);let is;if(ht&&T.terrain&&T.terrain.clipOrMaskOverlapStencilType()&&(_s=!1),ee!==0&&T.depthOcclusion){const br=v.paint._values["line-opacity"];br&&br.value&&br.value.kind==="constant"?is=br.value:i.w(`Occlusion opacity for layer ${v.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&zt.push("VARIABLE_LINE_WIDTH"),ht&&(T.emissiveMode!=="dual-source-blending"||B?T.emissiveMode==="mrt-fallback"&&zt.push("USE_MRT1"):zt.push("DUAL_SOURCE_BLENDING"));const Jt=(br,er,Zs,Dr,Pr,pr)=>{for(const wr of br){const Qr=h.getTile(wr);if(Ht&&!Qr.patternsLoaded())continue;const On=Qr.getBucket(v);if(!On||On.elevationType!=="none"&&!Pr||On.elevationType==="none"&&Pr)continue;T.prepareDrawTile();const Sa=[...er],oi=T.shadowRenderer,Fr=On.elevationType==="road"&&!!oi&&oi.enabled;let ei=[0,0,0];if(Fr){const Zn=T.style.directionalLight,eo=T.style.ambientLight;Zn&&eo&&(ei=ag(T.style,Zn,eo)),Sa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const En=On.programConfigurations.get(v.id);let pi=!1;if(es&&Qr.imageAtlas){const Zn=i.e3.from(es),eo=Zn.getPrimary().scaleSelf(ot).toString(),Ko=Qr.imageAtlas.patternPositions.get(eo),ko=Zn.getSecondary(),Ri=ko?Qr.imageAtlas.patternPositions.get(ko.scaleSelf(ot).toString()):null;pi=!!Ko&&!!Ri,Ko&&En.setConstantPatternPositions(Ko,Ri)}Ut>0&&(pi||En.getPatternTransitionVertexBuffer("line-pattern"))&&Sa.push("LINE_PATTERN_TRANSITION");const Ti=T.isTileAffectedByFog(wr),ji=T.getOrCreateProgram(Yt,{config:En,defines:Sa,overrideFog:Ti});if(!Ht&&wt&>&&Qr.lineAtlas){const Zn=Qr.lineAtlas.getDash(wt,gt);Zn&&En.setConstantPatternPositions(Zn)}Fr&&oi.setupShadows(Qr.tileID.toUnwrapped(),ji,"vector-tile");let[Xa,Kn]=v.paint.get("line-trim-offset");(gt==="round"||gt==="square")&&Xa!==Kn&&(Xa===0&&(Xa-=1),Kn===1&&(Kn+=1));const hi=ht?wr.projMatrix:null,To=le?1/On.tileToMeter/i.ay(Qr,1,T.transform.zoom):1,oo=le?1/On.tileToMeter/i.ay(Qr,1,Math.floor(T.transform.zoom)):1,fi=Ht?i.e4(T,Qr,v,hi,ot,To,oo,[Xa,Kn],ei,Ut):i.e5(T,Qr,v,hi,On.lineClipsArray.length,ot,To,oo,[Xa,Kn],ei);if(Ks){const Zn=On.gradients[v.id];let eo=Zn.texture;if(v.gradientVersion!==Zn.version){let Ko=256;if(v.stepInterpolant){const ko=h.getSource().maxzoom,Ri=wr.canonical.z===ko?Math.ceil(1<{is!=null&&(is.value=ts*ee),ji.draw(T,Re.TRIANGLES,Zs,Zn,at,gn.disabled,fi,v.id,On.layoutVertexBuffer,On.indexBuffer,On.segments,v.paint,T.transform.zoom,En,[On.layoutVertexBuffer2,On.patternVertexBuffer,On.zOffsetVertexBuffer]),is!=null&&(is.value=ts)};if(_s&&!Pr){const Zn=T.stencilModeForClipping(wr).ref;Zn===0&&ht&&Ne.clear({stencil:0});const eo={func:Re.EQUAL,mask:255};fi.u_alpha_discard_threshold=.8,Va(new bn(eo,Zn,255,Re.KEEP,Re.KEEP,Re.INVERT)),fi.u_alpha_discard_threshold=0,Va(new bn(eo,Zn,255,Re.KEEP,Re.KEEP,Re.KEEP))}else fi.u_alpha_discard_threshold=_s&&Pr&&pr?.8:0,Va(Pr?Dr:T.stencilModeForClipping(wr))}};let zs=T.depthModeForSublayer(0,Br.ReadOnly);const ir=new Br(T.depthOcclusion?Re.GREATER:Re.LEQUAL,Br.ReadOnly,T.depthRangeFor3D);if(v.hasNonElevatedBuckets){const br=!ht&&T.terrain;ee!==0&&br?i.w(`Occlusion opacity for layer ${v.id} is supported on terrain only if the layer has line-z-offset enabled.`):br?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${v.id}.`):Jt(A,zt,zs,bn.disabled,!1,!0)}if(v.hasElevatedBuckets){ae==="hd-road-markup"?be||(zs=ir,zt.push("ELEVATED_ROADS")):(zt.push("ELEVATED"),zs=ir,Ze&&zt.push(Ve?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),we&&zt.push("ELEVATION_REFERENCE_SEA"));const br=_s?T.stencilModeFor3D():bn.disabled;T.forceTerrainMode=!0,Jt(A,zt,zs,br,!0,!0),_s&&Jt(A,zt,zs,br,!0,!1),T.forceTerrainMode=!1}_s&&(T.resetStencilClippingMasks(),ht&&Ne.clear({stencil:0})),ee===0||T.depthOcclusion||ht||T.layersWithOcclusionOpacity.push(T.currentLayer)},fill:function(T,h,v,A){const D=v.paint.get("fill-color"),F=v.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const B=v.paint.get("fill-emissive-strength"),W=T.colorModeForDrapableLayerRenderPass(B),ee=v.paint.get("fill-pattern"),ae=T.opaquePassEnabledForLayer()&&!ee.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let le="none";v.layout.get("fill-elevation-reference")!=="none"?le="road":v.paint.get("fill-z-offset").constantOr(1)!==0&&(le="offset");const we=!(!T.terrain||!T.terrain.enabled),be={painter:T,sourceCache:h,layer:v,coords:A,colorMode:W,elevationType:le,terrainEnabled:we,pass:ae};if(T.renderPass==="shadow")return void(T.shadowRenderer&&le==="road"&&!we&&function(Re){const{painter:Ie,sourceCache:Ze,layer:Ve,coords:at}=Re,ht=Ie.context.gl,ot=Re.painter.shadowRenderer;for(const At of at){const Nt=Ze.getTile(At),Ct=Nt.getBucket(Ve);if(!Ct)continue;const wt=Ct.elevatedStructures;if(!wt||!wt.shadowCasterSegments||wt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ie.prepareDrawTile();const gt=Ct.bufferData.programConfigurations.get(Ve.id),Dt=Ie.isTileAffectedByFog(At),Ht=Ie.getOrCreateProgram("elevatedStructuresDepth",{config:gt,overrideFog:Dt}),Ut=ot.calculateShadowPassMatrixFromTile(Nt.tileID.toUnwrapped());Ie.uploadCommonUniforms(Ie.context,Ht,At.toUnwrapped());const es={u_matrix:Ut,u_depth_bias:0};Ht.draw(Ie,ht.TRIANGLES,ot.getShadowPassDepthMode(),bn.disabled,ot.getShadowPassColorMode(),gn.disabled,es,Ve.id,wt.vertexBuffer,wt.indexBuffer,wt.shadowCasterSegments,Ve.paint,Ie.transform.zoom,gt)}}(be));const Ne=T.emissiveMode==="mrt-fallback";if(le!=="offset"){if(CC(be,!1,Ne),le==="road"){const Re=!we&&T.renderPass==="translucent";Re&&SC(T,h,v,A,"geometry"),CC(be,!0,Ne,bn.disabled),Re&&function(Ie){const{painter:Ze,sourceCache:Ve,layer:at,coords:ht,colorMode:ot}=Ie,At=Ze.context.gl,Nt=Ie.painter.shadowRenderer,Ct=!!Nt&&Nt.enabled,wt=new Br(Ze.context.gl.LEQUAL,Br.ReadOnly,Ze.depthRangeFor3D);let gt=[0,0,0];if(Ct){const Ht=Ze.style.directionalLight,Ut=Ze.style.ambientLight;Ht&&Ut&&(gt=ag(Ze.style,Ht,Ut))}const Dt=Ht=>{for(const Ut of ht){const es=Ve.getTile(Ut),ts=es.getBucket(at);if(!ts)continue;const _s=ts.elevatedStructures;if(!_s)continue;let Ks,Yt;if(Ht?(Ks=_s.renderableBridgeSegments,Yt=_s.bridgeProgramConfigurations.get(at.id)):(Ks=_s.renderableTunnelSegments,Yt=_s.tunnelProgramConfigurations.get(at.id)),!Ks||Ks.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),Ze.prepareDrawTile();const zt=Ze.isTileAffectedByFog(Ut),is=[];Ct&&is.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=Ze.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:zt,defines:is}),zs=Ze.translatePosMatrix(Ut.projMatrix,es,at.paint.get("fill-translate"),at.paint.get("fill-translate-anchor"));Ct&&Nt.setupShadows(es.tileID.toUnwrapped(),Jt,"vector-tile");const ir=Ey(zs,gt);Ze.uploadCommonUniforms(Ze.context,Jt,Ut.toUnwrapped()),Jt.draw(Ze,At.TRIANGLES,wt,bn.disabled,ot,gn.backCCW,ir,at.id,_s.vertexBuffer,_s.indexBuffer,Ks,at.paint,Ze.transform.zoom,Yt,[_s.vertexBufferNormal])}};Dt(!0),Dt(!1)}(be)}}else CC(be,!1,Ne,T.stencilModeFor3D())},"fill-extrusion":function(T,h,v,A){const D=v.paint.get("fill-extrusion-opacity"),F=T.context,B=F.gl,W=T.terrain,ee=W&&W.renderingToTexture;if(D===0)return;const ae=T.emissiveMode==="mrt-fallback",le=T.conflationActive&&T.style.isLayerClipped(v,h.getSource()),we=T.style.order.indexOf(v.fqid);if(le&&function(be,Ne,Re,Ie,Ze){for(const Ve of Ie){const at=Ne.getTile(Ve).getBucket(Re);at&&(at.updateReplacement(Ve,be.replacementSource,Ze),at.uploadCentroid(be.context))}}(T,h,v,A,we),W||le)for(const be of A){const Ne=h.getTile(be).getBucket(v);Ne&&rpe(T.context,h,be,Ne,v,W,le)}if(T.renderPass==="shadow"&&T.shadowRenderer){const be=T.shadowRenderer;if(W&&D<.65&&v._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const Ne=be.getShadowPassDepthMode(),Re=be.getShadowPassColorMode();MC(T,h,v,A,Ne,bn.disabled,Re,le)}else if(T.renderPass==="translucent"){const be=!v.paint.get("fill-extrusion-pattern").constantOr(1),Ne=v.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!ee&&Ne.a!==0){const Re=new Br(T.context.gl.LEQUAL,Br.ReadWrite,T.depthRangeFor3D);D===1&&be?MC(T,h,v,A,Re,bn.disabled,Gn.unblended,le):(MC(T,h,v,A,Re,bn.disabled,Gn.disabled,le),MC(T,h,v,A,Re,T.stencilModeFor3D(),T.colorModeForRenderPass(),le),T.resetStencilClippingMasks())}if(T.style.enable3dLights()&&be&&(!W&&T.transform.projection.name!=="globe"||ee)){const Re=v.paint.get("fill-extrusion-opacity"),Ie=v.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ze=v.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Ve=v.paint.get("fill-extrusion-flood-light-intensity"),at=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ht=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(at?null:v.lut).toArray01().slice(0,3),ot=Ie>0&&Ze>0,At=Ve>0,Nt=(gt,Dt,Ht)=>(1-Ht)*gt+Ht*Dt,Ct=new R6;Ct.translate=v.paint.get("fill-extrusion-translate"),Ct.translateAnchor=v.paint.get("fill-extrusion-translate-anchor"),Ct.edgeRadius=v.layout.get("fill-extrusion-edge-radius"),Ct.cutoffFadeRange=v.paint.get("fill-extrusion-cutoff-fade-range");const wt=gt=>{const Dt=T.depthModeForSublayer(1,Br.ReadOnly,B.LEQUAL,!0),Ht=v.paint.get(gt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ut=Nt(.1,3,Ht),es=T._showOverdrawInspector;if(!es){const ts=new bn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),_s=new Gn([B.ONE,B.ONE,B.ONE,B.ONE],i.ao.transparent,[!1,!1,!1,!0],B.MIN);lg(Ct,T,h,v,A,Dt,ts,_s,gn.disabled,gt,"sdf",Re,Ie,Ze,Ve,ht,Ut,le,!1)}{const ts=es?bn.disabled:new bn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),_s=es?T.colorModeForRenderPass():new Gn([B.ONE_MINUS_DST_ALPHA,B.DST_ALPHA,B.ONE,B.ONE],i.ao.transparent,[!0,!0,!0,!0]);lg(Ct,T,h,v,A,Dt,ts,_s,gn.disabled,gt,"color",Re,Ie,Ze,Ve,ht,Ut,le,!1)}};if(ee){const gt=()=>{const Ht=W.drapeBufferSize[0],Ut=W.drapeBufferSize[1];let es=W.framebufferCopyTexture;return es&&(!es||es.size[0]===Ht&&es.size[1]===Ut)||(es&&es.destroy(),es=W.framebufferCopyTexture=new i.T(F,new i.q({width:Ht,height:Ut}),B.RGBA8)),es.bind(B.LINEAR,B.CLAMP_TO_EDGE),B.copyTexSubImage2D(B.TEXTURE_2D,0,0,0,0,0,Ht,Ut),es},Dt=(Ht,Ut,es)=>{const ts=T.depthModeForSublayer(1,Br.ReadOnly,B.LEQUAL,!1),_s=v.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ks=Nt(.1,3,_s);{const Yt=new Gn([B.ONE,B.ONE,B.ONE,B.ONE],i.ao.transparent,[!1,!1,!1,!0]);lg(Ct,T,h,v,A,ts,bn.disabled,Yt,gn.disabled,Ht,"clear",Re,Ie,Ze,Ve,ht,Ks,le,Ut)}{const Yt=new bn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),zt=new Gn([B.ONE,B.ONE,B.ONE,B.ONE],i.ao.transparent,[!1,!1,!1,!0],B.MIN);lg(Ct,T,h,v,A,ts,Yt,zt,gn.disabled,Ht,"sdf",Re,Ie,Ze,Ve,ht,Ks,le,Ut)}ae&&!Ht&&(es=gt());{const Yt=Ht?B.ZERO:B.ONE_MINUS_DST_ALPHA,zt=new bn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),is=new Gn([Yt,B.DST_ALPHA,B.ONE_MINUS_DST_ALPHA,B.ZERO],i.ao.transparent,[!0,!0,!0,!0]);lg(Ct,T,h,v,A,ts,zt,is,gn.disabled,Ht,"color",Re,Ie,Ze,Ve,ht,Ks,le,Ut)}if(!ae||Ht){const Yt=new Gn([B.ONE,B.ONE,B.ONE,Ht?B.ZERO:B.ONE],i.ao.transparent,[!1,!1,!1,!0],Ht?B.FUNC_ADD:B.MAX);lg(Ct,T,h,v,A,ts,bn.disabled,Yt,gn.disabled,Ht,"clear",Re,Ie,Ze,Ve,ht,Ks,le,Ut,es)}else{B.drawBuffers([B.NONE,B.COLOR_ATTACHMENT1]);const Yt=new bn({func:B.EQUAL,mask:255},254,255,B.KEEP,B.DECR,B.DECR),zt=new Gn([B.ONE,B.ONE,B.ONE,B.ONE],i.ao.transparent,[!0,!1,!1,!1],B.MAX);lg(Ct,T,h,v,A,ts,Yt,zt,gn.disabled,Ht,"emissive",Re,Ie,Ze,Ve,ht,Ks,le,Ut,es),B.drawBuffers([B.COLOR_ATTACHMENT0])}};if(ot||At){let Ht;T.prepareDrawTile(),ae&&!ot||(Ht=gt()),ot&&Dt(!0,!1,Ht),At&&Dt(!1,!0,Ht)}}else ot&&wt(!0),At&&wt(!1),(ot||At)&&T.resetStencilClippingMasks()}}},building:function(T,h,v,A){T.currentLayer0&&F>0,ae=!0;const le=v.paint.get("building-vertical-scale");if(le<=0)return;T.shadowRenderer||(ae=!1);const we=T.conflationActive&&T.style.isLayerClipped(v,h.getSource()),be=T.style.order.indexOf(v.fqid);if(function(Ne,Re,Ie,Ze,Ve,at){for(const ht of at){const ot=Re.getTile(ht).getBucket(Ie);ot&&(Ve&&ot.updateReplacement(ht,Ne.replacementSource,Ze),ot.uploadUpdatedIndexBuffer(Ne.context))}}(T,h,v,be,we,A),function(Ne,Re,Ie,Ze){for(const Ve of Ze){const at=Re.getTile(Ve).getBucket(Ie);at&&at.needsEvaluation()&&at.uploadUpdatedColorBuffer(Ne.context)}}(T,h,v,A),v.resetLayerRenderingStats(T),T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0),T.renderPass==="shadow"&&T.shadowRenderer){const Ne=T.shadowRenderer,Re=[],Ie=Ne.getShadowPassDepthMode();v2({painter:T,source:h,layer:v,coords:A,defines:Re,blendMode:Ne.getShadowPassColorMode(),depthMode:Ie,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"];ae&&(Ne=Ne.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),T.shadowRenderer&&T.shadowRenderer.useNormalOffset&&(Ne=Ne.concat("NORMAL_OFFSET"));const Re=v.paint.get("building-facade-emissive-chance"),Ie=v.paint.get("building-ambient-occlusion-intensity"),Ze=v.paint.get("building-flood-light-intensity"),Ve=v.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",at=v.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Ve?null:v.lut).toArray01().slice(0,3),ht=v.paint.get("building-flood-light-ground-attenuation"),ot=Ze>0,At=new Br(T.context.gl.LEQUAL,Br.ReadWrite,T.depthRangeFor3D);W<1&&v2({painter:T,source:h,layer:v,coords:A,defines:Ne,blendMode:Gn.disabled,depthMode:At,opacity:W,verticalScale:le,facadeEmissiveChance:Re,facadeAOIntensity:Ie,floodLightIntensity:Ze,floodLightColor:at,depthOnly:!0});const Nt=T.colorModeForRenderPass();v2({painter:T,source:h,layer:v,coords:A,defines:Ne,blendMode:Nt,depthMode:At,opacity:W,verticalScale:le,facadeEmissiveChance:Re,facadeAOIntensity:Ie,floodLightIntensity:Ze,floodLightColor:at}),ee&&TC(T,h,v,A,!0,W,D,F,Ze,at,B,we),ot&&TC(T,h,v,A,!1,W,D,F,Ze,at,ht,we)}else if(T.renderPass==="light-beam"){const Ne=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Re=new Br(T.context.gl.LEQUAL,Br.ReadOnly,T.depthRangeFor3D);v2({painter:T,source:h,layer:v,coords:A,defines:Ne,blendMode:Gn.alphaBlended,depthMode:Re,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,v,A){if(T.renderPass!=="offscreen"&&T.renderPass!=="translucent"||T.style.disableElevatedTerrain)return;const D=T.context,F=T.terrain&&T.terrain.renderingToTexture,[B,W]=T.renderPass!=="translucent"||F?[{},A]:T.stencilConfigForOverlap(A);for(const ee of W){const ae=h.getTile(ee);if(ae.needsHillshadePrepare&&T.renderPass==="offscreen")Wme(T,ae,v);else if(T.renderPass==="translucent"){const le=T.depthModeForSublayer(0,Br.ReadOnly),we=v.paint.get("hillshade-emissive-strength"),be=T.colorModeForDrapableLayerRenderPass(we),Ne=F&&T.terrain?T.terrain.stencilModeForRTTOverlap(ee):B[ee.overscaledZ];Gme(T,ee,ae,v,le,Ne,be)}}D.viewport.set([0,0,T.width,T.height]),T.resetStencilClippingMasks()},raster:function(T,h,v,A,D,F){if(T.renderPass!=="translucent"||v.paint.get("raster-opacity")===0)return;const B=T.transform.projection.name==="globe",W=v.paint.get("raster-elevation")!==0,ee=W&&B;if(T.renderElevatedRasterBackface&&!ee)return;const ae=T.context,le=ae.gl,we=h.getSource(),be=function(Nt,Ct,wt,gt,Dt){const Ht=Ct.paint.get("raster-color"),Ut=Nt.type==="raster-array",es=[],ts=Ct.paint.get("raster-resampling"),_s=Ct.paint.get("raster-color-mix");let Ks=Ct.paint.get("raster-color-range");const Yt=[_s[0],_s[1],_s[2],0],zt=_s[3];let is=ts==="nearest"?gt.NEAREST:gt.LINEAR;if(Ut&&(es.push("RASTER_ARRAY"),Ht||es.push("RASTER_COLOR"),ts==="linear"&&es.push("RASTER_ARRAY_LINEAR"),is=gt.NEAREST,!Ks&&Nt.rasterLayers)){const Jt=Nt.rasterLayers.find(({id:zs})=>zs===Ct.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(Ks=Jt.fields.range)}if(Ks=Ks||[0,1],Ht){es.push("RASTER_COLOR"),wt.activeTexture.set(gt.TEXTURE2),Ct.updateColorRamp(Ks);let Jt=Ct.colorRampTexture;Jt||(Jt=Ct.colorRampTexture=new i.T(wt,Ct.colorRamp,gt.RGBA8)),Jt.bind(gt.LINEAR,gt.CLAMP_TO_EDGE)}return Dt&&es.push("USE_MRT1"),{mix:Yt,range:Ks,offset:zt,defines:es,resampling:is}}(we,v,ae,le,T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback");if(we instanceof i.aU&&!A.length&&!B)return;const Ne=v.paint.get("raster-emissive-strength"),Re=T.colorModeForDrapableLayerRenderPass(Ne),Ie=T.terrain&&T.terrain.renderingToTexture,Ze=!T.options.moving,Ve=v.paint.get("raster-resampling")==="nearest"?le.NEAREST:le.LINEAR;if(we instanceof i.aU&&!A.length&&(we.onNorthPole||we.onSouthPole)){const Nt=W?T.stencilModeFor3D():bn.disabled;return void b2(!!we.onNorthPole,null,T,h,v,Ne,be,gn.disabled,Nt)}if(!A.length)return;const[at,ht]=we instanceof i.aU||Ie?[{},A]:T.stencilConfigForOverlap(A),ot=ht[ht.length-1].overscaledZ;ee&&be.defines.push("PROJECTION_GLOBE_VIEW"),W&&be.defines.push("RENDER_CUTOFF");const At=(Nt,Ct,wt)=>{for(const gt of Nt){const Dt=gt.toUnwrapped(),Ht=h.getTile(gt);if(Ie&&(!Ht||!Ht.hasData()))continue;ae.activeTexture.set(le.TEXTURE0);const Ut=dg(Ht,we,v,be);if(!Ut||!Ut.texture)continue;const{texture:es,mix:ts,offset:_s,tileSize:Ks,buffer:Yt}=Ut;let zt,is;Ie?(zt=Br.disabled,is=gt.projMatrix):W?(zt=new Br(le.LEQUAL,Br.ReadWrite,T.depthRangeFor3D),is=B?Float32Array.from(T.transform.expandedFarZProjMatrix):T.transform.calculateProjMatrix(Dt,Ze)):(zt=T.depthModeForSublayer(gt.overscaledZ-ot,v.paint.get("raster-opacity")===1?Br.ReadWrite:Br.ReadOnly,le.LESS),is=T.transform.calculateProjMatrix(Dt,Ze));const Jt=T.terrain&&Ie?T.terrain.stencilModeForRTTOverlap(gt):at[gt.overscaledZ],zs=F?0:v.paint.get("raster-fade-duration");Ht.registerFadeDuration(zs);const ir=h.findLoadedParent(gt,0),br=p2(Ht,ir,h,T.transform,zs);let er,Zs;!br.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),T.terrain&&T.terrain.prepareDrawTile(),ae.activeTexture.set(le.TEXTURE0),es.bind(Ve,le.CLAMP_TO_EDGE),ae.activeTexture.set(le.TEXTURE1),ir?(ir.texture&&ir.texture.bind(Ve,le.CLAMP_TO_EDGE),er=Math.pow(2,ir.tileID.overscaledZ-Ht.tileID.overscaledZ),Zs=[Ht.tileID.canonical.x*er%1,Ht.tileID.canonical.y*er%1]):es.bind(Ve,le.CLAMP_TO_EDGE),"useMipmap"in es&&ae.extTextureFilterAnisotropic&&T.transform.pitch>20&&le.texParameterf(le.TEXTURE_2D,ae.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ae.extTextureFilterAnisotropicMax);const Dr=T.transform;let Pr;const pr=W?_F(Dr):[0,0,0,0];let wr,Qr,On,Sa,oi,Fr=0;if(ee&&we instanceof i.aU&&we.coordinates.length>3)wr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Qr=Float32Array.from(Dr.globeMatrix),On=Float32Array.from(i.dF(Dr)),Sa=[i.aF(Dr.center.lng),i.aJ(Dr.center.lat)],Pr=we.elevatedGlobePerspectiveTransform,oi=we.elevatedGlobeGridMatrix||new Float32Array(9);else if(ee){const Ti=i.dG(gt.canonical);Fr=i.dH(Ti.getCenter().lat),wr=Float32Array.from(i.bk(i.dJ(gt.canonical))),Qr=Float32Array.from(Dr.globeMatrix),On=Float32Array.from(i.dF(Dr)),Sa=[i.aF(Dr.center.lng),i.aJ(Dr.center.lat)],Pr=[0,0],oi=Float32Array.from(i.dI(gt.canonical,Ti,Fr,Dr.worldSize/Dr._pixelsPerMercatorPixel))}else Pr=we instanceof i.aU?we.perspectiveTransform:[0,0],wr=new Float32Array(16),Qr=new Float32Array(9),On=new Float32Array(16),Sa=[0,0],oi=new Float32Array(9);const ei=pF(is,wr,Qr,On,oi,Zs||[0,0],i.aj(T.transform.zoom),Sa,pr,er||1,br,v,Pr,W?v.paint.get("raster-elevation"):0,2,ts,_s,be.range,Ks,Yt,Ne),En=T.isTileAffectedByFog(gt),pi=T.getOrCreateProgram("raster",{defines:be.defines,overrideFog:En});if(T.uploadCommonUniforms(ae,pi,Dt),we instanceof i.aU){const Ti=we.elevatedGlobeVertexBuffer,ji=we.elevatedGlobeIndexBuffer;if(Ie||!B)we.boundsBuffer&&we.boundsSegments&&pi.draw(T,le.TRIANGLES,zt,bn.disabled,Re,gn.disabled,ei,v.id,we.boundsBuffer,T.quadTriangleIndexBuffer,we.boundsSegments);else if(Ti&&ji){const Xa=Dr.zoom<=i.c_?we.elevatedGlobeSegments:we.getSegmentsForLongitude(Dr.center.lng);Xa&&pi.draw(T,le.TRIANGLES,zt,bn.disabled,Re,Ct,ei,v.id,Ti,ji,Xa)}}else if(ee){zt=new Br(le.LEQUAL,Br.ReadOnly,T.depthRangeFor3D);const Ti=T.globeSharedBuffers;if(Ti){const[ji,Xa,Kn]=Ti.getGridBuffers(Fr,!1);pi.draw(T,le.TRIANGLES,zt,wt||Jt,T.colorModeForRenderPass(),Ct,ei,v.id,ji,Xa,Kn)}}else{const{tileBoundsBuffer:Ti,tileBoundsIndexBuffer:ji,tileBoundsSegments:Xa}=T.getTileBoundsBuffers(Ht);pi.draw(T,le.TRIANGLES,zt,Jt,Re,gn.disabled,ei,v.id,Ti,ji,Xa)}}if(!(we instanceof i.aU)&&ee)for(const gt of Nt){const Dt=gt.canonical.y===(1<>>16,2654435769),((gt=Math.imul(gt^gt>>>16,2654435769))>>>0)/4294967296},wt=1/1.1;for(let gt=0;gti.e9[Jt](es));Yt.push(es);const zt=es.canonical.x,is=es.canonical.y;for(const Jt of Yt){const zs=ot.getTile(Dt?Jt.wrapped():Jt);if(!zs)continue;const ir=zs.rasterParticleState;if(!ir)continue;const br=Jt.canonical.x+(1<Ct.tileID)),Ne&&(ae.activeTexture.set(le.TEXTURE0),T.imageManager.bind(T.context,v.scope));const Nt=[];if(T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&Nt.push("USE_MRT1"),ee){const Ct=T.getOrCreateProgram(ht,{overrideFog:!1,overrideRtt:!0,defines:Nt}),wt=new Float32Array(i.bA([])),gt=new i.aQ(0,0,0,0,0),Dt=Ne?Iy(wt,W,B,T,0,v.scope,Re,ee,{tileID:gt,tileSize:be}):x2(wt,W,B,D.toPremultipliedRenderColor(F?null:v.lut));Ct.draw(T,le.TRIANGLES,Ve,Ze,at,gn.disabled,Dt,v.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments)}else for(const Ct of At){const wt=T.isTileAffectedByFog(Ct),gt=T.getOrCreateProgram(ht,{overrideFog:wt,defines:Nt}),Dt=Ct.toUnwrapped(),Ht=A?Ct.projMatrix:T.transform.calculateProjMatrix(Dt);T.prepareDrawTile();const Ut=h?h.getTile(Ct):ot?ot[Ct.key]:new Qm(Ct,be,we.zoom,T),es=Ne?Iy(Ht,W,B,T,0,v.scope,Re,ee,{tileID:Ct,tileSize:be}):x2(Ht,W,B,D.toPremultipliedRenderColor(F?null:v.lut));T.uploadCommonUniforms(ae,gt,Dt);const{tileBoundsBuffer:ts,tileBoundsIndexBuffer:_s,tileBoundsSegments:Ks}=T.getTileBoundsBuffers(Ut);gt.draw(T,le.TRIANGLES,Ve,Ze,at,gn.disabled,es,v.id,ts,_s,Ks)}},sky:function(T,h,v){const A=T._atmosphere?i.aj(T.transform.zoom):1,D=v.paint.get("sky-opacity")*A;if(D===0)return;const F=T.context,B=v.paint.get("sky-type"),W=new Br(F.gl.LEQUAL,Br.ReadOnly,[0,1]),ee=T.frameCounter/1e3%1;B==="atmosphere"?T.renderPass==="offscreen"?v.needsSkyboxCapture(T)&&(function(ae,le,we,be){const Ne=ae.context,Re=Ne.gl;let Ie=le.skyboxFbo;if(!Ie){Ie=le.skyboxFbo=Ne.createFramebuffer(32,32,1,null),le.skyboxGeometry=new IC(Ne),le.skyboxTexture=Ne.gl.createTexture(),Re.bindTexture(Re.TEXTURE_CUBE_MAP,le.skyboxTexture),Re.texParameteri(Re.TEXTURE_CUBE_MAP,Re.TEXTURE_WRAP_S,Re.CLAMP_TO_EDGE),Re.texParameteri(Re.TEXTURE_CUBE_MAP,Re.TEXTURE_WRAP_T,Re.CLAMP_TO_EDGE),Re.texParameteri(Re.TEXTURE_CUBE_MAP,Re.TEXTURE_MIN_FILTER,Re.LINEAR),Re.texParameteri(Re.TEXTURE_CUBE_MAP,Re.TEXTURE_MAG_FILTER,Re.LINEAR);for(let ht=0;ht<6;++ht)Re.texImage2D(Re.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0,Re.RGBA,32,32,0,Re.RGBA,Re.UNSIGNED_BYTE,null)}Ne.bindFramebuffer.set(Ie.framebuffer),Ne.viewport.set([0,0,32,32]);const Ze=le.getCenter(ae,!0),Ve=ae.getOrCreateProgram("skyboxCapture"),at=new Float64Array(16);i.bA(at),i.en(at,at,.5*-Math.PI),yv(ae,le,Ve,at,Ze,0),i.bA(at),i.en(at,at,.5*Math.PI),yv(ae,le,Ve,at,Ze,1),i.bA(at),i.cU(at,at,.5*-Math.PI),yv(ae,le,Ve,at,Ze,2),i.bA(at),i.cU(at,at,.5*Math.PI),yv(ae,le,Ve,at,Ze,3),i.bA(at),yv(ae,le,Ve,at,Ze,4),i.bA(at),i.en(at,at,Math.PI),yv(ae,le,Ve,at,Ze,5),Ne.viewport.set([0,0,ae.width,ae.height])}(T,v),v.markSkyboxValid(T)):T.renderPass==="sky"&&function(ae,le,we,be,Ne){const Re=ae.context,Ie=Re.gl,Ze=ae.transform,Ve=ae.getOrCreateProgram("skybox");Re.activeTexture.set(Ie.TEXTURE0),Ie.bindTexture(Ie.TEXTURE_CUBE_MAP,le.skyboxTexture);const at=((ht,ot,At,Nt,Ct)=>({u_matrix:ht,u_sun_direction:ot,u_cubemap:0,u_opacity:Nt,u_temporal_offset:Ct}))(Ze.skyboxMatrix,le.getCenter(ae,!1),0,be,Ne);ae.uploadCommonUniforms(Re,Ve),Ve.draw(ae,Ie.TRIANGLES,we,bn.disabled,ae.colorModeForRenderPass(),gn.backCW,at,"skybox",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,v,W,D,ee):B==="gradient"&&T.renderPass==="sky"&&function(ae,le,we,be,Ne){const Re=ae.context,Ie=Re.gl,Ze=ae.transform,Ve=ae.getOrCreateProgram("skyboxGradient");le.skyboxGeometry||(le.skyboxGeometry=new IC(Re)),Re.activeTexture.set(Ie.TEXTURE0);let at=le.colorRampTexture;at||(at=le.colorRampTexture=new i.T(Re,le.colorRamp,Ie.RGBA8)),at.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const ht=((ot,At,Nt,Ct,wt)=>({u_matrix:ot,u_color_ramp:0,u_center_direction:At,u_radius:i.an(Nt),u_opacity:Ct,u_temporal_offset:wt}))(Ze.skyboxMatrix,le.getCenter(ae,!1),le.paint.get("sky-gradient-radius"),be,Ne);ae.uploadCommonUniforms(Re,Ve),Ve.draw(ae,Ie.TRIANGLES,we,bn.disabled,ae.colorModeForRenderPass(),gn.backCW,ht,"skyboxGradient",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,v,W,D,ee)},custom:function(T,h,v,A){const D=T.context,F=v.implementation;if(!T.transform.projection.unsupportedLayers||!T.transform.projection.unsupportedLayers.includes("custom")||T.terrain&&(T.terrain.renderingToTexture||T.renderPass==="offscreen")&&v.isDraped(h)){if(T.renderPass==="offscreen"){const B=F.prerender;if(B){if(T.setCustomLayerDefaults(),D.setColorMode(T.colorModeForRenderPass()),T.transform.projection.name==="globe"){const W=T.transform.pointMerc;B.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 B.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 ee=A[0].canonical,ae={x:ee.x+A[0].wrap*(F.wrapTileId?0:1<{ae&&(ae.useNormalOffset=!0,le||(ae.enabled=!0))},be=h.getSource();if(T.renderPass==="light-beam"&&be.type!=="batched-model")return;if(be.type==="vector"||be.type==="geojson")return function(ot,At,Nt,Ct,wt){const gt=ot.transform,Dt=gt.projection.name==="globe",Ht=gt.getFreeCameraOptions().position;if(!ot.modelManager)return;const Ut=ot.modelManager;Nt.modelManager=Ut;const es=ot.shadowRenderer;if(!Nt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ts=Nt._unevaluatedLayout._values["model-id"],_s=Object.assign({},Nt.layout.get("model-id").parameters),Ks=ot.style.order.indexOf(Nt.fqid),Yt=Nt.paint.get("model-opacity").constantOr(1);for(const zt of Ct){const is=At.getTile(zt).getBucket(Nt);if(!is||is.projection.name!==gt.projection.name)continue;const Jt=is.getModelUris();if(Jt&&!is.modelsRequested&&(Ut.addModelsFromBucket(Jt,wt),is.modelsRequested=!0),Dt)_s.zoom=zt.overscaledZ;else{const pr=Uu(zt,gt);_s.zoom=pr}const zs=ts.possiblyEvaluate(_s);if(PF(ot,is,zt),Yf.shadowUniformsInitialized=!1,Yf.useSingleShadowCascade=!!es&&es.getMaxCascadeForTile(zt.toUnwrapped())===0,ot.renderPass==="shadow"&&es){if(ot.currentShadowCascade===1&&is.isInsideFirstShadowMapFrustum)continue;const pr=gt.calculatePosMatrix(zt.toUnwrapped(),gt.worldSize);if(Yf.tileMatrix.set(pr),Yf.shadowTileMatrix=Float32Array.from(es.calculateShadowPassMatrixFromMatrix(pr)),Yf.aabb.min=[0,0,0],Yf.aabb.max[0]=Yf.aabb.max[1]=i.al,Yf.aabb.max[2]=0,ipe(is,Yf,ot,Nt.scope))continue}const ir=1<0&&ot.style.isLayerClipped(Nt,At.getSource())&&is.updateReplacement(zt,ot.replacementSource,Ks,Nt.scope)&&(is.uploaded=!1,is.upload(ot.context));let er=0;const Zs=new Array,Dr=new Array,Pr=new Array;for(let pr in is.instancesPerModel){const wr=is.instancesPerModel[pr];wr.features.length>0&&!Dt&&(pr=zs.evaluate(wr.features[0].feature,{}));const Qr=Ut.getModel(pr,wt);if(Qr||Ut.hasURLBeenRequested(pr)||is.modelUris.includes(pr)||(is.modelUris.push(pr),is.modelsRequested=!1),Qr&&Qr.uploaded)if(Dt){const On=i.c5([],[Ht.x,Ht.y,Ht.z],ot.transform.worldSize);i.ew(On,On);for(let Sa=0;Sa0&&ei.elevationUpdate(pr.terrain,Sa,Fr,Qr.source),ei.needsReEvaluation(pr,oi,Qr)&&ei.evaluate(Qr))}})(ot,At,Nt,Ct),function(){let pr,wr,Qr;Zs?(pr=Ct.length-1,wr=-1,Qr=-1):(pr=0,wr=Ct.length,Qr=1);const On=new Float64Array(16),Sa=i.cA(),oi=new i.P(0,0);for(let Fr=pr;Fr!==wr;Fr+=Qr){const ei=Ct[Fr],En=At.getTile(ei).getBucket(Nt);if(!En||!En.uploaded)continue;let pi=!1;Ht&&(pi=Ht.getMaxCascadeForTile(ei.toUnwrapped())===0);const Ti=gt.calculatePosMatrix(ei.toUnwrapped(),gt.worldSize),ji=En.modelTraits;!ir&&Zs&&(i.bl(On,Ti),i.af(Sa,es,On),oi.x=Sa[0],oi.y=Sa[1]);const Xa=[];En.setFilter(Nt.filter);for(const Kn of En.getNodesInfo()){if(Kn.hiddenByReplacement||!Kn.node.meshes)continue;const hi=Kn.node;let To=0;ot.terrain&&hi.elevation&&(To=hi.elevation*ot.terrain.exaggeration());const oo=(()=>{const Wd=Kn.aabb;return zs.min=[...Wd.min],zs.max=[...Wd.max],zs.min[2]+=To,zs.max[2]+=To,i.af(zs.min,zs.min,Ti),i.af(zs.max,zs.max,Ti),zs})(),fi=Kn.evaluatedScale;if(fi[0]<=1&&fi[1]<=1&&fi[2]<=1&&oo.intersects(br)===0)continue;if(!ir&&Zs){const Wd=.16666666666666666;Kn.cameraCollisionOpacity=es[0]>oo.min[0]&&es[0]oo.min[1]&&es[1]!Zs||Kn.opacity===1&&hi.opacity===1?Kn.depthhi.depth?-1:1);for(const Kn of Xa){const hi=Kn.nodeInfo,To=hi.node;let oo=i.aB([],Yt,Kn.tileModelMatrix);i.aB(oo,_s,oo);const fi=i.bl([],oo);i.eg(fi,fi),i.cS(fi,fi,w2),oo=i.aB(oo,oo,To.globalMatrix);const Va=ot.renderPass==="light-beam",Zn=Nt.paint.get("model-color-use-theme").constantOr("default")==="none",eo=ji&i.eI.HasMapboxMeshFeatures,Ko=eo?0:hi.evaluatedRMEA[0][2];for(let ko=0;ko=Ns||So>=Ns}}const ld=Ri.material;let gm;ld.occlusionTexture&&ld.occlusionTexture.offsetScale&&(gm=ld.occlusionTexture.offsetScale,Kl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const ip=ot.getOrCreateProgram("model",Kl);!ir&&Ht&&Ht.setupShadowsFromMatrix(Kn.tileModelMatrix,ip,Ht.useNormalOffset),ot.uploadCommonUniforms(wt,ip,null,Kd);const xh=ld.pbrMetallicRoughness;xh.metallicFactor=.9,xh.roughnessFactor=.5;const Ro=mv(new Float32Array(Ed),new Float32Array(oo),new Float32Array(fi),new Float32Array(To.globalMatrix),ot,Kn.opacity,xh.baseColorFactor,ld.emissiveFactor,xh.metallicFactor,xh.roughnessFactor,ld,Ko,Nt,[0,0,0],gm);!Vu&&(hi.hasTranslucentParts||Kn.opacity<1)&&ip.draw(ot,wt.gl.TRIANGLES,is,bn.disabled,Gn.disabled,gn.backCCW,Ro,Nt.id,Ri.vertexBuffer,Ri.indexBuffer,Ri.segments,Nt.paint,ot.transform.zoom,void 0,Wd),ip.draw(ot,wt.gl.TRIANGLES,Vu?Jt:is,bn.disabled,Vu||Kn.opacity<1||hi.hasTranslucentParts?Gn.alphaBlended:Gn.unblended,gn.backCCW,Ro,Nt.id,Ri.vertexBuffer,Ri.indexBuffer,Ri.segments,Nt.paint,ot.transform.zoom,void 0,Wd)}}}}()}(T,h,v,A),void we();if(be.type!=="model")return;const Ne=be.getModels(),Re=[],Ie=T.transform.getFreeCameraOptions().position,Ze=i.c5([],[Ie.x,Ie.y,Ie.z],T.transform.worldSize);i.ew(Ze,Ze);const Ve=[],at=[];let ht=0;for(const ot of Ne){const At=h.getFeatureState("",ot.id),Nt={type:"Unknown",id:ot.id,properties:ot.featureProperties},Ct=v.paint.get("model-rotation").evaluate(Nt,At),wt=v.paint.get("model-scale").evaluate(Nt,At),gt=v.paint.get("model-translation").evaluate(Nt,At),Dt=v.paint.get("model-opacity").evaluate(Nt,At);TF(v,ot.id,At,ot.featureProperties,ot.nodeOverrideNames,ot.nodeOverrides),AF(v,ot.id,At,ot.featureProperties,ot.materialOverrideNames,ot.materialOverrides),ot.nodeOverrides.size>0&&ot.computeBoundsAndApplyParent(),ot.computeModelMatrix(T,Ct,wt,gt,W,B,!1);const Ht=i.bA([]),Ut=i.ef(ot.position.lat,T.transform.zoom),es=i.bq([],[1,1,1/Ut]);i.br(Ht,Ht,Ze),Re.push({zScaleMatrix:es,negCameraPosMatrix:Ht});for(const ts of ot.nodes)vv(T,ts,ot.matrix,T.transform.expandedFarZProjMatrix,ht,Ve,at,ot.materialOverrides,Dt);ht++}if(Ve.sort((ot,At)=>At.depth-ot.depth),T.renderPass!=="shadow")EF(T,v,Ve,at,Re),we();else{for(const ot of at)Up(ot.mesh,ot.nodeModelMatrix,T,v);for(const ot of Ve)Up(ot.mesh,ot.nodeModelMatrix,T,v);we()}}},BC={line:function(T,h,v){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,v){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(v.modelManager&&v.modelManager.upload(v,_2(v,T)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(v.context)},raster:function(T,h,v){const A=h.getSource();if(!(A instanceof Md&&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 B=h.getIds().map(W=>h.getTileByID(W));for(const W of B)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)},"raster-particle":function(T,h,v){const A=h.getSource();if(!(A instanceof Md&&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 B=h.getIds().map(W=>h.getTileByID(W));for(const W of B)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)}},xm={fill:SC},$C={fill:function(T,h,v,A){if(!v.layout||v.layout.get("fill-elevation-reference")==="none"||v.paint.get("fill-opacity").constantOr(1)===0)return;const D=T.context.gl,F=new Br(D.LEQUAL,Br.ReadOnly,T.depthRangeFor3D),B=new bn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=T.transform.getFreeCameraOptions().position,ee=T.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ae of A){const le=h.getTile(ae),we=le.getBucket(v);if(!we)continue;const be=we.elevatedStructures;if(!be||be.depthSegments.segments[0].primitiveLength===0)continue;const Ne=bF(ae.toUnwrapped(),W),Re=T.translatePosMatrix(ae.projMatrix,le,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor")),Ie=hv(Re,Ne,0,1,0);ee.draw(T,D.TRIANGLES,F,B,Gn.disabled,gn.disabled,Ie,v.id,be.vertexBuffer,be.indexBuffer,be.depthSegments,v.paint,T.transform.zoom)}}};class qC{constructor(h,v,A,D,F){this.context=new vb(h,v),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 B=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const ee of B)this._debugParams.enabledLayers[ee]=!0;for(const ee of B);this.occlusionParams=new _b,this.setup(),this.numSublayers=Il.maxUnderzooming+Il.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 ob(this),this._wireframeDebugCache=new Dy,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,v){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new M6(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,v),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const v=h.fog;if(!v||this.transform.projection.name==="globe"||v.getOpacity(this.transform.pitch)<1||v.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=v.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 M6(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,v){if(this.width=h*i.o.devicePixelRatio,this.height=v*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,v=new i.bd;v.emplaceBack(0,0),v.emplaceBack(i.al,0),v.emplaceBack(0,i.al),v.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(v,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 B=new i.b0;B.emplaceBack(0,1,2),B.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(B);const W=new i.be;for(const ae of[0,1,3,2,0])W.emplaceBack(ae);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 ee=this.context.gl;this.stencilClearMode=new bn({func:ee.ALWAYS,mask:0},0,255,ee.ZERO,ee.ZERO,ee.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,Br.disabled,this.stencilClearMode,Gn.disabled,gn.disabled,m2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,v,A){if(!v||this.currentStencilSource===v.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const ee of A)if(this._tileClippingMaskIDs[ee.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=v.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(Gn.disabled),D.setDepthMode(Br.disabled);const B=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of A){const ee=v.getTile(W),ae=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:le,tileBoundsIndexBuffer:we,tileBoundsSegments:be}=this.getTileBoundsBuffers(ee);B.draw(this,F.TRIANGLES,Br.disabled,new bn({func:F.ALWAYS,mask:0},ae,255,F.KEEP,F.KEEP,F.REPLACE),Gn.disabled,gn.disabled,m2(W.projMatrix),"$clipping",le,we,be)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,v=this.context.gl;return new bn({func:v.NOTEQUAL,mask:255},h,255,v.KEEP,v.KEEP,v.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const v=this.context.gl;return new bn({func:v.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,v.KEEP,v.KEEP,v.REPLACE)}stencilConfigForOverlap(h){const v=this.context.gl,A=h.sort((B,W)=>W.overscaledZ-B.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 B={};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,v)=>h+v/this._fpsHistory.length,0))}render(h,v){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=v;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),B=()=>this.style._getOrder(F).filter(Yt=>{const zt=D[Yt];return!(zt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[zt.type]});let W=B(),ee=!1,ae=!1,le=null,we=0,be=!1;for(const Yt of W){const zt=D[Yt];zt.visibility!=="none"&&(zt.type==="circle"?ee=!0:zt.type==="building"?(le=zt,++we):zt.type==="symbol"&&(zt.hasOcclusionOpacityProperties?ae=!0:ee=!0))}this.updateEmissiveMode();let Ne=W.map(Yt=>D[Yt]);const Re=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 Re){const zt=Re[Yt];zt.used&&(zt.prepare(this.context),zt.getSource().usedInConflation&&++we)}let Ie=!1;for(const Yt of Ne)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Ie=!0),this.prepareLayer(Yt));const Ze={},Ve={},at={},ht={},ot={};for(const Yt in Re){const zt=Re[Yt];Ze[Yt]=zt.getVisibleCoordinates(),Ve[Yt]=Ze[Yt].slice().reverse(),at[Yt]=zt.getVisibleCoordinates(!0).reverse(),ht[Yt]=zt.getShadowCasterCoordinates(),ot[Yt]=zt.sortCoordinatesByDistance(Ze[Yt])}const At=Yt=>{const zt=this.style.getLayerSourceCache(Yt);return zt&&zt.used?zt.getSource():null};if(we||Ie||this._clippingActiveLastFrame){const Yt=[],zt=[];let is=0;for(const Jt of Ne)this.isSourceForClippingOrConflation(Jt,At(Jt))&&(Yt.push(Jt),zt.push(is)),is++;if(Yt&&(Ie||Yt.length>1)||this._clippingActiveLastFrame){Ie=!1;const Jt=[];for(let zs=0;zs0){const Jt=At(zt);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),zt.minzoom&&(this.minCutoffZoom=Math.max(zt.minzoom,this.minCutoffZoom))}zt.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const 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(at),this.opaquePassCutoff=0,W=B(),Ne=W.map(Yt=>D[Yt]));const Ct=this._shadowRenderer;if(Ct){Ct.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Re)for(const zt of Ze[Yt]){let is={min:0,max:0};this.terrain&&(is=this.terrain.getMinMaxForTile(zt)||is),Ct.addShadowReceiver(zt.toUnwrapped(),is.min,is.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eR(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new MF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const wt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),gt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(wt&&!this._snow&&(this._snow=new V6(this)),!wt&&this._snow&&(this._snow.destroy(),delete this._snow),gt&&!this._rain&&(this._rain=new zC(this)),!gt&&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 LC);const Yt=this.style.getLayerSourceCache(le);this.buildingTileBorderManager.updateBorders(Yt,le)}if(!Xe.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of Ne){const zt=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const is=zt?Ve[zt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||is&&is.length)&&this.renderLayer(this,zt,Yt,is)}this.depthRangeFor3D=[0,1-(Ne.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ht)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Dt=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(v.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const zt=this.style.getLut(Yt.scope);if(!Dt){const is=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(is?null:zt).toArray01();return new i.ao(...Jt)}if(Dt){const is=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(is?null:zt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Ht,depth:1}),this.clearStencil(),this._showOverdrawInspector=v.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Dt&&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],zt=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const is=zt?(Yt.is3D(F)?ot:Ve)[zt.id]:void 0;this._renderTileClippingMasks(Yt,zt,is),this.renderLayer(this,zt,Yt,is)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Dt&&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 is=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const is=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const zs=Ne[this.currentLayer],ir=h.getLayerSourceCache(zs),br=ir?Ve[ir.id]:void 0;this.terrain||this._renderTileClippingMasks(zs,ir,ir?Ze[ir.id]:void 0),this.renderLayer(this,ir,zs,br)}this.depthOcclusion=!1,this.currentLayer=is,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;Ne.forEach(zt=>{const is=h.getLayerSourceCache(zt);is&&!zt.isHidden(this.transform.zoom)&&is.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?v.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,v,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||v!==void 0&&!v||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,v){this.cache=this.cache||{};const A=v&&v.defines||[],D=v&&v.config,F=this.currentGlobalDefines(h,v&&v.overrideFog,v&&v.overrideRtt).concat(A),B=oF.cacheKey(f6[h],h,F,D);return this.cache[B]||(this.cache[B]=new oF(this.context,h,f6[h],D,kC[h],F)),this.cache[B]}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,v){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((B,W,ee)=>{const ae=B.properties.get("direction"),le=B.properties.get("color-use-theme")==="none",we=B.properties.get("color").toNonPremultipliedRenderColor(le?null:ee.getLut(B.scope)).toArray01(),be=B.properties.get("intensity"),Ne=W.properties.get("color-use-theme")==="none",Re=W.properties.get("color").toNonPremultipliedRenderColor(Ne?null:ee.getLut(W.scope)).toArray01(),Ie=W.properties.get("intensity"),Ze=[ae.x,ae.y,ae.z],Ve=i.dN(Re,Ie),at=i.dN(we,be);return{u_lighting_ambient_color:Ve,u_lighting_directional_dir:Ze,u_lighting_directional_color:at,u_ground_radiance:xb(Ze,at,Ve)}})(A,D,this.style);v.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,v,A,D,F){if(this.uploadCommonLightUniforms(h,v),this.terrain&&this.terrain.renderingToTexture)return;const B=this.style.fog;if(B){const W=B.getOpacity(this.transform.pitch),ee=((ae,le,we,be,Ne,Re,Ie,Ze,Ve,at,ht,ot)=>{const At=ae.transform,Nt=le.properties.get("color-use-theme")==="none",Ct=le.properties.get("color").toNonPremultipliedRenderColor(Nt?null:ae.style.getLut(le.scope)).toArray01();Ct[3]=be;const wt=ae.frameCounter/1e3%1,[gt,Dt]=le.properties.get("vertical-range");return{u_fog_matrix:we?At.calculateFogTileMatrix(we):ot||ae.identityMat,u_fog_range:le.getFovAdjustedRange(At._fov),u_fog_color:Ct,u_fog_horizon_blend:le.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(gt,Dt),Dt],u_fog_temporal_offset:wt,u_frustum_tl:Ne,u_frustum_tr:Re,u_frustum_br:Ie,u_frustum_bl:Ze,u_globe_pos:Ve,u_globe_radius:at,u_viewport:ht,u_globe_transition:i.aj(At.zoom),u_is_globe:+(At.projection.name==="globe")}})(this,B,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);v.setFogUniformValues(h,ee)}F&&v.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,v=h.createTexture();return h.bindTexture(h.TEXTURE_2D,v),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),v}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,v=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)v[D.key]=h[D.key]||new Qm(D,512,this.transform.tileZoom,this,void 0,this.worldview);return v}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,v){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")&&(!v||v.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let v=this._cachedTileFogOpacities[h.key];return v||(this._cachedTileFogOpacities[h.key]=v=this.style.fog.getOpacityForTile(h)),v[0]>=Ns||v[1]>=Ns}setupDepthForOcclusion(h,v,A){const D=this.context,F=D.gl,B=!!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),B||v.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 UC(T,h){let v=!1,A=null;const D=()=>{A=null,v&&(T(),A=setTimeout(D,h),v=!1)};return()=>(v=!0,A||D(),A)}class H6{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=UC(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 v=Gl(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(B=>{const W=B.split("=")[0];return W===A?(D=!0,`${W}=${v}`):B}).filter(B=>B);return D||F.push(`${A}=${v}`),`#${F.join("&")}`}return`#${v}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let v;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(v=A)}),(v&&v[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const v=this._getCurrentHash();if(v.length>=3&&!v.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(v[3]||0):h.getBearing();return h.jumpTo({center:[+v[2],+v[1]],zoom:+v[0],bearing:A,pitch:+(v[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Gl(T,h){const v=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),B=Math.round(v.lng*F)/F,W=Math.round(v.lat*F)/F,ee=T.getBearing(),ae=T.getPitch();let le=h?`/${B}/${W}/${A}`:`${A}/${W}/${B}`;return(ee||ae)&&(le+="/"+Math.round(10*ee)/10),ae&&(le+=`/${Math.round(ae)}`),le}const jb={linearity:.3,easing:i.eT(0,0,.3,1)},G6=Object.assign({deceleration:2500,maxSpeed:1400},jb),W6=Object.assign({deceleration:20,maxSpeed:1400},jb),_v=Object.assign({deceleration:1e3,maxSpeed:360},jb),K6=Object.assign({deceleration:1e3,maxSpeed:90},jb);class Z6{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,v=i.o.now();for(;h.length>0&&v-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const v={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)v.zoom+=F.zoomDelta||0,v.bearing+=F.bearingDelta||0,v.pitch+=F.pitchDelta||0,F.panDelta&&v.pan._add(F.panDelta),F.around&&(v.around=F.around),F.pinchAround&&(v.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(v.pan.mag()){const F=Qf(v.pan.mag(),A,Object.assign({},G6,h||{}));D.offset=v.pan.mult(F.amount/v.pan.mag()),D.center=this._map.transform.center,Nb(D,F)}if(v.zoom){const F=Qf(v.zoom,A,W6);D.zoom=this._map.transform.zoom+F.amount,Nb(D,F)}if(v.bearing){const F=Qf(v.bearing,A,_v);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),Nb(D,F)}if(v.pitch){const F=Qf(v.pitch,A,K6);D.pitch=this._map.transform.pitch+F.amount,Nb(D,F)}if(D.zoom||D.bearing){const F=v.pinchAround===void 0?v.around:v.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function Nb(T,h){(!T.duration||T.durationv.unproject(ee)),W=F.reduce((ee,ae,le,we)=>ee.add(ae.div(we.length)),new i.P(0,0));super(h,{points:F,point:W,lngLats:B,lngLat:v.unproject(W),originalEvent:A}),this._defaultPrevented=!1}}class Y6 extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,v){super("wheel",{originalEvent:v}),this._defaultPrevented=!1}}class VC{constructor(h,v){this._map=h,this._clickTolerance=v.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new Y6(this._map,h))}mousedown(h,v){return this._mousedownPos=v,this._firePreventable(new fh(h.type,this._map,h))}mouseup(h){this._map.fire(new fh(h.type,this._map,h))}preclick(h){const v=new MouseEvent("preclick",h);this._map.fire(new fh(v.type,this._map,v))}click(h,v){this._mousedownPos&&this._mousedownPos.dist(v)>=this._clickTolerance||(this.preclick(h),this._map.fire(new fh(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new fh(h.type,this._map,h))}mouseover(h){this._map.fire(new fh(h.type,this._map,h))}mouseout(h){this._map.fire(new fh(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Ry(h.type,this._map,h))}touchmove(h){this._map.fire(new Ry(h.type,this._map,h))}touchend(h){this._map.fire(new Ry(h.type,this._map,h))}touchcancel(h){this._map.fire(new Ry(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Q6{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new fh(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new fh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new fh(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class HC{constructor(h,v){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=v.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,v){this.isEnabled()&&h.shiftKey&&h.button===0&&(I(),this._startPos=this._lastPos=v,this._active=!0)}mousemoveWindow(h,v){if(!this._active)return;const A=v,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${B}px,${ee}px)`,this._box.style.width=W-B+"px",this._box.style.height=ae-ee+"px")})}mouseupWindow(h,v){if(!this._active)return;const A=this._startPos,D=v;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),P(),delete this._startPos,delete this._lastPos}_fireEvent(h,v){return this._map.fire(new i.z(h,{originalEvent:v}))}}function GC(T,h){const v={};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 B of D)F._add(B);return F.div(D.length)}(v),this.touches=GC(A,v)))}touchmove(h,v,A){if(this.aborted||!this.centroid)return;const D=GC(A,v);for(const F in this.touches){const B=D[F];(!B||B.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,v,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 WC{constructor(h){this.singleTap=new DF(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,v,A){this.singleTap.touchstart(h,v,A)}touchmove(h,v,A){this.singleTap.touchmove(h,v,A)}touchend(h,v,A){const D=this.singleTap.touchend(h,v,A);if(D){const F=h.timeStamp-this.lastTime<500,B=!this.lastTap||this.lastTap.dist(D)<30;if(F&&B||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class OF{constructor(){this._zoomIn=new WC({numTouches:1,numTaps:2}),this._zoomOut=new WC({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,v,A){this._zoomIn.touchstart(h,v,A),this._zoomOut.touchstart(h,v,A)}touchmove(h,v,A){this._zoomIn.touchmove(h,v,A),this._zoomOut.touchmove(h,v,A)}touchend(h,v,A){const D=this._zoomIn.touchend(h,v,A),F=this._zoomOut.touchend(h,v,A);return D?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:B=>B.easeTo({duration:300,zoom:B.getZoom()+1,around:B.unproject(D)},{originalEvent:h})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:B=>B.easeTo({duration:300,zoom:B.getZoom()-1,around:B.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 RF={0:1,2:2},X6={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class KC{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,v){return!1}_move(h,v){return{}}mousedown(h,v){if(this._lastPoint)return;const A=V(h);this._correctButton(h,A)&&(this._lastPoint=v,this._eventButton=A)}mousemoveWindow(h,v){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const B=RF[F];return D.buttons===void 0||(D.buttons&B)!==B}(h,this._eventButton))this.reset();else if(this._moved||!(v.dist(A)0&&(this._active=!0);const D=GC(A,v),F=new i.P(0,0),B=new i.P(0,0);let W=0;for(const ae in D){const le=D[ae],we=this._touches[ae];we&&(F._add(le),B._add(le.sub(we)),W++,D[ae]=le)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class ZC{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,v,A){return{}}touchstart(h,v,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([v[0],v[1]]))}touchmove(h,v,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,B]=D,W=j2(A,v,F),ee=j2(A,v,B);if(!W||!ee)return;const ae=this._aroundCenter?null:W.add(ee).div(2);return this._move([W,ee],ae,h)}touchend(h,v,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,B=j2(A,v,D),W=j2(A,v,F);B&&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 j2(T,h,v){for(let A=0;AMath.abs(T.x)}class lpe extends ZC{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,YC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,v,A){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),B=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(F,B,A.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+B.y)/2*-.5})}gestureBeginsVertically(h,v,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=v.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const B=h.y>0==v.y>0;return YC(h)&&YC(v)&&B}}const cpe={panStep:100,bearingStep:15,pitchStep:10};class dpe{constructor(){const h=cpe;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 v=0,A=0,D=0,F=0,B=0;switch(h.keyCode){case 61:case 107:case 171:case 187:v=1;break;case 189:case 109:case 173:v=-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(),B=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),B=1);break;default:return}return this._rotationDisabled&&(A=0,D=0),{cameraAnimation:W=>{const ee=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:N2,zoom:v?Math.round(ee)+v*(h.shiftKey?2:1):ee,bearing:W.getBearing()+A*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-B*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 N2(T){return T*(2-T)}const tP=4.000244140625,sP=1/450;class QC{constructor(h,v){this._map=h,this._el=h.getCanvasContainer(),this._handler=v,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=sP,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 v=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,v!==0&&v%tP==0?this._type="wheel":v!==0&&Math.abs(v)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=v,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*v)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,v+=this._lastValue)),h.shiftKey&&v&&(v/=4),this._type&&(this._lastWheelEvent=h,this._delta-=v,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 v=$(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:v,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 v=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ae=this._type==="wheel"&&Math.abs(this._delta)>tP?this._wheelZoomRate:this._defaultZoomRate;let le=2/(1+Math.exp(-Math.abs(this._delta*ae)));this._delta<0&&le!==0&&(le=1/le);const we=v(),be=Math.pow(2,we),Ne=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):be;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(Ne*le))),this._type==="wheel"&&(this._startZoom=we,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:v(),D=this._startZoom,F=this._easing;let B,W=!1;if(this._type==="wheel"&&D&&F){const ae=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),le=F(ae);B=i.ak(D,A,le),ae<1?this._frameId||(this._frameId=!0):W=!0}else B=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 ee=B-v();return ee*this._lastDelta<0&&(ee=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:ee,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let v=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),B=.27/Math.sqrt(F*F+1e-4)*.01,W=Math.sqrt(.0729-B*B);v=i.eT(B,W,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:v},v}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class hg{constructor(h,v){this._clickZoom=h,this._tapZoom=v}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class XC{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,v){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(v)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wl{constructor(){this._tap=new WC({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,v,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=v[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,v,A))}touchmove(h,v,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=v[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,v,A)}touchend(h,v,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,v,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 Xf{constructor(h,v,A){this._el=h,this._mousePan=v,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 k2{constructor(h,v,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=v,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 JC{constructor(h,v,A,D){this._el=h,this._touchZoom=v,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 S2=T=>T.zoom||T.drag||T.pitch||T.rotate;class upe extends i.z{}class C2{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,v){const A=i.av([],v,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 v=i.c5([],h,this.radius);if(v[2]>0){const A=i.c5([],[0,0,1],i.bJ(v,[0,0,1])),D=i.c5([],i.aw([],[v[0],v[1],0]),this.radius),F=i.d8([],v,i.c5([],i.av([],i.d8([],D,A),v),2));v[0]=F[0],v[1]=F[1]}return v}}function e5(T){return T.panDelta&&T.panDelta.mag()||T.zoomDelta||T.bearingDelta||T.pitchDelta}class hpe{constructor(h,v){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Z6(h),this._bearingSnap=v.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new C2,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(v),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,B]of this._listeners){const W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,W,B)}}destroy(){for(const[h,v,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(v,D,A)}}_addDefaultHandlers(h){const v=this._map,A=v.getCanvasContainer();this._add("mapEvent",new VC(v,h));const D=v.boxZoom=new HC(v,h);this._add("boxZoom",D);const F=new OF,B=new XC;v.doubleClickZoom=new hg(B,F),this._add("tapZoom",F),this._add("clickZoom",B);const W=new Wl;this._add("tapDragZoom",W);const ee=v.touchPitch=new lpe(v);this._add("touchPitch",ee);const ae=new J6(h),le=new eP(h);v.dragRotate=new k2(h,ae,le),this._add("mouseRotate",ae,["mousePitch"]),this._add("mousePitch",le,["mouseRotate"]);const we=new FF(h),be=new zF(v,h);v.dragPan=new Xf(A,we,be),this._add("mousePan",we),this._add("touchPan",be,["touchZoom","touchRotate"]);const Ne=new No,Re=new ope;v.touchZoomRotate=new JC(A,Re,Ne,W),this._add("touchRotate",Ne,["touchPan","touchZoom"]),this._add("touchZoom",Re,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Q6(v));const Ie=v.scrollZoom=new QC(v,this);this._add("scrollZoom",Ie,["mousePan"]);const Ze=v.keyboard=new dpe;this._add("keyboard",Ze);for(const Ve of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Ve]&&v[Ve].enable(h[Ve])}_add(h,v,A){this._handlers.push({handlerName:h,handler:v,allowed:A}),this._handlersById[h]=v}stop(h){if(!this._updatingCamera){for(const{handler:v}of this._handlers)v.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!!S2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,v,A){for(const D in h)if(D!==A&&(!v||v.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const v=[];for(const A of h)this._el.contains(A.target)&&v.push(A);return v}handleEvent(h,v){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},B={},W={},ee=h.touches?this._getMapTouches(h.touches):void 0,ae=ee?z(this._el,ee):A?void 0:$(this._el,h);for(const{handlerName:be,handler:Ne,allowed:Re}of this._handlers){if(!Ne.isEnabled())continue;let Ie;this._blockedByActive(W,Re,be)?Ne.reset():Ne[v||h.type]&&(Ie=Ne[v||h.type](h,ae,ee),this.mergeHandlerResult(F,B,Ie,be,D),Ie&&Ie.needsRenderFrame&&this._triggerRenderFrame()),(Ie||Ne.isActive())&&(W[be]=Ne)}const le={};for(const be in this._previousActiveHandlers)W[be]||(le[be]=D);this._previousActiveHandlers=W,(Object.keys(le).length||e5(F))&&(this._changes.push([F,B,le]),this._triggerRenderFrame()),(Object.keys(W).length||e5(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:we}=F;we&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],we(this._map))}mergeHandlerResult(h,v,A,D,F){if(!A)return;Object.assign(h,A);const B={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(v.zoom=B),A.panDelta!==void 0&&(v.drag=B),A.pitchDelta!==void 0&&(v.pitch=B),A.bearingDelta!==void 0&&(v.rotate=B)}_applyChanges(){const h={},v={},A={};for(const[D,F,B]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(v,F),Object.assign(A,B);this._updateMapTransform(h,v,A),this._changes=[]}_updateMapTransform(h,v,A){const D=this._map,F=D.transform,B=at=>[at.x,at.y,at.z];if((at=>{const ht=this._eventsInProgress.drag;return ht&&!this._handlersById[ht.handlerName].isActive()})()&&!e5(h)){const at=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"),at!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!e5(h))return void this._fireEvents(v,A,!0);let{panDelta:W,zoomDelta:ee,bearingDelta:ae,pitchDelta:le,around:we,aroundCoord:be,pinchAround:Ne}=h;F._isCameraConstrained&&(ee>0&&(ee=0),F._isCameraConstrained=!1),Ne!==void 0&&(we=Ne),(ee||(at=>v[at]&&!this._eventsInProgress[at])("drag"))&&we&&(this._dragOrigin=B(F.pointCoordinate3D(we)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),we=we||D.transform.centerPoint,ae&&(F.bearing+=ae),le&&(F.pitch+=le),F._updateCameraState();const Re=[0,0,0];if(W)if(F.projection.name==="mercator"){const at=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(we).dir),ht=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(we.sub(W)).dir);Re[0]=ht[0]-at[0],Re[1]=ht[1]-at[1]}else{const at=F.pointCoordinate(we);if(F.projection.name==="globe"){W=W.rotate(-F.angle);const ht=F._pixelsPerMercatorPixel/F.worldSize;Re[0]=-W.x*i.eW(i.a$(at.y))*ht,Re[1]=-W.y*i.eW(F.center.lat)*ht}else{const ht=F.pointCoordinate(we.sub(W));at&&ht&&(Re[0]=ht.x-at.x,Re[1]=ht.y-at.y)}}const Ie=F.zoom,Ze=[0,0,0];if(ee){const at=B(be||F.pointCoordinate3D(we)),ht={dir:i.aw([],i.av([],at,F._camera.position))};if(ht.dir[2]<0){const ot=F.zoomDeltaToMovement(at,ee);i.c5(Ze,ht.dir,ot)}}const Ve=i.d8(Re,Re,Ze);F._translateCameraConstrained(Ve),ee&&Math.abs(F.zoom-Ie)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(v,A,!0)}_fireEvents(h,v,A){const D=S2(this._eventsInProgress),F=S2(h),B={};for(const le in h){const{originalEvent:we}=h[le];this._eventsInProgress[le]||(B[`${le}start`]=we),this._eventsInProgress[le]=h[le]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const le in B)this._fireEvent(le,B[le]);F&&this._fireEvent("move",F.originalEvent);for(const le in h){const{originalEvent:we}=h[le];this._fireEvent(le,we)}const W={};let ee;for(const le in this._eventsInProgress){const{handlerName:we,originalEvent:be}=this._eventsInProgress[le];this._handlersById[we].isActive()||(delete this._eventsInProgress[le],ee=v[we]||be,W[`${le}end`]=ee)}for(const le in W)this._fireEvent(le,W[le]);const ae=S2(this._eventsInProgress);if(A&&(D||F)&&!ae){this._updatingCamera=!0;const le=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),we=be=>be!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new upe("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const t5="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class rP extends i.E{constructor(h,v){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=v.bearingSnap,this._respectPrefersReducedMotion=v.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,v){return this.jumpTo({center:h},v)}panBy(h,v,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},v),A)}panTo(h,v,A){return this.easeTo(Object.assign({center:h},v),A)}getZoom(){return this.transform.zoom}setZoom(h,v){return this.jumpTo({zoom:h},v),this}zoomTo(h,v,A){return this.easeTo(Object.assign({zoom:h},v),A)}zoomIn(h,v){return this.zoomTo(this.getZoom()+1,h,v),this}zoomOut(h,v){return this.zoomTo(this.getZoom()-1,h,v),this}getBearing(){return this.transform.bearing}setBearing(h,v){return this.jumpTo({bearing:h},v),this}getPadding(){return this.transform.padding}setPadding(h,v){return this.jumpTo({padding:h},v),this}rotateTo(h,v,A){return this.easeTo(Object.assign({bearing:h},v),A)}resetNorth(h,v){return this.rotateTo(0,Object.assign({duration:1e3},h),v),this}resetNorthPitch(h,v){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),v),this}snapToNorth(h,v){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,v,A,D,F,B){const W=h.clone(),ee=this._extendCameraOptions(B);W.bearing=D,W.pitch=F;const ae=i.aT.convert(v),le=i.aT.convert(A),we=.5*(ae.lat+le.lat),be=.5*(ae.lng+le.lng),Ne=i.eZ(we,be),Re=i.aw([],Ne),Ie=i.aw([],i.bI([],Re,[0,1,0])),Ze=i.bI([],Ie,Re),Ve=[Ie[0],Ie[1],Ie[2],0,Ze[0],Ze[1],Ze[2],0,Re[0],Re[1],Re[2],0,0,0,0,1],at=[Ne,i.eZ(ae.lat,ae.lng),i.eZ(le.lat,ae.lng),i.eZ(le.lat,le.lng),i.eZ(ae.lat,le.lng),i.eZ(we,ae.lng),i.eZ(we,le.lng),i.eZ(ae.lat,be),i.eZ(le.lat,be)];let ht=i.d9.fromPoints(at.map(Jt=>[i.bJ(Ie,Jt),i.bJ(Ze,Jt),i.bJ(Re,Jt)]));const ot=i.af([],ht.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 At=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),At);ht=i.d9.applyTransform(ht,i.aB([],At,Ve));const Ct=this._extendAABB(ht,W,ee,D);if(!Ct)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ht=Ct,i.af(ot,ot,At);const wt=.5*(ht.max[2]-ht.min[2]),gt=this._minimumAABBFrustumDistance(W,ht),Dt=i.c5([],[0,0,1],wt),Ht=i.d8(Dt,ot,Dt),Ut=gt+(W.pitch===0?0:i.bG(ot,Ht)),es=W.globeCenterInViewSpace,ts=i.av([],ot,[es[0],es[1],es[2]]);i.aw(ts,ts),i.c5(ts,ts,Ut);const _s=i.d8([],ot,ts);i.af(_s,_s,Nt);const Ks=i.eM/i.aD,Yt=i.ag(_s),zt=i.cf(Math.max(Yt*Ks-i.eM,Number.EPSILON),0),is=Math.min(W.zoomFromMercatorZAdjusted(zt),ee.maxZoom);return is>.5*(i.c_+i.cL)?(W.setProjection({name:"mercator"}),W.zoom=is,this._cameraForBounds(W,v,A,D,F,B)):{center:W.center,zoom:is,bearing:D,pitch:F}}_extendAABB(h,v,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),B=.5*((A.padding.top||0)+(A.padding.bottom||0)),W=B,ee=F,ae=F,le=B,we=v.width-(ee+ae),be=v.height-(W+le),Ne=i.av([],h.max,h.min),Re=Math.min(we/Ne[0],be/Ne[1]),Ie=Math.min(v.scaleZoom(v.scale*Re),A.maxZoom);if(isNaN(Ie))return null;const Ze=v.scale/v.zoomScale(Ie),Ve=new i.d9([h.min[0]-ee*Ze,h.min[1]-le*Ze,h.min[2]],[h.max[0]+ae*Ze,h.max[1]+W*Ze,h.max[2]]),at=(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]-=at.x*Ze,Ve.center[1]+=at.y*Ze,Ve}queryTerrainElevation(h,v){const A=this.transform.elevation;return A?(v=Object.assign({},{exaggerated:!0},v),A.getAtPoint(i.ae.fromLngLat(h),null,v.exaggerated)):null}_cameraForBounds(h,v,A,D,F,B){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,v,A,D,F,B);const W=h.clone(),ee=this._extendCameraOptions(B);W.bearing=D,W.pitch=F;const ae=i.aT.convert(v),le=i.aT.convert(A),we=new i.aT(ae.lng,le.lat),be=new i.aT(le.lng,ae.lat),Ne=W.project(ae),Re=W.project(le),Ie=this.queryTerrainElevation(ae),Ze=this.queryTerrainElevation(le),Ve=this.queryTerrainElevation(we),at=this.queryTerrainElevation(be),ht=[[Ne.x,Ne.y,Math.min(Ie||0,Ze||0,Ve||0,at||0)],[Re.x,Re.y,Math.max(Ie||0,Ze||0,Ve||0,at||0)]];let ot=i.d9.fromPoints(ht);const At=W.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),At);ot=i.d9.applyTransform(ot,At);const Ct=this._extendAABB(ot,W,ee,D);if(!Ct)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ot=Ct;const wt=.5*i.av([],ot.max,ot.min)[2],gt=this._minimumAABBFrustumDistance(W,ot),Dt=[0,0,1,0];i.aC(Dt,Dt,At),i.f1(Dt,Dt);const Ht=i.c5([],Dt,gt+wt),Ut=i.d8([],ot.center,Ht);i.af(ot.center,ot.center,Nt),i.af(Ut,Ut,Nt);const es=W.unproject(new i.P(ot.center[0],ot.center[1])),ts=i.f2(W.projection,es),_s=Math.pow(2,ts),Ks=Math.min(W._zoomFromMercatorZ(Ut[2]*W.pixelsPerMeter*_s/W.worldSize),ee.maxZoom);return W.mercatorFromTransition&&Ks<.5*(i.c_+i.cL)?(W.setProjection({name:"globe"}),W.zoom=Ks,this._cameraForBounds(W,v,A,D,F,B)):{center:es,zoom:Ks,bearing:D,pitch:F}}fitBounds(h,v,A){const D=this.cameraForBounds(h,v);return this._fitInternal(D,v,A)}fitScreenCoordinates(h,v,A,D,F){const B=i.P.convert(h),W=i.P.convert(v),ee=new i.P(Math.min(B.x,W.x),Math.min(B.y,W.y)),ae=new i.P(Math.max(B.x,W.x),Math.max(B.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(B,W))return this;const le=this.transform.pointLocation3D(ee),we=this.transform.pointLocation3D(ae),be=this.transform.pointLocation3D(new i.P(ee.x,ae.y)),Ne=this.transform.pointLocation3D(new i.P(ae.x,ee.y)),Re=[Math.min(le.lng,we.lng,be.lng,Ne.lng),Math.min(le.lat,we.lat,be.lat,Ne.lat)],Ie=[Math.max(le.lng,we.lng,be.lng,Ne.lng),Math.max(le.lat,we.lat,be.lat,Ne.lat)],Ze=D&&D.pitch?D.pitch:this.getPitch(),Ve=this._cameraForBounds(this.transform,Re,Ie,A,Ze,D);return this._fitInternal(Ve,D,F)}_fitInternal(h,v,A){return h?(v=Object.assign(h,v)).linear?this.easeTo(v,A):this.flyTo(v,A):this}jumpTo(h,v){this.stop();const A=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,B=!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&&(B=!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 ee=A.clone();ee.padding=W,A.setLocationAtPoint(A.center,ee.centerPoint)}else A.padding=W;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",v)).fire(new i.z("move",v)),D&&this.fire(new i.z("zoomstart",v)).fire(new i.z("zoom",v)).fire(new i.z("zoomend",v)),F&&this.fire(new i.z("rotatestart",v)).fire(new i.z("rotate",v)).fire(new i.z("rotateend",v)),B&&this.fire(new i.z("pitchstart",v)).fire(new i.z("pitch",v)).fire(new i.z("pitchend",v)),this.fire(new i.z("moveend",v)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(t5),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,v){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(t5),this;this.stop();const D=A.zoom,F=A.pitch,B=A.bearing;A.setFreeCameraOptions(h);const W=D!==A.zoom,ee=F!==A.pitch,ae=B!==A.bearing;return this.fire(new i.z("movestart",v)).fire(new i.z("move",v)),W&&this.fire(new i.z("zoomstart",v)).fire(new i.z("zoom",v)).fire(new i.z("zoomend",v)),ae&&this.fire(new i.z("rotatestart",v)).fire(new i.z("rotate",v)).fire(new i.z("rotateend",v)),ee&&this.fire(new i.z("pitchstart",v)).fire(new i.z("pitch",v)).fire(new i.z("pitchend",v)),this.fire(new i.z("moveend",v)),this}easeTo(h,v){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(),B=this.getPitch(),W=this.getPadding(),ee="zoom"in h?+h.zoom:D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:B,we=this._extendPadding(h.padding),be=i.P.convert(h.offset);let Ne,Re,Ie;if(A.projection.name==="globe"){const Dt=i.ae.fromLngLat(A.center),Ht=be.rotate(-A.angle);Dt.x+=Ht.x/A.worldSize,Dt.y+=Ht.y/A.worldSize;const Ut=Dt.toLngLat(),es=i.aT.convert(h.center||Ut);this._normalizeCenter(es),Ne=A.centerPoint.add(Ht),Re=new i.P(Dt.x,Dt.y).mult(A.worldSize),Ie=new i.P(i.aF(es.lng),i.aJ(es.lat)).mult(A.worldSize).sub(Re)}else{Ne=A.centerPoint.add(be);const Dt=A.pointLocation(Ne),Ht=i.aT.convert(h.center||Dt);this._normalizeCenter(Ht),Re=A.project(Dt),Ie=A.project(Ht).sub(Re)}const Ze=A.zoomScale(ee-D);let Ve,at;h.around&&(Ve=i.aT.convert(h.around),at=A.locationPoint(Ve));const ht=this._zooming||ee!==D,ot=this._rotating||F!==ae,At=this._pitching||le!==B,Nt=!A.isPaddingEqual(we),Ct=h.retainPadding===!1?A.clone():A,wt=Dt=>Ht=>{if(ht&&(Dt.zoom=i.ak(D,ee,Ht)),ot&&(Dt.bearing=i.ak(F,ae,Ht)),At&&(Dt.pitch=i.ak(B,le,Ht)),Nt&&(Ct.interpolatePadding(W,we,Ht),Ne=Ct.centerPoint.add(be)),Ve)Dt.setLocationAtPoint(Ve,at);else{const Ut=Dt.zoomScale(Dt.zoom-D),es=ee>D?Math.min(2,Ze):Math.max(.5,Ze),ts=Math.pow(es,1-Ht),_s=Dt.unproject(Re.add(Ie.mult(Ht*ts)).mult(Ut));Dt.setLocationAtPoint(Dt.renderWorldCopies?_s.wrap():_s,Ne)}return h.preloadOnly||this._fireMoveEvents(v),Dt};if(h.preloadOnly){const Dt=this._emulate(wt,h.duration,A);return this._preloadTiles(Dt),this}const gt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ht,this._rotating=ot,this._pitching=At,this._padding=Nt,this._easeId=h.easeId,this._prepareEase(v,h.noMoveStart,gt),this._ease(wt(A),Dt=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(v,Dt)},h),this}_prepareEase(h,v,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),v||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,v){if(this._easeId&&v&&this._easeId===v)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,v){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,v)}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(),B=this.getPitch(),W=this.getPadding(),ee="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:B,we=this._extendPadding(h.padding),be=A.zoomScale(ee-D),Ne=i.P.convert(h.offset);let Re=A.centerPoint.add(Ne);const Ie=A.pointLocation(Re),Ze=i.aT.convert(h.center||Ie);this._normalizeCenter(Ze);const Ve=A.project(Ie),at=A.project(Ze).sub(Ve);let ht=h.curve;const ot=Math.max(A.width,A.height),At=ot/be,Nt=at.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,ee),A.minZoom,A.maxZoom),zs=ot/A.zoomScale(Jt-D);ht=Math.sqrt(zs/Nt*2)}const Ct=ht*ht;function wt(Jt){const zs=(At*At-ot*ot+(Jt?-1:1)*Ct*Ct*Nt*Nt)/(2*(Jt?At:ot)*Ct*Nt);return Math.log(Math.sqrt(zs*zs+1)-zs)}function gt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Dt(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Ht=wt(0);let Ut=function(Jt){return Dt(Ht)/Dt(Ht+ht*Jt)},es=function(Jt){return ot*((Dt(Ht)*(gt(zs=Ht+ht*Jt)/Dt(zs))-gt(Ht))/Ct)/Nt;var zs},ts=(wt(1)-Ht)/ht;if(Math.abs(Nt)<1e-6||!isFinite(ts)){if(Math.abs(ot-At)<1e-6)return this.easeTo(h,v);const Jt=Ath.maxDuration&&(h.duration=0);const _s=F!==ae,Ks=le!==B,Yt=!A.isPaddingEqual(we),zt=h.retainPadding===!1?A.clone():A,is=Jt=>zs=>{const ir=zs*ts,br=1/Ut(ir);Jt.zoom=zs===1?ee:D+Jt.scaleZoom(br),_s&&(Jt.bearing=i.ak(F,ae,zs)),Ks&&(Jt.pitch=i.ak(B,le,zs)),Yt&&(zt.interpolatePadding(W,we,zs),Re=zt.centerPoint.add(Ne));const er=zs===1?Ze:Jt.unproject(Ve.add(at.mult(es(ir))).mult(br));return Jt.setLocationAtPoint(Jt.renderWorldCopies?er.wrap():er,Re),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(v),Jt};if(h.preloadOnly){const Jt=this._emulate(is,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=_s,this._pitching=Ks,this._padding=Yt,this._prepareEase(v,!1),this._ease(is(A),()=>this._afterEase(v),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,v){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,v)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,v,A){A.animate===!1||A.duration===0?(h(1),v()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=v,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),v=this._onEaseFrame;v&&v(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,v){h=i.bT(h,-180,180);const A=Math.abs(h-v);return Math.abs(h-360-v)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,v,A){const D=Math.ceil(15*v/1e3),F=[],B=h(A.clone());for(let W=0;W<=D;W++){const ee=B(W/D);F.push(ee.clone())}return F}_preloadTiles(h,v){}}class M2{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const v=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=w("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),v&&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),v===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 v=[{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=v.reduce((D,F,B)=>(F.value&&(D+=`${F.key}=${F.value}${BD.length-F.length),h=h.filter((D,F)=>{for(let B=F+1;B=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 B=new DOMParser().parseFromString(F,"text/html");return Array.from(B.body.querySelectorAll("*")).forEach(W=>{const ee=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(B.createTextNode(ee));const ae=W.getAttribute("href");if(!ae||!/^(https?:|mailto:)/i.test(ae))return void W.replaceWith(B.createTextNode(ee));const le=B.createElement("a");le.href=ae,le.textContent=ee,le.rel="noopener nofollow";const we=W.getAttribute("class");we&&(le.className=we),W.replaceWith(le)}),B.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 T2{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=w("div","mapboxgl-ctrl");const v=w("a","mapboxgl-ctrl-logo");return v.target="_blank",v.rel="noopener nofollow",v.href="https://www.mapbox.com/",v.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),v.setAttribute("rel","noopener nofollow"),this._container.appendChild(v),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 v in h){const A=h[v].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const v=h[0];this._map.getCanvasContainer().offsetWidth<250?v.classList.add("mapboxgl-compact"):v.classList.remove("mapboxgl-compact")}}}class kb{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",v=>this._onIndoorUpdate(v)),this._container}_createButton(h,v){const A=w("button",h,this._container);return A.type="button",A.addEventListener("click",v),A}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,v){this._map&&(h.setAttribute("aria-label",v),h.textContent=v)}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 v=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",v&&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 v=this._map;this._model&&v&&v._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,v){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&v&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const v=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-v)+this._end*v}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,v,A){this._start=this.getValue(v),this._end=h,this._startTime=v,this._endTime=v+A}}const fg={"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 Fy extends i.z{constructor(h,v,A,D){const{point:F,lngLat:B,originalEvent:W,target:ee}=h;super(h.type,{point:F,lngLat:B,originalEvent:W,target:ee}),this.preventDefault=()=>{h.preventDefault()},this.id=v,this.interaction=A,this.feature=D}}class Vp{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,v){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=v.filter;let D=v.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,v)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,v),this.typeById.set(h,D)}get(h){const v=this.typeById.get(h);if(!v)return;const A=this.interactionsByType.get(v);return A?A.get(h):void 0}remove(h){const v=this.typeById.get(h);if(!v)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(v);A&&(A.delete(h),v==="mouseenter"||v==="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(v,this.handleType))}queryTargets(h,v){const A=[];for(const[D,F]of v)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 v=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());v.length&&(h.type="mouseenter",this.handleType(h,v));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 v=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);v.length&&(h.type="mouseleave",this.handleType(h,v)),this.hoveredFeatures.clear()}handleType(h,v){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=!!v;v=v||this.queryTargets(h.point,D);let B=!1;const W=new Set;for(const ee of v){for(const[ae,le]of D){if(!le.target)continue;const we=ee.variants?ee.variants[ae]:null;if(we){for(const be of we){if(_y(be,ee,W,ae))continue;const Ne=new i.dx(ee,be),Re=Jx(be,ee,ae);F&&Ne.id!==void 0&&(Ne.state=this.map.getFeatureState(Ne));const Ie=A?this.prevHoveredFeatures.get(Re):null,Ze=new Fy(h,ae,le,Ne),Ve=Ie?Ie.stop:le.handler(Ze);if(A&&this.hoveredFeatures.set(Re,{feature:ee,stop:Ve}),Ve!==!1){B=!0;break}}if(B)break}}if(B)break}if(!B)for(const[ee,ae]of D){const{handler:le,target:we}=ae;if(!we&&le(new Fy(h,ee,ae,null))!==!1)break}}}function mpe(T,h){if(Array.isArray(T)&&Array.isArray(h)){const v=new Set(T),A=new Set(h);return v.size===A.size&&T.every(D=>A.has(D))}return i.by(T,h)}const ppe={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"},fpe={showCompass:!0,showZoom:!0,visualizePitch:!1};class xpe{constructor(h,v,A=!1){this._clickTolerance=10,this.element=v,this.mouseRotate=new J6({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new eP({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),v.addEventListener("mousedown",this.mousedown),v.addEventListener("touchstart",this.touchstart,{passive:!1}),v.addEventListener("touchmove",this.touchmove),v.addEventListener("touchend",this.touchend),v.addEventListener("touchcancel",this.reset)}down(h,v){this.mouseRotate.mousedown(h,v),this.mousePitch&&this.mousePitch.mousedown(h,v),I()}move(h,v){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,v),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const B=this.mousePitch.mousemoveWindow(h,v),W=B&&B.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(){P(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),$(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,$(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=z(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=z(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)v.width||h.y>v.height;v.locationPoint3D(A).distSqr(h)180;){const A=v.locationPoint3D(T);if(A.x>=0&&A.y>=0&&A.x<=v.width&&A.y<=v.height)break;T.lng>v.center.lng?T.lng-=360:T.lng+=360}return T}const Gd={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%)"},rp={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class s5 extends i.E{constructor(h,v){super(),(h instanceof HTMLElement||v)&&(h=Object.assign({element:h},v)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:B=!1,clickTolerance:W=0,rotation:ee=rp.rotation,rotationAlignment:ae=rp.rotationAlignment,pitchAlignment:le=rp.pitchAlignment,occludedOpacity:we=rp.occludedOpacity,altitude:be=rp.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=B,this._clickTolerance=W,this._rotation=ee,this._rotationAlignment=ae,this._pitchAlignment=le,this._occludedOpacity=we,this._altitude=be,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",Ie=>{Ie.preventDefault()}),this._element.addEventListener("mousedown",Ie=>{Ie.preventDefault()});const Ne=this._element.classList;for(const Ie in Gd)Ne.remove(`mapboxgl-marker-anchor-${Ie}`);Ne.add(`mapboxgl-marker-anchor-${this._anchor}`);const Re=h&&h.className?h.className.trim().split(/\s+/):[];Ne.add(...Re),this._popup=null}_createDefaultMarker(){const h=w("div"),v=j("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=j("radialGradient",{id:"shadowGradient"},j("defs",{},v));j("stop",{offset:"10%","stop-opacity":.4},A),j("stop",{offset:"100%","stop-opacity":.05},A),j("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},v)}return j("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},v),j("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},v),j("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},v),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||rp.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 v=h.code,A=h.charCode||h.keyCode;v!=="Space"&&v!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const v=h.originalEvent.target,A=this._element;this._popup&&(v===A||A.contains(v))&&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,v=this._pos;if(!h||!v)return!1;const A=h.unproject(v,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 v=this._pos;if(!v||v.x<0||v.x>h.transform.width||v.y<0||v.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(v,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 v=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${Gd[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${v.x}px,${v.y}px) `}_calculateXYTransform(){const h=this._pos,v=this._map,A=this.getPitchAlignment();if(!v||!h||A!=="map")return"";if(!v._showingGlobe()){const ee=v.getPitch();return ee?`rotateX(${ee}deg)`:""}const D=i.cX(i.f6(v.transform,this._lngLat)),F=h.sub(i.f7(v.transform)),B=Math.abs(F.x)+Math.abs(F.y);if(B===0)return"";const W=D/B;return`rotateX(${-F.y*W}deg) rotateY(${F.x*W}deg)`}_calculateZTransform(){const h=this._pos,v=this._map;if(!v||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(v._showingGlobe()){const F=v.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),B=v.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(B.y,B.x))-90}else A=-v.getBearing();else if(D==="horizon"){const F=i.ah(4,6,v.getZoom()),B=i.f7(v.transform);B.y+=F*v.transform.height;const W=h.sub(B),ee=i.cX(Math.atan2(W.y,W.x));A=(ee>90?ee-270:ee+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const v=this._map;v&&(v.transform.renderWorldCopies&&(this._lngLat=nP(this._lngLat,this._pos,v.transform)),this._pos=v.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(),v._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(v._showingGlobe()||v.getTerrain()||v.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 v=this._map;if(!v)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||v._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 l6(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 mg,this._domRenderTaskQueue=new mg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},fg,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 pg(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=T.scaleFactor,this._requestManager=new Q(T.transformRequest,T.accessToken,T.testMode),this._silenceAuthErrors=!!T.testMode,this._contextCreateOptions=T.contextCreateOptions?Object.assign({},T.contextCreateOptions):{},typeof T.container=="string"){const v=document.getElementById(T.container);if(!v)throw new Error(`Container '${T.container.toString()}' not found.`);this._container=v}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 hpe(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 H6(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 v=T.bounds;v&&(this.resize(),this.fitBounds(v,Object.assign({},T.fitBoundsOptions,{duration:0})))}this.resize(),T.attributionControl&&this.addControl(new M2({customAttribution:T.customAttribution})),this._logoControl=new T2,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",v=>{this._update(v.dataType==="style"),this.fire(new i.z(`${v.dataType}data`,v))}),this.on("dataloading",v=>{this.fire(new i.z(`${v.dataType}dataloading`,v))}),this._interactions=new Vp(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 v=T.onAdd(this);this._controls.push(T);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(v,A.firstChild):A.appendChild(v),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 v of this._controls)v._setLanguage&&v._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 v;h==="globe"&&T.zoom>=i.cL?(T.setMercatorFromTransition(),v=!0):h==="mercator"&&T.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(T),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&v!==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,v){const A=D=>{let F=[];if(Array.isArray(h)){const B=h.filter(W=>this.getLayer(W));F=B.length?this.queryRenderedFeatures(D,{layers:B}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(T==="mouseenter"||T==="mouseover"){let D=!1;return{listener:v,targets:h,delegates:{mousemove:B=>{const W=A(B.point);W.length?D||(D=!0,v.call(this,new fh(T,this,B.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(T==="mouseleave"||T==="mouseout"){let D=!1;return{listener:v,targets:h,delegates:{mousemove:W=>{A(W.point).length?D=!0:D&&(D=!1,v.call(this,new fh(T,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,v.call(this,new fh(T,this,W.originalEvent)))}}}}{const D=F=>{const B=A(F.point);B.length&&(F.features=B,v.call(this,F),delete F.features)};return{listener:v,targets:h,delegates:{[T]:D}}}}on(T,h,v){if(typeof h=="function"||v===void 0)return super.on(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,v);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,v){if(typeof h=="function"||v===void 0)return super.once(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,v);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(T,h,v){if(typeof h=="function"||v===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(v){const D=typeof v=="string"?v:v instanceof Error?v.message:v.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 v=Object.assign({},h);h&&h.config&&(v.initialConfig=h.config,delete v.config),this.style=new sp(this,v).load(T),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new sp(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,v){this._lazyInitEmptyStyle(),this.style.addSourceType(T,h,v)}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:v=1,sdf:A=!1,stretchX:D,stretchY:F,content:B}={}){this._lazyInitEmptyStyle();const W=i.I.from(T);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:ee,height:ae,data:le}=i.o.getImageData(h);this.style.addImage(W,{data:new i.q({width:ee,height:ae},le),pixelRatio:v,stretchX:D,stretchY:F,content:B,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:ee,height:ae}=h,le=h;this.style.addImage(W,{data:new i.q({width:ee,height:ae},new Uint8Array(le.data)),pixelRatio:v,stretchX:D,stretchY:F,content:B,sdf:A,usvg:!1,version:0,userImage:le}),le.onAdd&&le.onAdd(this,T)}}updateImage(T,h){this._lazyInitEmptyStyle();const v=i.I.from(T),A=this.style.getImage(v);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:B,data:W}=D;if(F===void 0||B===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)||B!==(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}, ${B}) must be that same as the previous version of the image (${A.data.width}, ${A.data.height})`)));const ee=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ae=!1;A.usvg?(A.data=new i.q({width:F,height:B},new Uint8Array(W)),A.usvg=!1,A.icon=void 0,ae=!0):A.data.replace(W,ee),this.style.updateImage(v,A,ae)}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),(v,A)=>{h(v,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(v=>this.fire(new i.y(new Error("Failed to add import",v)))),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,v){return this._isValidId(T)?(this.style.setLayerZoomRange(T,h,v),this._update(!0)):this}setFilter(T,h,v={}){return this._isValidId(T)?(this.style.setFilter(T,h,v),this._update(!0)):this}getFilter(T){return this._isValidId(T)?this.style.getFilter(T):null}setPaintProperty(T,h,v,A={}){return this._isValidId(T)?(this.style.setPaintProperty(T,h,v,A),this._update(!0)):this}getPaintProperty(T,h){return this._isValidId(T)?this.style.getPaintProperty(T,h):null}setLayoutProperty(T,h,v,A={}){return this._isValidId(T)?(this.style.setLayoutProperty(T,h,v,A),this._update(!0)):this}getLayoutProperty(T,h){return this._isValidId(T)?this.style.getLayoutProperty(T,h):null}setLayerProperty(T,h,v,A={}){return this._isValidId(T)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(T,h,v,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,v){return this.style.setConfigProperty(T,h,v),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 kb),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 v,A,D,F=this._container;for(;F&&(!A||!D);){const B=window.getComputedStyle(F).transform;B&&B!=="none"&&(v=B.match(/matrix.*\((.+)\)/)[1].split(", "),v[0]&&v[0]!=="0"&&v[0]!=="1"&&(A=v[0]),v[3]&&v[3]!=="0"&&v[3]!=="1"&&(D=v[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 ZR(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=w("div","mapboxgl-canary",T)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=w("div","mapboxgl-canvas-container",T);this._canvas=w("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const v=this._controlContainer=w("div","mapboxgl-control-container",T),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=w("div",`mapboxgl-ctrl-${D}`,v)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(T,h){const v=i.o.devicePixelRatio||1;this._canvas.width=v*Math.ceil(T),this._canvas.height=v*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 qC(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",v=>{v.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 v=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(v.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 ae=this.transform.zoom,le=this.transform.pitch,we=i.o.now(),be=new i.ac(ae,{now:we,fadeDuration:F,pitch:le,transition:this.style.transition,worldview:this._worldview});this.style.update(be)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let B=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),B=this._updateAverageElevation(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):B=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,m.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 ae=i.o.now()-A;D.endQuery(v.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:ae,gpuTime:le}))},50)}if(this.listens("gpu-timing-layer")){const ae=this.painter.collectGpuTimers();setTimeout(()=>{const le=this.painter.queryGpuTimers(ae);this.fire(new i.z("gpu-timing-layer",{layerTimes:le}))},50)}if(this.listens("gpu-timing-deferred-render")){const ae=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const le=this.painter.queryGpuTimeDeferredRender(ae);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:le}))},50)}const ee=this._sourcesDirty||this._styleDirty||this._placementDirty||B;if(ee||this._repaint)this.triggerRepaint();else{const ae=this.idle();if(ae&&(B=this._updateAverageElevation(A,!0)),B)this.triggerRepaint();else if(this._triggerFrame(!1),ae&&(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||ee||(this._fullyLoaded=!0,m.mark(u.fullLoad),this._performanceMetricsCollection&&dt(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(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 v=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&v(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 B=Math.abs(D-F);if(B>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),v(F);this._averageElevation.easeTo(F,T,300)}else if(B>1e-4)return this._averageElevation.jumpTo(F),v(F)}return!!this._averageElevation.isEasing(T)&&v(this._averageElevation.getValue(T))}_authenticate(){Ue(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,T=>{if(T&&(T.message===J||T.status===401)){const h=this.painter.context.gl;et(h,!1),this._logoControl instanceof T2&&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/")))}}),Se(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ae(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&ke(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){qe(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 v=this.painter.context.gl,A=v.createFramebuffer();function D(F){v.framebufferTexture2D(v.FRAMEBUFFER,v.COLOR_ATTACHMENT0,v.TEXTURE_2D,F,0);const B=new Uint8Array(v.drawingBufferWidth*v.drawingBufferHeight*4);return v.readPixels(0,0,v.drawingBufferWidth,v.drawingBufferHeight,v.RGBA,v.UNSIGNED_BYTE,B),B}return v.bindFramebuffer(v.FRAMEBUFFER,A),this._canvasPixelComparison(D(T),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(T,h,v){let A=v[1]-v[0];const D=T.length/4;for(let F=0;F{const v=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,v&&this._render(h)}))}_preloadTiles(T){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(v,A)=>v._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({},fpe,T),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const v=this._map;v&&(this.options.visualizePitch?v.resetNorthPitch({},{originalEvent:h}):v.resetNorth({},{originalEvent:h}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const T=this._map;if(!T)return;const h=T.getZoom(),v=h===T.getMaxZoom(),A=h===T.getMinZoom();this._zoomInButton.disabled=v,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",v.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 xpe(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 v=w("button",T,this._container);return v.type="button",v.addEventListener("click",h),v}_setButtonTitle(T,h){if(!this._map)return;const v=this._map._getUIString(`NavigationControl.${h}`);T.setAttribute("aria-label",v),T.firstElementChild&&T.firstElementChild.setAttribute("title",v)}},GeolocateControl:class extends i.E{constructor(T={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},gpe,T),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=UC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(T){return this._map=T,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(T){const h=(v=!!this.options.geolocation)=>{this._supportsGeolocation=v,T(v)};this._supportsGeolocation!==void 0?T(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(v=>h(v.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(T){const h=this._map.getMaxBounds(),v=T.coords;return!!h&&(v.longitudeh.getEast()||v.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),v=T.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(v),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,v=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${v}px`,this._circleElement.style.height=`${v}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=w("button","mapboxgl-ctrl-geolocate",this._container),w("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=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new s5({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new s5({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:M2,ScaleControl:class{constructor(T={}){this.options=Object.assign({},Sb,T),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const T=this.options.maxWidth||100,h=this._map,v=h._containerHeight/2,A=h._containerWidth/2-T/2,D=h.unproject([A,v]),F=h.unproject([A+T,v]),B=D.distanceTo(F);if(this.options.unit==="imperial"){const W=3.2808*B;W>5280?this._setScale(T,W/5280,"mile"):this._setScale(T,W,"foot")}else this.options.unit==="nautical"?this._setScale(T,B/1852,"nautical-mile"):B>=1e3?this._setScale(T,B/1e3,"kilometer"):this._setScale(T,B,"meter")}_setScale(T,h,v){this._map._requestDomTask(()=>{const A=function(F){const B=Math.pow(10,`${Math.floor(F)}`.length-1);let W=F/B;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(ee){const ae=Math.pow(10,Math.ceil(-Math.log(ee)/Math.LN10));return Math.round(ee*ae)/ae}(W),B*W}(h),D=A/h;this._container.innerHTML=v!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:v}).format(A):`${A} ${aP[v]}`,this._container.style.width=T*D+"px"})}onAdd(T){return this._map=T,this._language=T.getLanguage(),this._container=w("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=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const T=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("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:kb,Popup:class extends i.E{constructor(T){super(),this.options=Object.assign(Object.create(np),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(),v=document.createElement("body");let A;for(v.innerHTML=T;A=v.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=w("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(T),this.options.closeButton){const v=this._closeButton=w("button","mapboxgl-popup-close-button",h);v.type="button",v.setAttribute("aria-label","Close popup"),v.innerHTML='',v.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,v=this._container,A=this._pos;if(!h||!v||!A)return"bottom";const D=v.offsetWidth,F=v.offsetHeight,B=A.xh.transform.width-D/2;if(A.y+Th.transform.height-F){if(B)return"bottom-left";if(W)return"bottom-right"}return B?"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,v=this._content;if(!h||!this._lngLat&&!this._trackPointer||!v)return;let A=this._container;if(A||(A=this._container=w("div","mapboxgl-popup",h.getContainer()),this._tip=w("div","mapboxgl-popup-tip",A),A.appendChild(v)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=nP(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=wv(this.options.offset),B=this._anchor=this._getAnchor(F.y),W=wv(this.options.offset,B),ee=D.add(W).round();h._requestDomTask(()=>{this._container&&B&&(this._container.style.transform=`${Gd[B]} translate(${ee.x}px,${ee.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(ap);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:s5,Style:sp,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:$u,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})})(VGe);var akt=VGe.exports;const Io=Do(akt);function ws({className:t,...s}){return e.jsx("div",{className:Pt("animate-pulse rounded-md bg-muted",t),...s})}const _6e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},w6e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function ikt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function okt({listings:t,isLoading:s}){const r=ar(),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;Io.accessToken=l;const f=t.filter(_=>_.latitude!=null&&_.longitude!=null);let g=[-98.5795,39.8283],y=4;if(f.length>0){const _=f.reduce((j,N)=>j+N.longitude,0)/f.length,w=f.reduce((j,N)=>j+N.latitude,0)/f.length;g=[_,w],y=f.length===1?12:10}return a.current=new Io.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:y,center:g}),a.current.addControl(new Io.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 I,P,O;const y=_6e[g.status]||"#10B981",_=((I=g.photos)==null?void 0:I.find(q=>q.is_primary))||((P=g.photos)==null?void 0:P[0]),j=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 Io.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${_!=null&&_.photo_url?``:""}
${ikt(g.price)}
${g.property_address||""}
${g.city}, ${g.state}
${w6e[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 Io.Marker(N).setLngLat([g.longitude,g.latitude]).setPopup(S).addTo(a.current);o.current.push(M)}),f.length>1){const g=new Io.LngLatBounds;f.forEach(y=>g.extend([y.longitude,y.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(ws,{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(_6e).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:w6e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function xD(t,[s,r]){return Math.min(r,Math.max(s,t))}function YO(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 lkt=[" ","Enter","ArrowUp","ArrowDown"],ckt=[" ","Enter"],JS="Select",[nue,aue,dkt]=LO(JS),[hE]=od(JS,[dkt,V0]),iue=V0(),[ukt,Rw]=hE(JS),[hkt,mkt]=hE(JS),GGe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:c,dir:u,name:m,autoComplete:f,disabled:g,required:y,form:_}=t,w=iue(s),[j,N]=k.useState(null),[S,M]=k.useState(null),[I,P]=k.useState(!1),O=Dw(u),[q,$]=lh({prop:n,defaultProp:a??!1,onChange:o,caller:JS}),[z,V]=lh({prop:l,defaultProp:i,onChange:c,caller:JS}),X=k.useRef(null),Y=j?_||!!j.closest("form"):!0,[J,Q]=k.useState(new Set),ce=Array.from(J).map(ne=>ne.props.value).join(";");return e.jsx(FO,{...w,children:e.jsxs(ukt,{required:y,scope:s,trigger:j,onTriggerChange:N,valueNode:S,onValueNodeChange:M,valueNodeHasChildren:I,onValueNodeHasChildrenChange:P,contentId:Iu(),value:z,onValueChange:V,open:q,onOpenChange:$,dir:O,triggerPointerDownPosRef:X,disabled:g,children:[e.jsx(nue.Provider,{scope:s,children:e.jsx(hkt,{scope:t.__scopeSelect,onNativeOptionAdd:k.useCallback(ne=>{Q(re=>new Set(re).add(ne))},[]),onNativeOptionRemove:k.useCallback(ne=>{Q(re=>{const oe=new Set(re);return oe.delete(ne),oe})},[]),children:r})}),Y?e.jsxs(xWe,{"aria-hidden":!0,required:y,tabIndex:-1,name:m,autoComplete:f,value:z,onChange:ne=>V(ne.target.value),disabled:g,form:_,children:[z===void 0?e.jsx("option",{value:""}):null,Array.from(J)]},ce):null]})})};GGe.displayName=JS;var WGe="SelectTrigger",KGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=iue(r),l=Rw(WGe,r),i=l.disabled||n,c=Ka(s,l.onTriggerChange),u=aue(r),m=k.useRef("touch"),[f,g,y]=yWe(w=>{const j=u().filter(M=>!M.disabled),N=j.find(M=>M.value===l.value),S=vWe(j,w,N);S!==void 0&&l.onValueChange(S.value)}),_=w=>{i||(l.onOpenChange(!0),y()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(nE,{asChild:!0,...o,children:e.jsx(cn.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":gWe(l.value)?"":void 0,...a,ref:c,onClick:Or(a.onClick,w=>{w.currentTarget.focus(),m.current!=="mouse"&&_(w)}),onPointerDown:Or(a.onPointerDown,w=>{m.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:Or(a.onKeyDown,w=>{const j=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(j&&w.key===" ")&&lkt.includes(w.key)&&(_(),w.preventDefault())})})})});KGe.displayName=WGe;var ZGe="SelectValue",YGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=Rw(ZGe,r),{onValueNodeHasChildrenChange:u}=c,m=o!==void 0,f=Ka(s,c.onValueNodeChange);return kd(()=>{u(m)},[u,m]),e.jsx(cn.span,{...i,ref:f,style:{pointerEvents:"none"},children:gWe(c.value)?e.jsx(e.Fragment,{children:l}):o})});YGe.displayName=ZGe;var pkt="SelectIcon",QGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(cn.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});QGe.displayName=pkt;var fkt="SelectPortal",XGe=t=>e.jsx(eE,{asChild:!0,...t});XGe.displayName=fkt;var e3="SelectContent",JGe=k.forwardRef((t,s)=>{const r=Rw(e3,t.__scopeSelect),[n,a]=k.useState();if(kd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?vp.createPortal(e.jsx(eWe,{scope:t.__scopeSelect,children:e.jsx(nue.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(tWe,{...t,ref:s})});JGe.displayName=e3;var Ig=10,[eWe,Fw]=hE(e3),xkt="SelectContentImpl",gkt=fw("SelectContent.RemoveScroll"),tWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:c,align:u,alignOffset:m,arrowPadding:f,collisionBoundary:g,collisionPadding:y,sticky:_,hideWhenDetached:w,avoidCollisions:j,...N}=t,S=Rw(e3,r),[M,I]=k.useState(null),[P,O]=k.useState(null),q=Ka(s,Ae=>I(Ae)),[$,z]=k.useState(null),[V,X]=k.useState(null),Y=aue(r),[J,Q]=k.useState(!1),ce=k.useRef(!1);k.useEffect(()=>{if(M)return Yde(M)},[M]),Wde();const ne=k.useCallback(Ae=>{const[Me,...ke]=Y().map(ve=>ve.ref.current),[Oe]=ke.slice(-1),qe=document.activeElement;for(const ve of Ae)if(ve===qe||(ve==null||ve.scrollIntoView({block:"nearest"}),ve===Me&&P&&(P.scrollTop=0),ve===Oe&&P&&(P.scrollTop=P.scrollHeight),ve==null||ve.focus(),document.activeElement!==qe))return},[Y,P]),re=k.useCallback(()=>ne([$,M]),[ne,$,M]);k.useEffect(()=>{J&&re()},[J,re]);const{onOpenChange:oe,triggerPointerDownPosRef:he}=S;k.useEffect(()=>{if(M){let Ae={x:0,y:0};const Me=Oe=>{var qe,ve;Ae={x:Math.abs(Math.round(Oe.pageX)-(((qe=he.current)==null?void 0:qe.x)??0)),y:Math.abs(Math.round(Oe.pageY)-(((ve=he.current)==null?void 0:ve.y)??0))}},ke=Oe=>{Ae.x<=10&&Ae.y<=10?Oe.preventDefault():M.contains(Oe.target)||oe(!1),document.removeEventListener("pointermove",Me),he.current=null};return he.current!==null&&(document.addEventListener("pointermove",Me),document.addEventListener("pointerup",ke,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Me),document.removeEventListener("pointerup",ke,{capture:!0})}}},[M,oe,he]),k.useEffect(()=>{const Ae=()=>oe(!1);return window.addEventListener("blur",Ae),window.addEventListener("resize",Ae),()=>{window.removeEventListener("blur",Ae),window.removeEventListener("resize",Ae)}},[oe]);const[xe,ue]=yWe(Ae=>{const Me=Y().filter(qe=>!qe.disabled),ke=Me.find(qe=>qe.ref.current===document.activeElement),Oe=vWe(Me,Ae,ke);Oe&&setTimeout(()=>Oe.ref.current.focus())}),ge=k.useCallback((Ae,Me,ke)=>{const Oe=!ce.current&&!ke;(S.value!==void 0&&S.value===Me||Oe)&&(z(Ae),Oe&&(ce.current=!0))},[S.value]),_e=k.useCallback(()=>M==null?void 0:M.focus(),[M]),Be=k.useCallback((Ae,Me,ke)=>{const Oe=!ce.current&&!ke;(S.value!==void 0&&S.value===Me||Oe)&&X(Ae)},[S.value]),Se=n==="popper"?$ve:sWe,Ee=Se===$ve?{side:i,sideOffset:c,align:u,alignOffset:m,arrowPadding:f,collisionBoundary:g,collisionPadding:y,sticky:_,hideWhenDetached:w,avoidCollisions:j}:{};return e.jsx(eWe,{scope:r,content:M,viewport:P,onViewportChange:O,itemRefCallback:ge,selectedItem:$,onItemLeave:_e,itemTextRefCallback:Be,focusSelectedItem:re,selectedItemText:V,position:n,isPositioned:J,searchRef:xe,children:e.jsx(VO,{as:gkt,allowPinchZoom:!0,children:e.jsx(qO,{asChild:!0,trapped:S.open,onMountAutoFocus:Ae=>{Ae.preventDefault()},onUnmountAutoFocus:Or(a,Ae=>{var Me;(Me=S.trigger)==null||Me.focus({preventScroll:!0}),Ae.preventDefault()}),children:e.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ae=>Ae.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Se,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Ae=>Ae.preventDefault(),...N,...Ee,onPlaced:()=>Q(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Or(N.onKeyDown,Ae=>{const Me=Ae.ctrlKey||Ae.altKey||Ae.metaKey;if(Ae.key==="Tab"&&Ae.preventDefault(),!Me&&Ae.key.length===1&&ue(Ae.key),["ArrowUp","ArrowDown","Home","End"].includes(Ae.key)){let Oe=Y().filter(qe=>!qe.disabled).map(qe=>qe.ref.current);if(["ArrowUp","End"].includes(Ae.key)&&(Oe=Oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ae.key)){const qe=Ae.target,ve=Oe.indexOf(qe);Oe=Oe.slice(ve+1)}setTimeout(()=>ne(Oe)),Ae.preventDefault()}})})})})})})});tWe.displayName=xkt;var ykt="SelectItemAlignedPosition",sWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Rw(e3,r),l=Fw(e3,r),[i,c]=k.useState(null),[u,m]=k.useState(null),f=Ka(s,q=>m(q)),g=aue(r),y=k.useRef(!1),_=k.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:N,focusSelectedItem:S}=l,M=k.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&w&&j&&N){const q=o.trigger.getBoundingClientRect(),$=u.getBoundingClientRect(),z=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const qe=V.left-$.left,ve=z.left-qe,dt=q.left-ve,pe=q.width+dt,Ue=Math.max(pe,$.width),Xe=window.innerWidth-Ig,et=xD(ve,[Ig,Math.max(Ig,Xe-Ue)]);i.style.minWidth=pe+"px",i.style.left=et+"px"}else{const qe=$.right-V.right,ve=window.innerWidth-z.right-qe,dt=window.innerWidth-q.right-ve,pe=q.width+dt,Ue=Math.max(pe,$.width),Xe=window.innerWidth-Ig,et=xD(ve,[Ig,Math.max(Ig,Xe-Ue)]);i.style.minWidth=pe+"px",i.style.right=et+"px"}const X=g(),Y=window.innerHeight-Ig*2,J=w.scrollHeight,Q=window.getComputedStyle(u),ce=parseInt(Q.borderTopWidth,10),ne=parseInt(Q.paddingTop,10),re=parseInt(Q.borderBottomWidth,10),oe=parseInt(Q.paddingBottom,10),he=ce+ne+J+oe+re,xe=Math.min(j.offsetHeight*5,he),ue=window.getComputedStyle(w),ge=parseInt(ue.paddingTop,10),_e=parseInt(ue.paddingBottom,10),Be=q.top+q.height/2-Ig,Se=Y-Be,Ee=j.offsetHeight/2,Ae=j.offsetTop+Ee,Me=ce+ne+Ae,ke=he-Me;if(Me<=Be){const qe=X.length>0&&j===X[X.length-1].ref.current;i.style.bottom="0px";const ve=u.clientHeight-w.offsetTop-w.offsetHeight,dt=Math.max(Se,Ee+(qe?_e:0)+ve+re),pe=Me+dt;i.style.height=pe+"px"}else{const qe=X.length>0&&j===X[0].ref.current;i.style.top="0px";const dt=Math.max(Be,ce+w.offsetTop+(qe?ge:0)+Ee)+ke;i.style.height=dt+"px",w.scrollTop=Me-Be+w.offsetTop}i.style.margin=`${Ig}px 0`,i.style.minHeight=xe+"px",i.style.maxHeight=Y+"px",n==null||n(),requestAnimationFrame(()=>y.current=!0)}},[g,o.trigger,o.valueNode,i,u,w,j,N,o.dir,n]);kd(()=>M(),[M]);const[I,P]=k.useState();kd(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const O=k.useCallback(q=>{q&&_.current===!0&&(M(),S==null||S(),_.current=!1)},[M,S]);return e.jsx(bkt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:y,onScrollButtonChange:O,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(cn.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});sWe.displayName=ykt;var vkt="SelectPopperPosition",$ve=k.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Ig,...o}=t,l=iue(r);return e.jsx(zO,{...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)"}})});$ve.displayName=vkt;var[bkt,Nje]=hE(e3,{}),qve="SelectViewport",rWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Fw(qve,r),l=Nje(qve,r),i=Ka(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(nue.Slot,{scope:r,children:e.jsx(cn.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Or(a.onScroll,u=>{const m=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&f){const y=Math.abs(c.current-m.scrollTop);if(y>0){const _=window.innerHeight-Ig*2,w=parseFloat(f.style.minHeight),j=parseFloat(f.style.height),N=Math.max(w,j);if(N<_){const S=N+y,M=Math.min(_,S),I=S-M;f.style.height=M+"px",f.style.bottom==="0px"&&(m.scrollTop=I>0?I:0,f.style.justifyContent="flex-end")}}}c.current=m.scrollTop})})})]})});rWe.displayName=qve;var nWe="SelectGroup",[_kt,wkt]=hE(nWe),jkt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Iu();return e.jsx(_kt,{scope:r,id:a,children:e.jsx(cn.div,{role:"group","aria-labelledby":a,...n,ref:s})})});jkt.displayName=nWe;var aWe="SelectLabel",iWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=wkt(aWe,r);return e.jsx(cn.div,{id:a.id,...n,ref:s})});iWe.displayName=aWe;var Doe="SelectItem",[Nkt,oWe]=hE(Doe),lWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Rw(Doe,r),c=Fw(Doe,r),u=i.value===n,[m,f]=k.useState(o??""),[g,y]=k.useState(!1),_=Ka(s,S=>{var M;return(M=c.itemRefCallback)==null?void 0:M.call(c,S,n,a)}),w=Iu(),j=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(Nkt,{scope:r,value:n,disabled:a,textId:w,isSelected:u,onItemTextChange:k.useCallback(S=>{f(M=>M||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(nue.ItemSlot,{scope:r,value:n,disabled:a,textValue:m,children:e.jsx(cn.div,{role:"option","aria-labelledby":w,"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:Or(l.onFocus,()=>y(!0)),onBlur:Or(l.onBlur,()=>y(!1)),onClick:Or(l.onClick,()=>{j.current!=="mouse"&&N()}),onPointerUp:Or(l.onPointerUp,()=>{j.current==="mouse"&&N()}),onPointerDown:Or(l.onPointerDown,S=>{j.current=S.pointerType}),onPointerMove:Or(l.onPointerMove,S=>{var M;j.current=S.pointerType,a?(M=c.onItemLeave)==null||M.call(c):j.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Or(l.onPointerLeave,S=>{var M;S.currentTarget===document.activeElement&&((M=c.onItemLeave)==null||M.call(c))}),onKeyDown:Or(l.onKeyDown,S=>{var I;((I=c.searchRef)==null?void 0:I.current)!==""&&S.key===" "||(ckt.includes(S.key)&&N(),S.key===" "&&S.preventDefault())})})})})});lWe.displayName=Doe;var $I="SelectItemText",cWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Rw($I,r),i=Fw($I,r),c=oWe($I,r),u=mkt($I,r),[m,f]=k.useState(null),g=Ka(s,N=>f(N),c.onItemTextChange,N=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,N,c.value,c.disabled)}),y=m==null?void 0:m.textContent,_=k.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:y},c.value),[c.disabled,c.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=u;return kd(()=>(w(_),()=>j(_)),[w,j,_]),e.jsxs(e.Fragment,{children:[e.jsx(cn.span,{id:c.textId,...o,ref:g}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?vp.createPortal(o.children,l.valueNode):null]})});cWe.displayName=$I;var dWe="SelectItemIndicator",uWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return oWe(dWe,r).isSelected?e.jsx(cn.span,{"aria-hidden":!0,...n,ref:s}):null});uWe.displayName=dWe;var Uve="SelectScrollUpButton",hWe=k.forwardRef((t,s)=>{const r=Fw(Uve,t.__scopeSelect),n=Nje(Uve,t.__scopeSelect),[a,o]=k.useState(!1),l=Ka(s,n.onScrollButtonChange);return kd(()=>{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(pWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});hWe.displayName=Uve;var Vve="SelectScrollDownButton",mWe=k.forwardRef((t,s)=>{const r=Fw(Vve,t.__scopeSelect),n=Nje(Vve,t.__scopeSelect),[a,o]=k.useState(!1),l=Ka(s,n.onScrollButtonChange);return kd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollHeight-c.clientHeight,m=Math.ceil(c.scrollTop)c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(pWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});mWe.displayName=Vve;var pWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Fw("SelectScrollButton",r),l=k.useRef(null),i=aue(r),c=k.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return k.useEffect(()=>()=>c(),[c]),kd(()=>{var m;const u=i().find(f=>f.ref.current===document.activeElement);(m=u==null?void 0:u.ref.current)==null||m.scrollIntoView({block:"nearest"})},[i]),e.jsx(cn.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Or(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Or(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Or(a.onPointerLeave,()=>{c()})})}),kkt="SelectSeparator",fWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(cn.div,{"aria-hidden":!0,...n,ref:s})});fWe.displayName=kkt;var Hve="SelectArrow",Skt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=iue(r),o=Rw(Hve,r),l=Fw(Hve,r);return o.open&&l.position==="popper"?e.jsx(BO,{...a,...n,ref:s}):null});Skt.displayName=Hve;var Ckt="SelectBubbleInput",xWe=k.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ka(n,a),l=YO(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&m){const f=new Event("change",{bubbles:!0});m.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(cn.select,{...r,style:{...pqe,...r.style},ref:o,defaultValue:s})});xWe.displayName=Ckt;function gWe(t){return t===""||t===void 0}function yWe(t){const s=_d(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=Mkt(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 Mkt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Tkt=GGe,bWe=KGe,Akt=YGe,Ekt=QGe,Pkt=XGe,_We=JGe,Ikt=rWe,wWe=iWe,jWe=lWe,Lkt=cWe,Dkt=uWe,NWe=hWe,kWe=mWe,SWe=fWe;const Rs=Tkt,$s=Akt,Ls=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(bWe,{ref:n,className:Pt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(Ekt,{asChild:!0,children:e.jsx(Ji,{className:"h-4 w-4 opacity-50"})})]}));Ls.displayName=bWe.displayName;const CWe=k.forwardRef(({className:t,...s},r)=>e.jsx(NWe,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Sp,{className:"h-4 w-4"})}));CWe.displayName=NWe.displayName;const MWe=k.forwardRef(({className:t,...s},r)=>e.jsx(kWe,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Ji,{className:"h-4 w-4"})}));MWe.displayName=kWe.displayName;const Ds=k.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(Pkt,{children:e.jsxs(_We,{ref:a,className:Pt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(CWe,{}),e.jsx(Ikt,{className:Pt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(MWe,{})]})}));Ds.displayName=_We.displayName;const Okt=k.forwardRef(({className:t,...s},r)=>e.jsx(wWe,{ref:r,className:Pt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Okt.displayName=wWe.displayName;const ft=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(jWe,{ref:n,className:Pt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Dkt,{children:e.jsx(ua,{className:"h-4 w-4"})})}),e.jsx(Lkt,{children:s})]}));ft.displayName=jWe.displayName;const Rkt=k.forwardRef(({className:t,...s},r)=>e.jsx(SWe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));Rkt.displayName=SWe.displayName;const Fkt=t=>pt({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}}),TWe=t=>pt({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}),AWe=()=>Tt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l,leadType:i="info_request",preferredDate:c,preferredTime:u,showingMode:m,message:f})=>{let g=null,y=null;if(l){const{data:N}=await H.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();N&&(g=N.id,y=N.sharing_agent_id)}const{data:_,error:w}=await H.from("listing_leads").insert({listing_id:t,agent_id:y||s,first_name:r,last_name:n,email:a,phone:o,share_id:g,referred_by_agent_id:y,lead_type:i,preferred_date:c||null,preferred_time:u||null,showing_mode:m||null,message:f||null}).select().single();if(w)throw w;const{error:j}=await H.functions.invoke("process-listing-lead",{body:{leadId:_.id}});return j&&console.error("Error processing lead:",j),_}}),zkt=()=>Tt({mutationFn:async t=>{const{error:s}=await H.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),Bkt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},j6e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},$kt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function EWe(){const[t,s]=k.useState(""),[r,n]=k.useState(!1),[a,o]=k.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Fkt({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("")},m=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{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(la,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:UGe,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(${nkt})`},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(sn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Le,{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(G,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(sn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(v1,{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(Rs,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Ls,{className:"bg-white",children:e.jsx($s,{placeholder:"Any status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"Any status"}),Object.entries(j6e).map(([f,g])=>e.jsx(ft,{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(Rs,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Ls,{className:"bg-white",children:e.jsx($s,{placeholder:"Any type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"Any type"}),Object.entries($kt).map(([f,g])=>e.jsx(ft,{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(Le,{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(Le,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),m&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(G,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Er,{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(okt,{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(ws,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ws,{className:"h-7 w-28"}),e.jsx(ws,{className:"h-4 w-full"}),e.jsx(ws,{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 w,j,N;const g=((w=f.photos)==null?void 0:w.find(S=>S.is_primary))||((j=f.photos)==null?void 0:j[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(la,{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(xn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(Ye,{className:`absolute top-2 left-2 ${Bkt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:j6e[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(Ja,{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(xn,{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:m?"Try adjusting your search or filters":"Check back soon for new listings"}),m&&e.jsx(G,{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:jje,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 Pe=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Pe.displayName="Card";const Et=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex flex-col space-y-1.5 p-6",t),...s}));Et.displayName="CardHeader";const Lt=k.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Pt("text-2xl font-semibold leading-none tracking-tight",t),...s}));Lt.displayName="CardTitle";const vr=k.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));vr.displayName="CardDescription";const De=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("p-6 pt-0",t),...s}));De.displayName="CardContent";const i8=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex items-center p-6 pt-0",t),...s}));i8.displayName="CardFooter";var qkt="Label",PWe=k.forwardRef((t,s)=>e.jsx(cn.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())}}));PWe.displayName=qkt;var IWe=PWe;const Ukt=S3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ye=k.forwardRef(({className:t,...s},r)=>e.jsx(IWe,{ref:r,className:Pt(Ukt(),t),...s}));ye.displayName=IWe.displayName;const Ooe="/assets/levelup-logo-color-D3mY9gCJ.png";function Vkt(){const t=hc(),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(EWe,{}):n.startsWith("public/")?null:e.jsx(Hkt,{slug:n})}function Hkt({slug:t}){return e.jsx(Kkt,{slug:t})}const Gkt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Wkt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},N6e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Kkt({slug:t}){var z,V;const{data:s,isLoading:r}=TWe(t),n=AWe(),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[m,f]=k.useState(""),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(null),S=X=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(X),M=async X=>{if(X.preventDefault(),!(!a.trim()||!c.trim()||!s)){y(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:m.trim()}),w(!0),me.success("Thanks! The agent will be in touch soon.")}catch(Y){console.error("Lead submission error:",Y),me.error(`Failed to submit: ${Y.message||"Please try again"}`)}finally{y(!1)}}},I=(s==null?void 0:s.photos)||[],P=I.find(X=>X.is_primary)||I[0],O=()=>{j!==null&&N(j===0?I.length-1:j-1)},q=()=>{j!==null&&N(j===I.length-1?0:j+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(ws,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ws,{className:"h-10 w-48 mb-6"}),e.jsx(ws,{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(ws,{className:"h-12 w-48"}),e.jsx(ws,{className:"h-6 w-full"}),e.jsx(ws,{className:"h-6 w-3/4"})]}),e.jsx(ws,{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:Ooe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(xn,{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(G,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const $=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(Pl,{children:[e.jsxs("title",{children:[$," | 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":""} ${N6e[s.property_type]} in ${s.city}, ${s.state}. ${((z=s.description)==null?void 0:z.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:$}),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"}),P&&e.jsx("meta",{property:"og:image",content:P.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:Ooe,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(Ga,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),I.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>N(0),children:e.jsx("img",{src:P==null?void 0:P.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:I.slice(1,5).map((X,Y)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(Y+1),children:[e.jsx("img",{src:X.photo_url,alt:`Photo ${Y+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Y===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",I.length-5," more"]})]},X.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(Ye,{className:`${Gkt[s.status]} text-white border-0`,children:Wkt[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(aa,{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(Th,{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(au,{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(k0,{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(fn,{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(Ye,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),N6e[s.property_type]]}),s.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(Ye,{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(G,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Zi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(De,{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(Pe,{className:"border-primary",children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(De,{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(rr,{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(ye,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Le,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:X=>o(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Le,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:X=>i(X.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email *"}),e.jsx(Le,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:X=>u(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(Le,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:m,onChange:X=>f(X.target.value)})]}),e.jsx(G,{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:j!==null,onOpenChange:()=>N(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{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(Er,{className:"h-5 w-5"})}),j!==null&&I[j]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[j].photo_url,alt:`Photo ${j+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick: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(tl,{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:[j+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function oue({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 LWe=t=>pt({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}),Zkt=()=>pt({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}}),Ykt=t=>pt({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}),DWe=()=>{const t=Qt();return Tt({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)})},OWe=()=>{const t=Qt();return Tt({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)})},vo=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:{}})},Qkt=async(t,s)=>{const{error:r}=await H.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},RWe=t=>pt({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 lue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=k.useState(""),[i,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(""),[w,j]=k.useState(!1),N=async S=>{if(S.preventDefault(),!o.trim()){me.error("Please enter your name");return}j(!0);try{await Qkt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:y.trim()||void 0,intent:f||void 0}),vo(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:y.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(""),m(""),g(""),_("")}catch{me.error("Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(js,{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(ye,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Le,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Le,{id:"lead-phone",type:"tel",value:u,onChange:S=>m(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-email",children:"Email"}),e.jsx(Le,{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(ye,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Rs,{value:f,onValueChange:g,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select one"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"buy",children:"Buy a home"}),e.jsx(ft,{value:"sell",children:"Sell my home"}),e.jsx(ft,{value:"both",children:"Buy & Sell"}),e.jsx(ft,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Le,{id:"lead-message",value:y,onChange:S=>_(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(G,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const Xkt=t=>pt({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}),Jkt=t=>pt({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}),e4t=()=>{const t=Qt();return Tt({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)})},t4t=()=>{const t=Qt();return Tt({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)})},s4t=()=>{const t=Qt();return Tt({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 r4t(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 n4t(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 a4t={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 i4t({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=n4t(r.video_url),o=n||!!a,l=n?r4t(r.video_url):a||r.video_url;return e.jsx("div",{className:a4t[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 o4t={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 l4t({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=k.useState(0);if(n.length===0)return null;const l=o4t[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(g1,{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(tl,{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 c4t={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 d4t({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=c4t[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const u4t={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 h4t({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=u4t[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:()=>vo(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(rn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Gve={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 m4t({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 p4t={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 f4t({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=p4t[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=Gve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>vo(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(m4t,{path:c.icon,color:c.color})},i)})})]})}function cue({cardId:t,variant:s}){const{data:r}=Xkt(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(i4t,{block:l,variant:s},l.id);case"testimonials":return e.jsx(l4t,{block:l,variant:s},l.id);case"specialties":return e.jsx(d4t,{block:l,variant:s},l.id);case"custom_links":return e.jsx(h4t,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(f4t,{block:o,cardId:t,variant:s})]})}async function x4t(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 g4t(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 due(t){const{first:s,last:r}=g4t(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 x4t(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 y4t({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)=>{vo(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")}),m=()=>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),vo(t.id,"button_click","book"))},g=()=>{var S,M;vo(t.id,"contact_saved"),due({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})},y=async()=>{vo(t.id,"share_event");const S=`https://cards.relevelup.com/${t.slug}`,M="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:M,url:S})}catch{}else await navigator.clipboard.writeText(S),me.success("Link copied!")},_=()=>{a("referral"),r(!0),vo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),vo(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Cn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Wa,{src:t.avatar_url||void 0,alt:o}),e.jsx(Mn,{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(G,{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(Nn,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(G,{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(Ki,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(G,{onClick:m,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(rr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(G,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(fn,{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(ea,{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(oue,{card:t,variant:"standard"}),e.jsx(cue,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(G,{variant:"ghost",onClick:g,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(vi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(G,{variant:"ghost",onClick:()=>{vo(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(ea,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(G,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(ur,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(G,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(El,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(G,{variant:"ghost",onClick:y,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(nd,{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:()=>vo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(lue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function v4t({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)=>{vo(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")}),m=()=>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),vo(t.id,"button_click","book"))},g=()=>{var S,M;vo(t.id,"contact_saved"),due({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})},y=async()=>{vo(t.id,"share_event");const S=`https://cards.relevelup.com/${t.slug}`,M="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:M,url:S})}catch{}else await navigator.clipboard.writeText(S),me.success("Link copied!")},_=()=>{a("referral"),r(!0),vo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),vo(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Cn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Wa,{src:t.avatar_url||void 0,alt:o}),e.jsx(Mn,{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:Nn,label:"Call",handler:c},{icon:Ki,label:"Text",handler:u},{icon:rr,label:"Email",handler:m}].map(({icon:S,label:M,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children: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(fn,{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(ea,{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(oue,{card:t,variant:"luxury"}),e.jsx(cue,{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(vi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{vo(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(ea,{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(ur,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(El,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(nd,{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:()=>vo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(lue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function b4t({card:t}){var M,I,P,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:((I=t.bold_theme_colors)==null?void 0:I.accent)||"#ff5722",dark:((P=t.bold_theme_colors)==null?void 0:P.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},c=(q,$)=>{const z=parseInt(q.replace("#",""),16),V=Math.max(0,(z>>16)-$),X=Math.max(0,(z>>8&255)-$),Y=Math.max(0,(z&255)-$);return`#${(V<<16|X<<8|Y).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=(q,$)=>{vo(t.id,"button_click",q),$()},m=()=>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")}),y=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),vo(t.id,"button_click","book"))},_=()=>{var q,$;vo(t.id,"contact_saved"),due({name:o,phone:(q=t.profile)==null?void 0:q.phone,email:($=t.profile)==null?void 0:$.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{vo(t.id,"share_event");const q=`https://cards.relevelup.com/${t.slug}`,$="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:$,url:q})}catch{}else await navigator.clipboard.writeText(q),me.success("Link copied!")},j=()=>{a("referral"),r(!0),vo(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),vo(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(Cn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Wa,{src:t.avatar_url||void 0,alt:o}),e.jsx(Mn,{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:Nn,label:"Call",handler:m},{icon:Ki,label:"Text",handler:f},{icon:rr,label:"Email",handler:g}].map(({icon:q,label:$,handler:z})=>e.jsxs("button",{onClick:z,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:$})]},$))}),e.jsxs("button",{onClick:y,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(fn,{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(ea,{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(oue,{card:t,variant:"bold"}),e.jsx(cue,{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(vi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{vo(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(ea,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(ur,{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(El,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(nd,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map((q,$)=>e.jsx("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>vo(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()]||"🔗"},$))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(lue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function _4t({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)=>{vo(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")}),m=()=>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),vo(t.id,"button_click","book"))},g=()=>{var S,M;vo(t.id,"contact_saved"),due({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})},y=async()=>{vo(t.id,"share_event");const S=`https://cards.relevelup.com/${t.slug}`,M="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:M,url:S})}catch{}else await navigator.clipboard.writeText(S),me.success("Link copied!")},_=()=>{a("referral"),r(!0),vo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),vo(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Cn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Wa,{src:t.avatar_url||void 0,alt:o}),e.jsx(Mn,{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:Nn,label:"Call",handler:c},{icon:Ki,label:"Text",handler:u},{icon:rr,label:"Email",handler:m}].map(({icon:S,label:M,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children: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(fn,{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(ea,{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(oue,{card:t,variant:"classic"}),e.jsx(cue,{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(vi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{vo(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(ea,{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(ur,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(El,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:y,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(nd,{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:()=>vo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(lue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function kje({card:t}){switch(t.theme){case"luxury":return e.jsx(v4t,{card:t});case"bold":return e.jsx(b4t,{card:t});case"classic":return e.jsx(_4t,{card:t});case"standard":default:return e.jsx(y4t,{card:t})}}function w4t(){const t=hc();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(j4t,{slug:s})}function j4t({slug:t}){return e.jsx(N4t,{slug:t})}function N4t({slug:t}){var o;const{data:s,isLoading:r,error:n}=LWe(t);if(k.useEffect(()=>{s!=null&&s.id&&vo(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(ws,{className:"h-28 w-28 rounded-full"}),e.jsx(ws,{className:"h-6 w-48"}),e.jsx(ws,{className:"h-4 w-36"})]}),e.jsx(ws,{className:"h-12 w-full"}),e.jsx(ws,{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(Pl,{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(kje,{card:s})]})}function FWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=k.useState(n||""),[c,u]=k.useState(a||""),[m,f]=k.useState(o||""),[g,y]=k.useState(""),[_,w]=k.useState(""),[j,N]=k.useState(!1),[S,M]=k.useState(!1),I=async P=>{if(P.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:m.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:m.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(ua,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:I,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(Le,{id:"pres-lead-name",value:l,onChange:P=>i(P.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Le,{id:"pres-lead-phone",type:"tel",value:m,onChange:P=>f(P.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Le,{id:"pres-lead-email",type:"email",value:c,onChange:P=>u(P.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Rs,{value:g,onValueChange:y,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select one"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"buy",children:"Buy a home"}),e.jsx(ft,{value:"sell",children:"Sell my home"}),e.jsx(ft,{value:"both",children:"Buy & Sell"}),e.jsx(ft,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Le,{id:"pres-lead-message",value:_,onChange:P=>w(P.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(G,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:j,children:j?"Sending...":s})]})}function k4t(){const t=hc();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(S4t,{shareToken:s})}function S4t({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:w,error:j}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(j||!w){c(!0),a(!1);return}const{data:N}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(N!=null&&N.brokerage_id){const{data:I}=await H.from("brokerages").select("name").eq("id",N.brokerage_id).single();S=(I==null?void 0:I.name)||void 0}let M=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();M=I}r({...w,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: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{}},m=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=w=>{const j=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(j)return`https://www.youtube.com/embed/${j[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const M=w.replace("/play/","/embed/"),I=M.includes("?")?"&":"?";return`${M}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const M=w.includes("?")?"&":"?";return`${w}${M}responsive=true`}const N=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(ws,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ws,{className:"h-64 w-full"}),e.jsx(ws,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const g=s.sections.filter(w=>w.is_visible!==!1),y=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:[y!=null&&y.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(y.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):y!=null&&y.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:y.image_url,alt:y.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:y==null?void 0:y.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:y==null?void 0:y.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:y==null?void 0:y.description})]}),(y==null?void 0:y.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:y.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((w,j)=>e.jsx("button",{onClick:()=>l(j),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===j?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(j+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},j))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(_=s.cta_url)!=null&&_.trim()?e.jsxs(G,{size:"lg",onClick:m,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(rn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(FWe,{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 Gx=()=>{const t=Fa();return pt({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 C4t(){const{user:t}=Fs(),s=Fa(),{data:r}=Gx();return pt({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 m=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...m]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function eEs(t){const{user:s}=Fs();return pt({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 zWe(t){const{user:s}=Fs(),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]),pt({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 M4t(){const t=Qt(),s=Fa();return Tt({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"]}),kn({title:"Open house created!"})},onError:r=>{kn({title:"Error",description:r.message,variant:"destructive"})}})}function BWe(){const t=Qt();return Tt({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 T4t(){const t=Qt();return Tt({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"]}),kn({title:"Open house deleted"})}})}function A4t(t){return pt({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 E4t(t){const{user:s}=Fs();return pt({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 P4t(t){return pt({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 I4t(){return Tt({mutationFn:async t=>{const{error:s}=await H.from("open_house_survey_responses").insert(t);if(s)throw s}})}function L4t(t){const{user:s}=Fs();return pt({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 D4t(){const t=Qt();return Tt({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 O4t(){const t=Qt();return Tt({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 R4t(){const t=Qt();return Tt({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 F4t(){const t=Qt();return Tt({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 z4t(){return Tt({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}})}function B4t(){return Tt({mutationFn:async({visitor_id:t,...s})=>{const{error:r}=await H.from("open_house_visitors").update(s).eq("id",t);if(r)throw r}})}function $4t(){return Tt({mutationFn:async t=>{await H.rpc("increment_open_house_scan",{_slug:t})}})}var uue="Switch",[q4t]=od(uue),[U4t,V4t]=q4t(uue),$We=k.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c="on",onCheckedChange:u,form:m,...f}=t,[g,y]=k.useState(null),_=Ka(s,M=>y(M)),w=k.useRef(!1),j=g?m||!!g.closest("form"):!0,[N,S]=lh({prop:a,defaultProp:o??!1,onChange:u,caller:uue});return e.jsxs(U4t,{scope:r,checked:N,disabled:i,children:[e.jsx(cn.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":HWe(N),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:_,onClick:Or(t.onClick,M=>{S(I=>!I),j&&(w.current=M.isPropagationStopped(),w.current||M.stopPropagation())})}),j&&e.jsx(VWe,{control:g,bubbles:!w.current,name:n,value:c,checked:N,required:l,disabled:i,form:m,style:{transform:"translateX(-100%)"}})]})});$We.displayName=uue;var qWe="SwitchThumb",UWe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=V4t(qWe,r);return e.jsx(cn.span,{"data-state":HWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});UWe.displayName=qWe;var H4t="SwitchBubbleInput",VWe=k.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ka(l,o),c=YO(r),u=RO(s);return k.useEffect(()=>{const m=l.current;if(!m)return;const f=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&y){const _=new Event("click",{bubbles:n});y.call(m,r),m.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}})});VWe.displayName=H4t;function HWe(t){return t?"checked":"unchecked"}var GWe=$We,G4t=UWe;const qr=k.forwardRef(({className:t,...s},r)=>e.jsx(GWe,{className:Pt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(G4t,{className:Pt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));qr.displayName=GWe.displayName;function ia(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 vl(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Ll(t,s){const r=ia(t);return isNaN(s)?vl(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function qm(t,s){const r=ia(t);if(isNaN(s))return vl(t,NaN);if(!s)return r;const n=r.getDate(),a=vl(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 WWe(t,s){const r=+ia(t);return vl(t,r+s)}const Sje=6048e5,W4t=864e5,hue=6e4,QO=36e5,K4t=1e3,vz=43200,k6e=1440;function S6e(t,s){return WWe(t,s*QO)}let Z4t={};function zw(){return Z4t}function tm(t,s){var i,c,u,m;const r=zw(),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??((m=(u=r.locale)==null?void 0:u.options)==null?void 0:m.weekStartsOn)??0,a=ia(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Um(t){const s=ia(t);return s.setHours(0,0,0,0),s}function vw(t){const s=ia(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 ff(t,s){const r=Um(t),n=Um(s),a=+r-vw(r),o=+n-vw(n);return Math.round((a-o)/W4t)}function Y4t(t){const s=KWe(t),r=vl(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),O1(r)}function bM(t,s){return WWe(t,s*hue)}function j4(t,s){const r=s*7;return Ll(t,r)}function Q4t(t,s){return qm(t,s*12)}function X4t(t){let s;return t.forEach(function(r){const n=ia(r);(s===void 0||s{const n=ia(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function Nie(t,s){const r=ia(t),n=ia(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function Cje(t){return vl(t,Date.now())}function Tl(t,s){const r=Um(t),n=Um(s);return+r==+n}function Mje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Wve(t){if(!Mje(t)&&typeof t!="number")return!1;const s=ia(t);return!isNaN(Number(s))}function XT(t,s){const r=ia(t),n=ia(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function eSt(t,s,r){const n=tm(t,r),a=tm(s,r),o=+n-vw(n),l=+a-vw(a);return Math.round((o-l)/Sje)}function dy(t,s){const r=ia(t),n=ia(s),a=C6e(r,n),o=Math.abs(ff(r,n));r.setDate(r.getDate()-a*o);const l=+(C6e(r,n)===-a),i=a*(o-l);return i===0?0:i}function C6e(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 ZWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function YWe(t,s){return+ia(t)-+ia(s)}function tSt(t,s,r){const n=YWe(t,s)/QO;return ZWe(r==null?void 0:r.roundingMethod)(n)}function sSt(t){const s=ia(t);return s.setHours(23,59,59,999),s}function px(t){const s=ia(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function rSt(t){const s=ia(t);return+sSt(s)==+px(s)}function nSt(t,s){const r=ia(t),n=ia(s),a=Nie(r,n),o=Math.abs(XT(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=Nie(r,n)===-a;rSt(ia(t))&&o===1&&Nie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function aSt(t,s,r){const n=YWe(t,s)/1e3;return ZWe(r==null?void 0:r.roundingMethod)(n)}function iSt(t,s){const r=ia(t.start),n=ia(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(ia(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function Bc(t){const s=ia(t);return s.setDate(1),s.setHours(0,0,0,0),s}function QWe(t){const s=ia(t),r=vl(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function mue(t,s){var i,c,u,m;const r=zw(),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??((m=(u=r.locale)==null?void 0:u.options)==null?void 0:m.weekStartsOn)??0,a=ia(t),o=a.getDay(),l=(o{let n;const a=oSt[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 $xe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const cSt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},dSt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},uSt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hSt={date:$xe({formats:cSt,defaultWidth:"full"}),time:$xe({formats:dSt,defaultWidth:"full"}),dateTime:$xe({formats:uSt,defaultWidth:"full"})},mSt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pSt=(t,s,r,n)=>mSt[t];function iI(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 fSt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xSt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},gSt={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"]},ySt={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"]},vSt={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"}},bSt={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"}},_St=(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"},wSt={ordinalNumber:_St,era:iI({values:fSt,defaultWidth:"wide"}),quarter:iI({values:xSt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:iI({values:gSt,defaultWidth:"wide"}),day:iI({values:ySt,defaultWidth:"wide"}),dayPeriod:iI({values:vSt,defaultWidth:"wide",formattingValues:bSt,defaultFormattingWidth:"wide"})};function oI(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)?NSt(i,f=>f.test(l)):jSt(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const m=s.slice(l.length);return{value:u,rest:m}}}function jSt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function NSt(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 SSt=/^(\d+)(th|st|nd|rd)?/i,CSt=/\d+/i,MSt={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},TSt={any:[/^b/i,/^(a|c)/i]},ASt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ESt={any:[/1/i,/2/i,/3/i,/4/i]},PSt={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},ISt={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]},LSt={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},DSt={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]},OSt={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},RSt={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}},FSt={ordinalNumber:kSt({matchPattern:SSt,parsePattern:CSt,valueCallback:t=>parseInt(t,10)}),era:oI({matchPatterns:MSt,defaultMatchWidth:"wide",parsePatterns:TSt,defaultParseWidth:"any"}),quarter:oI({matchPatterns:ASt,defaultMatchWidth:"wide",parsePatterns:ESt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:oI({matchPatterns:PSt,defaultMatchWidth:"wide",parsePatterns:ISt,defaultParseWidth:"any"}),day:oI({matchPatterns:LSt,defaultMatchWidth:"wide",parsePatterns:DSt,defaultParseWidth:"any"}),dayPeriod:oI({matchPatterns:OSt,defaultMatchWidth:"any",parsePatterns:RSt,defaultParseWidth:"any"})},pue={code:"en-US",formatDistance:lSt,formatLong:hSt,formatRelative:pSt,localize:wSt,match:FSt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zSt(t){const s=ia(t);return ff(s,QWe(s))+1}function Tje(t){const s=ia(t),r=+O1(s)-+Y4t(s);return Math.round(r/Sje)+1}function Aje(t,s){var m,f,g,y;const r=ia(t),n=r.getFullYear(),a=zw(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(m=s==null?void 0:s.locale)==null?void 0:m.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((y=(g=a.locale)==null?void 0:g.options)==null?void 0:y.firstWeekContainsDate)??1,l=vl(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=tm(l,s),c=vl(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=tm(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function BSt(t,s){var i,c,u,m;const r=zw(),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??((m=(u=r.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??1,a=Aje(t,s),o=vl(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),tm(o,s)}function Eje(t,s){const r=ia(t),n=+tm(r,s)-+BSt(r,s);return Math.round(n/Sje)+1}function yl(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const qb={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return yl(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):yl(r+1,2)},d(t,s){return yl(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 yl(t.getHours()%12||12,s.length)},H(t,s){return yl(t.getHours(),s.length)},m(t,s){return yl(t.getMinutes(),s.length)},s(t,s){return yl(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return yl(a,s.length)}},D5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},M6e={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 qb.y(t,s)},Y:function(t,s,r,n){const a=Aje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return yl(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):yl(o,s.length)},R:function(t,s){const r=KWe(t);return yl(r,s.length)},u:function(t,s){const r=t.getFullYear();return yl(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 yl(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 yl(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 qb.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 yl(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=Eje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):yl(a,s.length)},I:function(t,s,r){const n=Tje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):yl(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):qb.d(t,s)},D:function(t,s,r){const n=zSt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):yl(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 yl(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 yl(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 yl(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=D5.noon:n===0?a=D5.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=D5.evening:n>=12?a=D5.afternoon:n>=4?a=D5.morning:a=D5.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 qb.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):qb.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):yl(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):yl(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):qb.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):qb.s(t,s)},S:function(t,s){return qb.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return A6e(n);case"XXXX":case"XX":return c4(n);case"XXXXX":case"XXX":default:return c4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return A6e(n);case"xxxx":case"xx":return c4(n);case"xxxxx":case"xxx":default:return c4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+T6e(n,":");case"OOOO":default:return"GMT"+c4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+T6e(n,":");case"zzzz":default:return"GMT"+c4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return yl(n,s.length)},T:function(t,s,r){const n=t.getTime();return yl(n,s.length)}};function T6e(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+yl(o,2)}function A6e(t,s){return t%60===0?(t>0?"-":"+")+yl(Math.abs(t)/60,2):c4(t,s)}function c4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=yl(Math.trunc(n/60),2),o=yl(n%60,2);return r+a+s+o}const E6e=(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"})}},JWe=(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"})}},$St=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return E6e(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}}",E6e(n,s)).replace("{{time}}",JWe(a,s))},Kve={p:JWe,P:$St},qSt=/^D+$/,USt=/^Y+$/,VSt=["D","DD","YY","YYYY"];function eKe(t){return qSt.test(t)}function tKe(t){return USt.test(t)}function Zve(t,s,r){const n=HSt(t,s,r);if(console.warn(n),VSt.includes(t))throw new RangeError(n)}function HSt(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 GSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,WSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,KSt=/^'([^]*?)'?$/,ZSt=/''/g,YSt=/[a-zA-Z]/;function ds(t,s,r){var m,f,g,y,_,w,j,N;const n=zw(),a=(r==null?void 0:r.locale)??n.locale??pue,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(m=r==null?void 0:r.locale)==null?void 0:m.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((y=(g=n.locale)==null?void 0:g.options)==null?void 0:y.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((w=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((N=(j=n.locale)==null?void 0:j.options)==null?void 0:N.weekStartsOn)??0,i=ia(t);if(!Wve(i))throw new RangeError("Invalid time value");let c=s.match(WSt).map(S=>{const M=S[0];if(M==="p"||M==="P"){const I=Kve[M];return I(S,a.formatLong)}return S}).join("").match(GSt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const M=S[0];if(M==="'")return{isToken:!1,value:QSt(S)};if(M6e[M])return{isToken:!0,value:S};if(M.match(YSt))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)&&tKe(M)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&eKe(M))&&Zve(M,s,String(t));const I=M6e[M[0]];return I(i,M,a.localize,u)}).join("")}function QSt(t){const s=t.match(KSt);return s?s[1].replace(ZSt,"'"):t}function XSt(t,s,r){const n=zw(),a=(r==null?void 0:r.locale)??n.locale??pue,o=2520,l=Nie(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=ia(s),u=ia(t)):(c=ia(t),u=ia(s));const m=aSt(u,c),f=(vw(u)-vw(c))/1e3,g=Math.round((m-f)/60);let y;if(g<2)return r!=null&&r.includeSeconds?m<5?a.formatDistance("lessThanXSeconds",5,i):m<10?a.formatDistance("lessThanXSeconds",10,i):m<20?a.formatDistance("lessThanXSeconds",20,i):m<40?a.formatDistance("halfAMinute",0,i):m<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 s3(t,s){const r=ia(t),n=ia(s);return+r<+n}function a3t(t){return+ia(t)>Date.now()}function i3t(t,s){const r=s instanceof Date?vl(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 o3t=10;class sKe{constructor(){Pn(this,"subPriority",0)}validate(s,r){return!0}}class l3t extends sKe{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 c3t extends sKe{constructor(){super(...arguments);Pn(this,"priority",o3t);Pn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:vl(r,i3t(r,Date))}}class ll{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new l3t(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class d3t extends ll{constructor(){super(...arguments);Pn(this,"priority",140);Pn(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 Od={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}/},i0={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 Rd(t,s){return t&&{value:s(t.value),rest:t.rest}}function ed(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function o0(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*QO+o*hue+l*K4t),rest:s.slice(r[0].length)}}function rKe(t){return ed(Od.anyDigitsSigned,t)}function Sd(t,s){switch(t){case 1:return ed(Od.singleDigit,s);case 2:return ed(Od.twoDigits,s);case 3:return ed(Od.threeDigits,s);case 4:return ed(Od.fourDigits,s);default:return ed(new RegExp("^\\d{1,"+t+"}"),s)}}function Roe(t,s){switch(t){case 1:return ed(Od.singleDigitSigned,s);case 2:return ed(Od.twoDigitsSigned,s);case 3:return ed(Od.threeDigitsSigned,s);case 4:return ed(Od.fourDigitsSigned,s);default:return ed(new RegExp("^-?\\d{1,"+t+"}"),s)}}function Pje(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 nKe(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 aKe(t){return t%400===0||t%4===0&&t%100!==0}class u3t extends ll{constructor(){super(...arguments);Pn(this,"priority",130);Pn(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 Rd(Sd(4,r),o);case"yo":return Rd(a.ordinalNumber(r,{unit:"year"}),o);default:return Rd(Sd(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=nKe(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 h3t extends ll{constructor(){super(...arguments);Pn(this,"priority",130);Pn(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 Rd(Sd(4,r),o);case"Yo":return Rd(a.ordinalNumber(r,{unit:"year"}),o);default:return Rd(Sd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Aje(r,o);if(a.isTwoDigitYear){const c=nKe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),tm(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),tm(r,o)}}class m3t extends ll{constructor(){super(...arguments);Pn(this,"priority",130);Pn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Roe(n==="R"?4:n.length,r)}set(r,n,a){const o=vl(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),O1(o)}}class p3t extends ll{constructor(){super(...arguments);Pn(this,"priority",130);Pn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Roe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class f3t extends ll{constructor(){super(...arguments);Pn(this,"priority",120);Pn(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 Sd(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 x3t extends ll{constructor(){super(...arguments);Pn(this,"priority",120);Pn(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 Sd(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 g3t extends ll{constructor(){super(...arguments);Pn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Pn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Rd(ed(Od.month,r),o);case"MM":return Rd(Sd(2,r),o);case"Mo":return Rd(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 y3t extends ll{constructor(){super(...arguments);Pn(this,"priority",110);Pn(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 Rd(ed(Od.month,r),o);case"LL":return Rd(Sd(2,r),o);case"Lo":return Rd(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 v3t(t,s,r){const n=ia(t),a=Eje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class b3t extends ll{constructor(){super(...arguments);Pn(this,"priority",100);Pn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return ed(Od.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Sd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return tm(v3t(r,a,o),o)}}function _3t(t,s){const r=ia(t),n=Tje(r)-s;return r.setDate(r.getDate()-n*7),r}class w3t extends ll{constructor(){super(...arguments);Pn(this,"priority",100);Pn(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 ed(Od.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Sd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return O1(_3t(r,a))}}const j3t=[31,28,31,30,31,30,31,31,30,31,30,31],N3t=[31,29,31,30,31,30,31,31,30,31,30,31];class k3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(this,"subPriority",1);Pn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return ed(Od.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Sd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=aKe(a),l=r.getMonth();return o?n>=1&&n<=N3t[l]:n>=1&&n<=j3t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class S3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(this,"subpriority",1);Pn(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 ed(Od.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Sd(n.length,r)}}validate(r,n){const a=r.getFullYear();return aKe(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 Ije(t,s,r){var f,g,y,_;const n=zw(),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??((_=(y=n.locale)==null?void 0:y.options)==null?void 0:_.weekStartsOn)??0,o=ia(t),l=o.getDay(),c=(s%7+7)%7,u=7-a,m=s<0||s>6?s-(l+u)%7:(c+u)%7-(l+u)%7;return Ll(o,m)}class C3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(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=Ije(r,a,o),r.setHours(0,0,0,0),r}}class M3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(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 Rd(Sd(n.length,r),l);case"eo":return Rd(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=Ije(r,a,o),r.setHours(0,0,0,0),r}}class T3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(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 Rd(Sd(n.length,r),l);case"co":return Rd(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=Ije(r,a,o),r.setHours(0,0,0,0),r}}function A3t(t,s){const r=ia(t),n=t3t(r),a=s-n;return Ll(r,a)}class E3t extends ll{constructor(){super(...arguments);Pn(this,"priority",90);Pn(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 Sd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Rd(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 Rd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Rd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Rd(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=A3t(r,a),r.setHours(0,0,0,0),r}}class P3t extends ll{constructor(){super(...arguments);Pn(this,"priority",80);Pn(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(Pje(a),0,0,0),r}}class I3t extends ll{constructor(){super(...arguments);Pn(this,"priority",80);Pn(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(Pje(a),0,0,0),r}}class L3t extends ll{constructor(){super(...arguments);Pn(this,"priority",80);Pn(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(Pje(a),0,0,0),r}}class D3t extends ll{constructor(){super(...arguments);Pn(this,"priority",70);Pn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return ed(Od.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Sd(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 O3t extends ll{constructor(){super(...arguments);Pn(this,"priority",70);Pn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return ed(Od.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Sd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class R3t extends ll{constructor(){super(...arguments);Pn(this,"priority",70);Pn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return ed(Od.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Sd(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 F3t extends ll{constructor(){super(...arguments);Pn(this,"priority",70);Pn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return ed(Od.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Sd(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 z3t extends ll{constructor(){super(...arguments);Pn(this,"priority",60);Pn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return ed(Od.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Sd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class B3t extends ll{constructor(){super(...arguments);Pn(this,"priority",50);Pn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return ed(Od.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Sd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class $3t extends ll{constructor(){super(...arguments);Pn(this,"priority",30);Pn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Rd(Sd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class q3t extends ll{constructor(){super(...arguments);Pn(this,"priority",10);Pn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return o0(i0.basicOptionalMinutes,r);case"XX":return o0(i0.basic,r);case"XXXX":return o0(i0.basicOptionalSeconds,r);case"XXXXX":return o0(i0.extendedOptionalSeconds,r);case"XXX":default:return o0(i0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:vl(r,r.getTime()-vw(r)-a)}}class U3t extends ll{constructor(){super(...arguments);Pn(this,"priority",10);Pn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return o0(i0.basicOptionalMinutes,r);case"xx":return o0(i0.basic,r);case"xxxx":return o0(i0.basicOptionalSeconds,r);case"xxxxx":return o0(i0.extendedOptionalSeconds,r);case"xxx":default:return o0(i0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:vl(r,r.getTime()-vw(r)-a)}}class V3t extends ll{constructor(){super(...arguments);Pn(this,"priority",40);Pn(this,"incompatibleTokens","*")}parse(r){return rKe(r)}set(r,n,a){return[vl(r,a*1e3),{timestampIsSet:!0}]}}class H3t extends ll{constructor(){super(...arguments);Pn(this,"priority",20);Pn(this,"incompatibleTokens","*")}parse(r){return rKe(r)}set(r,n,a){return[vl(r,a),{timestampIsSet:!0}]}}const G3t={G:new d3t,y:new u3t,Y:new h3t,R:new m3t,u:new p3t,Q:new f3t,q:new x3t,M:new g3t,L:new y3t,w:new b3t,I:new w3t,d:new k3t,D:new S3t,E:new C3t,e:new M3t,c:new T3t,i:new E3t,a:new P3t,b:new I3t,B:new L3t,h:new D3t,H:new O3t,K:new R3t,k:new F3t,m:new z3t,s:new B3t,S:new $3t,X:new q3t,x:new U3t,t:new V3t,T:new H3t},W3t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,K3t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Z3t=/^'([^]*?)'?$/,Y3t=/''/g,Q3t=/\S/,X3t=/[a-zA-Z]/;function Lje(t,s,r,n){var w,j,N,S;const a=e3t(),o=a.locale??pue,l=a.firstWeekContainsDate??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(N=a.locale)==null?void 0:N.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?ia(r):vl(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new c3t],m=s.match(K3t).map(M=>{const I=M[0];if(I in Kve){const P=Kve[I];return P(M,o.formatLong)}return M}).join("").match(W3t),f=[];for(let M of m){tKe(M)&&Zve(M,s,t),eKe(M)&&Zve(M,s,t);const I=M[0],P=G3t[I];if(P){const{incompatibleTokens:O}=P;if(Array.isArray(O)){const $=f.find(z=>O.includes(z.token)||z.token===I);if($)throw new RangeError(`The format string mustn't contain \`${$.fullToken}\` and \`${M}\` at the same time`)}else if(P.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:I,fullToken:M});const q=P.run(t,M,o.match,c);if(!q)return vl(r,NaN);u.push(q.setter),t=q.rest}else{if(I.match(X3t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(M==="''"?M="'":I==="'"&&(M=J3t(M)),t.indexOf(M)===0)t=t.slice(M.length);else return vl(r,NaN)}}if(t.length>0&&Q3t.test(t))return vl(r,NaN);const g=u.map(M=>M.priority).sort((M,I)=>I-M).filter((M,I,P)=>P.indexOf(M)===I).map(M=>u.filter(I=>I.priority===M).sort((I,P)=>P.subPriority-I.subPriority)).map(M=>M[0]);let y=ia(r);if(isNaN(y.getTime()))return vl(r,NaN);const _={};for(const M of g){if(!M.validate(y,c))return vl(r,NaN);const I=M.set(y,_,c);Array.isArray(I)?(y=I[0],Object.assign(_,I[1])):y=I}return vl(r,y)}function J3t(t){return t.match(Z3t)[1].replace(Y3t,"'")}function M0(t){return+ia(t)o-l);return r>=n&&r<=a}function kie(t,s){return Ll(t,-s)}function Mm(t,s){const n=iCt(t);let a;if(n.date){const c=oCt(n.date,2);a=lCt(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=cCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=dCt(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 bz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},rCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,nCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,aCt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function iCt(t){const s={},r=t.split(bz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],bz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(bz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=bz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function oCt(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 lCt(t,s){if(s===null)return new Date(NaN);const r=t.match(rCt);if(!r)return new Date(NaN);const n=!!r[4],a=lI(r[1]),o=lI(r[2])-1,l=lI(r[3]),i=lI(r[4]),c=lI(r[5])-1;if(n)return fCt(s,i,c)?uCt(s,i,c):new Date(NaN);{const u=new Date(0);return!mCt(s,o,l)||!pCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function lI(t){return t?parseInt(t):1}function cCt(t){const s=t.match(nCt);if(!s)return NaN;const r=qxe(s[1]),n=qxe(s[2]),a=qxe(s[3]);return xCt(r,n,a)?r*QO+n*hue+a*1e3:NaN}function qxe(t){return t&&parseFloat(t.replace(",","."))||0}function dCt(t){if(t==="Z")return 0;const s=t.match(aCt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return gCt(n,a)?r*(n*QO+a*hue):NaN}function uCt(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 hCt=[31,null,31,30,31,30,31,31,30,31,30,31];function iKe(t){return t%400===0||t%4===0&&t%100!==0}function mCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(hCt[s]||(iKe(t)?29:28))}function pCt(t,s){return s>=1&&s<=(iKe(t)?366:365)}function fCt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function xCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function gCt(t,s){return s>=0&&s<=59}function Uxe(t,s){const r=ia(t),n=r.getFullYear(),a=r.getDate(),o=vl(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=JSt(o);return r.setMonth(s,Math.min(a,l)),r}function o8(t,s){const r=ia(t);return r.setHours(s),r}function l8(t,s){const r=ia(t);return r.setMinutes(s),r}function I6e(t,s){const r=ia(t);return isNaN(+r)?vl(t,NaN):(r.setFullYear(s),r)}function N4(t,s){return qm(t,-s)}var Yo;(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})(Yo||(Yo={}));var L6e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(L6e||(L6e={}));const va=Yo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),t_=t=>{switch(typeof t){case"undefined":return va.undefined;case"string":return va.string;case"number":return Number.isNaN(t)?va.nan:va.number;case"boolean":return va.boolean;case"function":return va.function;case"bigint":return va.bigint;case"symbol":return va.symbol;case"object":return Array.isArray(t)?va.array:t===null?va.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?va.promise:typeof Map<"u"&&t instanceof Map?va.map:typeof Set<"u"&&t instanceof Set?va.set:typeof Date<"u"&&t instanceof Date?va.date:va.object;default:return va.unknown}},hn=Yo.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 D0 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()}}D0.create=t=>new D0(t);const Yve=(t,s)=>{let r;switch(t.code){case hn.invalid_type:t.received===va.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case hn.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Yo.jsonStringifyReplacer)}`;break;case hn.unrecognized_keys:r=`Unrecognized key(s) in object: ${Yo.joinValues(t.keys,", ")}`;break;case hn.invalid_union:r="Invalid input";break;case hn.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Yo.joinValues(t.options)}`;break;case hn.invalid_enum_value:r=`Invalid enum value. Expected ${Yo.joinValues(t.options)}, received '${t.received}'`;break;case hn.invalid_arguments:r="Invalid function arguments";break;case hn.invalid_return_type:r="Invalid function return type";break;case hn.invalid_date:r="Invalid date";break;case hn.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}"`:Yo.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case hn.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 hn.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 hn.custom:r="Invalid input";break;case hn.invalid_intersection_types:r="Intersection results could not be merged";break;case hn.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case hn.not_finite:r="Number must be finite";break;default:r=s.defaultError,Yo.assertNever(t)}return{message:r}};let yCt=Yve;function vCt(){return yCt}const bCt=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 Jn(t,s){const r=vCt(),n=bCt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Yve?void 0:Yve].filter(a=>!!a)});t.common.issues.push(n)}class Af{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 Bi;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 Af.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 Bi;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 Bi=Object.freeze({status:"aborted"}),qI=t=>({status:"dirty",value:t}),Wx=t=>({status:"valid",value:t}),D6e=t=>t.status==="aborted",O6e=t=>t.status==="dirty",JT=t=>t.status==="valid",Foe=t=>typeof Promise<"u"&&t instanceof Promise;var Ma;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(Ma||(Ma={}));class bw{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 R6e=(t,s)=>{if(JT(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 D0(t.common.issues);return this._error=r,this._error}}};function uo(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 Wo{get description(){return this._def.description}_getType(s){return t_(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:t_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Af,ctx:{common:s.parent.common,data:s.data,parsedType:t_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Foe(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:t_(s)},a=this._parseSync({data:s,path:n.path,parent:n});return R6e(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:t_(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return JT(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=>JT(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:t_(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Foe(a)?a:Promise.resolve(a));return R6e(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:hn.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 sA({schema:this,typeName:$i.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 nw.create(this,this._def)}nullable(){return rA.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return T0.create(this)}promise(){return qoe.create(this,this._def)}or(s){return Boe.create([this,s],this._def)}and(s){return $oe.create(this,s,this._def)}transform(s){return new sA({...uo(this._def),schema:this,typeName:$i.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new e1e({...uo(this._def),innerType:this,defaultValue:r,typeName:$i.ZodDefault})}brand(){return new UCt({typeName:$i.ZodBranded,type:this,...uo(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new t1e({...uo(this._def),innerType:this,catchValue:r,typeName:$i.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return Dje.create(this,s)}readonly(){return s1e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _Ct=/^c[^\s-]{8,}$/i,wCt=/^[0-9a-z]+$/,jCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,NCt=/^[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,kCt=/^[a-z0-9_-]{21}$/i,SCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,CCt=/^[-+]?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)?)??$/,MCt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,TCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Vxe;const ACt=/^(?:(?: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])$/,ECt=/^(?:(?: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])$/,PCt=/^(([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]))$/,ICt=/^(([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])$/,LCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,DCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,oKe="((\\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])))",OCt=new RegExp(`^${oKe}$`);function lKe(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 RCt(t){return new RegExp(`^${lKe(t)}$`)}function FCt(t){let s=`${oKe}T${lKe(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 zCt(t,s){return!!((s==="v4"||!s)&&ACt.test(t)||(s==="v6"||!s)&&PCt.test(t))}function BCt(t,s){if(!SCt.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 $Ct(t,s){return!!((s==="v4"||!s)&&ECt.test(t)||(s==="v6"||!s)&&ICt.test(t))}class P_ extends Wo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==va.string){const o=this._getOrReturnCtx(s);return Jn(o,{code:hn.invalid_type,expected:va.string,received:o.parsedType}),Bi}const n=new Af;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Jn(a,{code:hn.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:hn.invalid_string,...Ma.errToObj(n)})}_addCheck(s){return new P_({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...Ma.errToObj(s)})}url(s){return this._addCheck({kind:"url",...Ma.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...Ma.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...Ma.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...Ma.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...Ma.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...Ma.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...Ma.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...Ma.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...Ma.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...Ma.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...Ma.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...Ma.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,...Ma.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,...Ma.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...Ma.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...Ma.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...Ma.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...Ma.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...Ma.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...Ma.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...Ma.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...Ma.errToObj(r)})}nonempty(s){return this.min(1,Ma.errToObj(s))}trim(){return new P_({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P_({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P_({...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 P_({checks:[],typeName:$i.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...uo(t)});function qCt(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 eA extends Wo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==va.number){const o=this._getOrReturnCtx(s);return Jn(o,{code:hn.invalid_type,expected:va.number,received:o.parsedType}),Bi}let n;const a=new Af;for(const o of this._def.checks)o.kind==="int"?Yo.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Jn(n,{code:hn.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),Jn(n,{code:hn.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?qCt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Jn(n,{code:hn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Jn(n,{code:hn.not_finite,message:o.message}),a.dirty()):Yo.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,Ma.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Ma.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Ma.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Ma.toString(r))}setLimit(s,r,n,a){return new eA({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Ma.toString(a)}]})}_addCheck(s){return new eA({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:Ma.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ma.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ma.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ma.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ma.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Ma.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:Ma.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ma.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ma.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"&&Yo.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 eA({checks:[],typeName:$i.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...uo(t)});class gD extends Wo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==va.bigint)return this._getInvalidInput(s);let n;const a=new Af;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Jn(n,{code:hn.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),Jn(n,{code:hn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Yo.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Jn(r,{code:hn.invalid_type,expected:va.bigint,received:r.parsedType}),Bi}gte(s,r){return this.setLimit("min",s,!0,Ma.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Ma.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Ma.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Ma.toString(r))}setLimit(s,r,n,a){return new gD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Ma.toString(a)}]})}_addCheck(s){return new gD({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ma.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ma.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ma.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ma.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Ma.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 gD({checks:[],typeName:$i.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...uo(t)});class Qve extends Wo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==va.boolean){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.boolean,received:n.parsedType}),Bi}return Wx(s.data)}}Qve.create=t=>new Qve({typeName:$i.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...uo(t)});class zoe extends Wo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==va.date){const o=this._getOrReturnCtx(s);return Jn(o,{code:hn.invalid_type,expected:va.date,received:o.parsedType}),Bi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Jn(o,{code:hn.invalid_date}),Bi}const n=new Af;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Jn(a,{code:hn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Yo.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new zoe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:Ma.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:Ma.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 zoe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:$i.ZodDate,...uo(t)});class F6e extends Wo{_parse(s){if(this._getType(s)!==va.symbol){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.symbol,received:n.parsedType}),Bi}return Wx(s.data)}}F6e.create=t=>new F6e({typeName:$i.ZodSymbol,...uo(t)});class z6e extends Wo{_parse(s){if(this._getType(s)!==va.undefined){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.undefined,received:n.parsedType}),Bi}return Wx(s.data)}}z6e.create=t=>new z6e({typeName:$i.ZodUndefined,...uo(t)});class B6e extends Wo{_parse(s){if(this._getType(s)!==va.null){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.null,received:n.parsedType}),Bi}return Wx(s.data)}}B6e.create=t=>new B6e({typeName:$i.ZodNull,...uo(t)});class $6e extends Wo{constructor(){super(...arguments),this._any=!0}_parse(s){return Wx(s.data)}}$6e.create=t=>new $6e({typeName:$i.ZodAny,...uo(t)});class q6e extends Wo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Wx(s.data)}}q6e.create=t=>new q6e({typeName:$i.ZodUnknown,...uo(t)});class _w extends Wo{_parse(s){const r=this._getOrReturnCtx(s);return Jn(r,{code:hn.invalid_type,expected:va.never,received:r.parsedType}),Bi}}_w.create=t=>new _w({typeName:$i.ZodNever,...uo(t)});class U6e extends Wo{_parse(s){if(this._getType(s)!==va.undefined){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.void,received:n.parsedType}),Bi}return Wx(s.data)}}U6e.create=t=>new U6e({typeName:$i.ZodVoid,...uo(t)});class T0 extends Wo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==va.array)return Jn(r,{code:hn.invalid_type,expected:va.array,received:r.parsedType}),Bi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Jn(r,{code:hn.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 bw(r,l,r.path,i)))).then(l=>Af.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new bw(r,l,r.path,i)));return Af.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new T0({...this._def,minLength:{value:s,message:Ma.toString(r)}})}max(s,r){return new T0({...this._def,maxLength:{value:s,message:Ma.toString(r)}})}length(s,r){return new T0({...this._def,exactLength:{value:s,message:Ma.toString(r)}})}nonempty(s){return this.min(1,s)}}T0.create=(t,s)=>new T0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:$i.ZodArray,...uo(s)});function J5(t){if(t instanceof Jd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=nw.create(J5(n))}return new Jd({...t._def,shape:()=>s})}else return t instanceof T0?new T0({...t._def,type:J5(t.element)}):t instanceof nw?nw.create(J5(t.unwrap())):t instanceof rA?rA.create(J5(t.unwrap())):t instanceof r3?r3.create(t.items.map(s=>J5(s))):t}class Jd extends Wo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Yo.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==va.object){const u=this._getOrReturnCtx(s);return Jn(u,{code:hn.invalid_type,expected:va.object,received:u.parsedType}),Bi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof _w&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const c=[];for(const u of l){const m=o[u],f=a.data[u];c.push({key:{status:"valid",value:u},value:m._parse(new bw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof _w){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of i)c.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(u==="strict")i.length>0&&(Jn(a,{code:hn.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 m of i){const f=a.data[m];c.push({key:{status:"valid",value:m},value:u._parse(new bw(a,f,a.path,m)),alwaysSet:m in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of c){const f=await m.key,g=await m.value;u.push({key:f,value:g,alwaysSet:m.alwaysSet})}return u}).then(u=>Af.mergeObjectSync(n,u)):Af.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return Ma.errToObj,new Jd({...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:Ma.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Jd({...this._def,unknownKeys:"strip"})}passthrough(){return new Jd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Jd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Jd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:$i.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Jd({...this._def,catchall:s})}pick(s){const r={};for(const n of Yo.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Jd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Yo.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Jd({...this._def,shape:()=>r})}deepPartial(){return J5(this)}partial(s){const r={};for(const n of Yo.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Jd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Yo.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof nw;)o=o._def.innerType;r[n]=o}return new Jd({...this._def,shape:()=>r})}keyof(){return cKe(Yo.objectKeys(this.shape))}}Jd.create=(t,s)=>new Jd({shape:()=>t,unknownKeys:"strip",catchall:_w.create(),typeName:$i.ZodObject,...uo(s)});Jd.strictCreate=(t,s)=>new Jd({shape:()=>t,unknownKeys:"strict",catchall:_w.create(),typeName:$i.ZodObject,...uo(s)});Jd.lazycreate=(t,s)=>new Jd({shape:t,unknownKeys:"strip",catchall:_w.create(),typeName:$i.ZodObject,...uo(s)});class Boe extends Wo{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new D0(i.ctx.common.issues));return Jn(r,{code:hn.invalid_union,unionErrors:l}),Bi}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},m=c._parseSync({data:r.data,path:r.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!o&&(o={result:m,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 D0(c));return Jn(r,{code:hn.invalid_union,unionErrors:i}),Bi}}get options(){return this._def.options}}Boe.create=(t,s)=>new Boe({options:t,typeName:$i.ZodUnion,...uo(s)});function Xve(t,s){const r=t_(t),n=t_(s);if(t===s)return{valid:!0,data:t};if(r===va.object&&n===va.object){const a=Yo.objectKeys(s),o=Yo.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=Xve(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===va.array&&n===va.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(D6e(o)||D6e(l))return Bi;const i=Xve(o.value,l.value);return i.valid?((O6e(o)||O6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Jn(n,{code:hn.invalid_intersection_types}),Bi)};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}))}}$oe.create=(t,s,r)=>new $oe({left:t,right:s,typeName:$i.ZodIntersection,...uo(r)});class r3 extends Wo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==va.array)return Jn(n,{code:hn.invalid_type,expected:va.array,received:n.parsedType}),Bi;if(n.data.lengththis._def.items.length&&(Jn(n,{code:hn.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 bw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Af.mergeArray(r,l)):Af.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new r3({...this._def,rest:s})}}r3.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new r3({items:t,typeName:$i.ZodTuple,rest:null,...uo(s)})};class V6e extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==va.map)return Jn(n,{code:hn.invalid_type,expected:va.map,received:n.parsedType}),Bi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,c],u)=>({key:a._parse(new bw(n,i,n.path,[u,"key"])),value:o._parse(new bw(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,m=await c.value;if(u.status==="aborted"||m.status==="aborted")return Bi;(u.status==="dirty"||m.status==="dirty")&&r.dirty(),i.set(u.value,m.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const c of l){const u=c.key,m=c.value;if(u.status==="aborted"||m.status==="aborted")return Bi;(u.status==="dirty"||m.status==="dirty")&&r.dirty(),i.set(u.value,m.value)}return{status:r.value,value:i}}}}V6e.create=(t,s,r)=>new V6e({valueType:s,keyType:t,typeName:$i.ZodMap,...uo(r)});class yD extends Wo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==va.set)return Jn(n,{code:hn.invalid_type,expected:va.set,received:n.parsedType}),Bi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Jn(n,{code:hn.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 m of c){if(m.status==="aborted")return Bi;m.status==="dirty"&&r.dirty(),u.add(m.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((c,u)=>o._parse(new bw(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new yD({...this._def,minSize:{value:s,message:Ma.toString(r)}})}max(s,r){return new yD({...this._def,maxSize:{value:s,message:Ma.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}yD.create=(t,s)=>new yD({valueType:t,minSize:null,maxSize:null,typeName:$i.ZodSet,...uo(s)});class H6e extends Wo{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}H6e.create=(t,s)=>new H6e({getter:t,typeName:$i.ZodLazy,...uo(s)});class Jve extends Wo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Jn(r,{received:r.data,code:hn.invalid_literal,expected:this._def.value}),Bi}return{status:"valid",value:s.data}}get value(){return this._def.value}}Jve.create=(t,s)=>new Jve({value:t,typeName:$i.ZodLiteral,...uo(s)});function cKe(t,s){return new tA({values:t,typeName:$i.ZodEnum,...uo(s)})}class tA extends Wo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Jn(r,{expected:Yo.joinValues(n),received:r.parsedType,code:hn.invalid_type}),Bi}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 Jn(r,{received:r.data,code:hn.invalid_enum_value,options:n}),Bi}return Wx(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 tA.create(s,{...this._def,...r})}exclude(s,r=this._def){return tA.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}tA.create=cKe;class G6e extends Wo{_parse(s){const r=Yo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==va.string&&n.parsedType!==va.number){const a=Yo.objectValues(r);return Jn(n,{expected:Yo.joinValues(a),received:n.parsedType,code:hn.invalid_type}),Bi}if(this._cache||(this._cache=new Set(Yo.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Yo.objectValues(r);return Jn(n,{received:n.data,code:hn.invalid_enum_value,options:a}),Bi}return Wx(s.data)}get enum(){return this._def.values}}G6e.create=(t,s)=>new G6e({values:t,typeName:$i.ZodNativeEnum,...uo(s)});class qoe extends Wo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==va.promise&&r.common.async===!1)return Jn(r,{code:hn.invalid_type,expected:va.promise,received:r.parsedType}),Bi;const n=r.parsedType===va.promise?r.data:Promise.resolve(r.data);return Wx(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}qoe.create=(t,s)=>new qoe({type:t,typeName:$i.ZodPromise,...uo(s)});class sA extends Wo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$i.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=>{Jn(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 Bi;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?Bi:c.status==="dirty"||r.value==="dirty"?qI(c.value):c});{if(r.value==="aborted")return Bi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Bi:i.status==="dirty"||r.value==="dirty"?qI(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"?Bi:(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"?Bi:(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(!JT(l))return Bi;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=>JT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Bi);Yo.assertNever(a)}}sA.create=(t,s,r)=>new sA({schema:t,typeName:$i.ZodEffects,effect:s,...uo(r)});sA.createWithPreprocess=(t,s,r)=>new sA({schema:s,effect:{type:"preprocess",transform:t},typeName:$i.ZodEffects,...uo(r)});class nw extends Wo{_parse(s){return this._getType(s)===va.undefined?Wx(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}nw.create=(t,s)=>new nw({innerType:t,typeName:$i.ZodOptional,...uo(s)});class rA extends Wo{_parse(s){return this._getType(s)===va.null?Wx(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}rA.create=(t,s)=>new rA({innerType:t,typeName:$i.ZodNullable,...uo(s)});class e1e extends Wo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===va.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}e1e.create=(t,s)=>new e1e({innerType:t,typeName:$i.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...uo(s)});class t1e extends Wo{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Foe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new D0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new D0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}t1e.create=(t,s)=>new t1e({innerType:t,typeName:$i.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...uo(s)});class W6e extends Wo{_parse(s){if(this._getType(s)!==va.nan){const n=this._getOrReturnCtx(s);return Jn(n,{code:hn.invalid_type,expected:va.nan,received:n.parsedType}),Bi}return{status:"valid",value:s.data}}}W6e.create=t=>new W6e({typeName:$i.ZodNaN,...uo(t)});class UCt extends Wo{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Dje extends Wo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Bi:o.status==="dirty"?(r.dirty(),qI(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"?Bi: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 Dje({in:s,out:r,typeName:$i.ZodPipeline})}}class s1e extends Wo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(JT(a)&&(a.value=Object.freeze(a.value)),a);return Foe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}s1e.create=(t,s)=>new s1e({innerType:t,typeName:$i.ZodReadonly,...uo(s)});var $i;(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"})($i||($i={}));const wc=P_.create,c8=eA.create,VCt=Qve.create;_w.create;T0.create;const A3=Jd.create;Boe.create;$oe.create;r3.create;const Uoe=Jve.create,dKe=tA.create;qoe.create;nw.create;rA.create;const Tr=k.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Pt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Tr.displayName="Textarea";const HCt=["Excellent","Good","Neutral","Bad","Very Bad"],GCt=[5,4,3,2,1];function WCt({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=I4t(),[o,l]=k.useState({}),i=t.filter(g=>g.question_type==="rating"),c=t.filter(g=>g.question_type!=="rating"),u=(g,y)=>{l(_=>({..._,[g]:{rating_value:y}}))},m=(g,y)=>{l(_=>({..._,[g]:{text_value:y}}))},f=async()=>{const g=Object.entries(o).filter(([,y])=>y.rating_value!=null||y.text_value&&y.text_value.trim()).map(([y,_])=>{var w;return{visitor_id:s,question_id:y,rating_value:_.rating_value??null,text_value:((w=_.text_value)==null?void 0:w.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"}),HCt.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}),GCt.map(y=>{var _;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(g.id,y),className:`w-6 h-6 rounded-full border-2 transition-all ${((_=o[g.id])==null?void 0:_.rating_value)===y?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},y)})]},g.id))]}),c.map(g=>{var y;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(Tr,{value:((y=o[g.id])==null?void 0:y.text_value)||"",onChange:_=>m(g.id,_.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},g.id)}),e.jsx(G,{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(ys,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const KCt=A3({first_name:wc().trim().min(1,"First name is required").max(50),last_name:wc().trim().max(50).optional(),email:wc().trim().email("Please enter a valid email").max(255).optional().or(Uoe("")),phone:wc().trim().max(20).optional().or(Uoe(""))}),ZCt=[{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 uKe({slug:t}={}){var he;const s=ao(),r=t||s.slug,{data:n,isLoading:a,error:o}=A4t(r),l=z4t(),i=B4t(),c=$4t(),u=k.useRef(!1),[m,f]=k.useState("welcome"),[g,y]=k.useState(null),[_,w]=k.useState({first_name:"",last_name:"",email:"",phone:""}),[j,N]=k.useState(""),[S,M]=k.useState(!1),[I,P]=k.useState(!1),[O,q]=k.useState(""),[$,z]=k.useState(""),{data:V,isLoading:X}=P4t(n==null?void 0:n.id),Y=!!(n!=null&&n.enable_survey);k.useEffect(()=>{if(!r||!(n!=null&&n.id)||u.current)return;const xe=`oh_scan_${n.id}`;if(sessionStorage.getItem(xe)){u.current=!0;return}u.current=!0,sessionStorage.setItem(xe,"1"),c.mutate(r)},[r,n==null?void 0:n.id]),k.useEffect(()=>{m==="pending_survey"&&(X||f(Y&&((V==null?void 0:V.length)??0)>0?"survey":"done"))},[m,X,Y,V]);const J=xe=>{if(!xe)return"";const[ue,ge]=xe.split(":"),_e=parseInt(ue),Be=_e>=12?"PM":"AM";return`${_e>12?_e-12:_e||12}:${ge} ${Be}`},Q=async()=>{z("");const xe=KCt.safeParse(_);if(!xe.success){z(xe.error.issues[0].message);return}if(!_.email&&!_.phone){z("Please provide either an email or phone number");return}if(!g&&(n!=null&&n.id))try{const ue=await l.mutateAsync({open_house_id:n.id,first_name:_.first_name.trim(),last_name:_.last_name.trim()||void 0,email:_.email.trim()||void 0,phone:_.phone.trim()||void 0,wants_market_updates:S,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:!0});y(ue.id)}catch{}f("intent")},ce=async xe=>{N(xe);try{let ue=g;ue?await i.mutateAsync({visitor_id:ue,visitor_intent:xe,wants_market_updates:S,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():null,partial_signin:!1}):(ue=(await l.mutateAsync({open_house_id:n.id,first_name:_.first_name.trim(),last_name:_.last_name.trim()||void 0,email:_.email.trim()||void 0,phone:_.phone.trim()||void 0,visitor_intent:xe,wants_market_updates:S,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:!1})).id,y(ue)),Y?!X&&V&&V.length>0?f("survey"):f("pending_survey"):f("done")}catch{z("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(xn,{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 ne=n.profiles,re=((he=ne==null?void 0:ne.name)==null?void 0:he.split(" ").map(xe=>xe[0]).join("").slice(0,2))||"?",oe=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{children:[e.jsxs("title",{children:[oe?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${oe?"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(Cn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Wa,{src:(ne==null?void 0:ne.avatar_url)||"",alt:(ne==null?void 0:ne.name)||""}),e.jsx(Mn,{className:"bg-white/10 text-white text-lg",children:re})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ne==null?void 0:ne.name}),(ne==null?void 0:ne.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ne.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(aa,{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(fn,{className:"h-3 w-3"}),ds(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(mn,{className:"h-3 w-3"}),J(n.start_time),n.end_time?` – ${J(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:oe?e.jsx(Ta,{className:"h-5 w-5 text-white"}):e.jsx(xn,{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(aa,{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(fn,{className:"h-3 w-3"}),ds(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(mn,{className:"h-3 w-3"}),J(n.start_time),n.end_time?` – ${J(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[m==="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(G,{onClick:()=>f("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(ba,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),m==="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:()=>f("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ga,{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(ye,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Le,{value:_.first_name,onChange:xe=>w(ue=>({...ue,first_name:xe.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Le,{value:_.last_name,onChange:xe=>w(ue=>({...ue,last_name:xe.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Le,{type:"email",value:_.email,onChange:xe=>w(ue=>({...ue,email:xe.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Le,{type:"tel",value:_.phone,onChange:xe=>w(ue=>({...ue,phone:xe.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:S,onChange:xe=>M(xe.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:I?"Yes":"No"}),e.jsx(qr,{checked:I,onCheckedChange:P})]})]}),I&&e.jsx(Le,{value:O,onChange:xe=>q(xe.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),$&&e.jsx("p",{className:"text-destructive text-sm",children:$}),e.jsxs(G,{onClick:Q,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(ba,{className:"h-5 w-5 ml-2"})]})]}),m==="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:()=>f("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Ga,{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:ZCt.map(xe=>e.jsxs("button",{onClick:()=>ce(xe.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:xe.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:xe.label})]},xe.value))}),$&&e.jsx("p",{className:"text-destructive text-sm text-center",children:$})]}),m==="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..."})]}),m==="survey"&&g&&V&&e.jsx(WCt,{questions:V,visitorId:g,onComplete:()=>f("done"),onSkip:()=>f("done")}),m==="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, ",_.first_name,". ",oe?"Enjoy the event!":"Enjoy the open house!"]})]}),(n==null?void 0:n.disclosure_pdf_url)&&e.jsxs("a",{href:`https://docs.google.com/gview?url=${encodeURIComponent(n.disclosure_pdf_url)}&embedded=true`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-800 font-medium text-sm transition-colors",children:[e.jsx(wn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ne==null?void 0:ne.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ne.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function tEs(t){const{user:s}=Fs();return pt({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 sEs(){const t=Qt(),{user:s}=Fs();return Tt({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 rEs(){const t=Qt();return Tt({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 YCt(t){return pt({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 Oje="ScrollArea",[hKe]=od(Oje),[XCt,Kx]=hKe(Oje),mKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=k.useState(null),[u,m]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(null),[N,S]=k.useState(0),[M,I]=k.useState(0),[P,O]=k.useState(!1),[q,$]=k.useState(!1),z=Ka(s,X=>c(X)),V=Dw(a);return e.jsx(XCt,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:m,content:f,onContentChange:g,scrollbarX:y,onScrollbarXChange:_,scrollbarXEnabled:P,onScrollbarXEnabledChange:O,scrollbarY:w,onScrollbarYChange:j,scrollbarYEnabled:q,onScrollbarYEnabledChange:$,onCornerWidthChange:S,onCornerHeightChange:I,children:e.jsx(cn.div,{dir:V,...l,ref:z,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":M+"px",...t.style}})})});mKe.displayName=Oje;var pKe="ScrollAreaViewport",fKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Kx(pKe,r),i=k.useRef(null),c=Ka(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(cn.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})})]})});fKe.displayName=pKe;var G0="ScrollAreaScrollbar",Rje=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Kx(G0,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(JCt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(e5t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(xKe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(Fje,{...n,ref:s}):null});Rje.displayName=G0;var JCt=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Kx(G0,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)},m=()=>{c=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",m),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",m)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(qd,{present:r||o,children:e.jsx(xKe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),e5t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Kx(G0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=gue(()=>c("SCROLL_END"),100),[i,c]=QCt("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,m=o?"scrollLeft":"scrollTop";if(u){let f=u[m];const g=()=>{const y=u[m];f!==y&&(c("SCROLL"),l()),f=y};return u.addEventListener("scroll",g),()=>u.removeEventListener("scroll",g)}},[a.viewport,o,c,l]),e.jsx(qd,{present:r||i!=="hidden",children:e.jsx(Fje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Or(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Or(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),xKe=k.forwardRef((t,s)=>{const r=Kx(G0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=k.useState(!1),i=t.orientation==="horizontal",c=gue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Kx(G0,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=_Ke(i.viewport,i.content),m={...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,y){return i5t(g,l.current,i,y)}return r==="horizontal"?e.jsx(t5t,{...m,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollLeft,y=K6e(g,i,a.dir);o.current.style.transform=`translate3d(${y}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(s5t,{...m,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollTop,y=K6e(g,i);o.current.style.transform=`translate3d(0, ${y}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=f(g))}}):null}),t5t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Kx(G0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=Ka(s,c,o.onScrollbarXChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(yKe,{"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":xue(r)+"px",...t.style},onThumbPointerDown:m=>t.onThumbPointerDown(m.x),onDragScroll:m=>t.onDragScroll(m.x),onWheelScroll:(m,f)=>{if(o.viewport){const g=o.viewport.scrollLeft+m.deltaX;t.onWheelScroll(g),jKe(g,f)&&m.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Hoe(l.paddingLeft),paddingEnd:Hoe(l.paddingRight)}})}})}),s5t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Kx(G0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=Ka(s,c,o.onScrollbarYChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(yKe,{"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":xue(r)+"px",...t.style},onThumbPointerDown:m=>t.onThumbPointerDown(m.y),onDragScroll:m=>t.onDragScroll(m.y),onWheelScroll:(m,f)=>{if(o.viewport){const g=o.viewport.scrollTop+m.deltaY;t.onWheelScroll(g),jKe(g,f)&&m.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Hoe(l.paddingTop),paddingEnd:Hoe(l.paddingBottom)}})}})}),[r5t,gKe]=hKe(G0),yKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:m,onResize:f,...g}=t,y=Kx(G0,r),[_,w]=k.useState(null),j=Ka(s,z=>w(z)),N=k.useRef(null),S=k.useRef(""),M=y.viewport,I=n.content-n.viewport,P=_d(m),O=_d(c),q=gue(f,10);function $(z){if(N.current){const V=z.clientX-N.current.left,X=z.clientY-N.current.top;u({x:V,y:X})}}return k.useEffect(()=>{const z=V=>{const X=V.target;(_==null?void 0:_.contains(X))&&P(V,I)};return document.addEventListener("wheel",z,{passive:!1}),()=>document.removeEventListener("wheel",z,{passive:!1})},[M,_,I,P]),k.useEffect(O,[n,O]),nA(_,q),nA(y.content,q),e.jsx(r5t,{scope:r,scrollbar:_,hasThumb:a,onThumbChange:_d(o),onThumbPointerUp:_d(l),onThumbPositionChange:O,onThumbPointerDown:_d(i),children:e.jsx(cn.div,{...g,ref:j,style:{position:"absolute",...g.style},onPointerDown:Or(t.onPointerDown,z=>{z.button===0&&(z.target.setPointerCapture(z.pointerId),N.current=_.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",y.viewport&&(y.viewport.style.scrollBehavior="auto"),$(z))}),onPointerMove:Or(t.onPointerMove,$),onPointerUp:Or(t.onPointerUp,z=>{const V=z.target;V.hasPointerCapture(z.pointerId)&&V.releasePointerCapture(z.pointerId),document.body.style.webkitUserSelect=S.current,y.viewport&&(y.viewport.style.scrollBehavior=""),N.current=null})})})}),Voe="ScrollAreaThumb",vKe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=gKe(Voe,t.__scopeScrollArea);return e.jsx(qd,{present:r||a.hasThumb,children:e.jsx(n5t,{ref:s,...n})})}),n5t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Kx(Voe,r),l=gKe(Voe,r),{onThumbPositionChange:i}=l,c=Ka(s,f=>l.onThumbChange(f)),u=k.useRef(void 0),m=gue(()=>{u.current&&(u.current(),u.current=void 0)},100);return k.useEffect(()=>{const f=o.viewport;if(f){const g=()=>{if(m(),!u.current){const y=o5t(f,i);u.current=y,i()}};return i(),f.addEventListener("scroll",g),()=>f.removeEventListener("scroll",g)}},[o.viewport,m,i]),e.jsx(cn.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:Or(t.onPointerDownCapture,f=>{const y=f.target.getBoundingClientRect(),_=f.clientX-y.left,w=f.clientY-y.top;l.onThumbPointerDown({x:_,y:w})}),onPointerUp:Or(t.onPointerUp,l.onThumbPointerUp)})});vKe.displayName=Voe;var zje="ScrollAreaCorner",bKe=k.forwardRef((t,s)=>{const r=Kx(zje,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(a5t,{...t,ref:s}):null});bKe.displayName=zje;var a5t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Kx(zje,r),[o,l]=k.useState(0),[i,c]=k.useState(0),u=!!(o&&i);return nA(a.scrollbarX,()=>{var f;const m=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(m),c(m)}),nA(a.scrollbarY,()=>{var f;const m=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(m),l(m)}),u?e.jsx(cn.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 Hoe(t){return t?parseInt(t,10):0}function _Ke(t,s){const r=t/s;return isNaN(r)?0:r}function xue(t){const s=_Ke(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function i5t(t,s,r,n="ltr"){const a=xue(r),o=a/2,l=s||o,i=a-l,c=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,m=r.content-r.viewport,f=n==="ltr"?[0,m]:[m*-1,0];return wKe([c,u],f)(t)}function K6e(t,s,r="ltr"){const n=xue(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=xD(t,c);return wKe([0,l],[0,i])(u)}function wKe(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 jKe(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 gue(t,s){const r=_d(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 nA(t,s){const r=_d(s);kd(()=>{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 NKe=mKe,l5t=fKe,c5t=bKe;const Li=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(NKe,{ref:n,className:Pt("relative overflow-hidden",t),...r,children:[e.jsx(l5t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(yue,{}),e.jsx(c5t,{})]}));Li.displayName=NKe.displayName;const yue=k.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(Rje,{ref:n,orientation:s,className:Pt("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(vKe,{className:"relative flex-1 rounded-full bg-border"})}));yue.displayName=Rje.displayName;const Bje=k.createContext({});function $je(t){const s=k.useRef(null);return s.current===null&&(s.current=t()),s.current}const d5t=typeof window<"u",kKe=d5t?k.useLayoutEffect:k.useEffect,vue=k.createContext(null);function qje(t,s){t.indexOf(s)===-1&&t.push(s)}function Goe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const O0=(t,s,r)=>r>s?s:r{};const ww={},SKe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function CKe(t){return typeof t=="object"&&t!==null}const MKe=t=>/^0[^.\s]+$/u.test(t);function TKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const Dx=t=>t,u5t=(t,s)=>r=>s(t(r)),XO=(...t)=>t.reduce(u5t),vD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class Vje{constructor(){this.subscriptions=[]}add(s){return qje(this.subscriptions,s),()=>Goe(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,Sx=t=>t/1e3;function AKe(t,s){return s?t*(1e3/s):0}const EKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,h5t=1e-7,m5t=12;function p5t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=EKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>h5t&&++ip5t(o,0,1,t,r);return o=>o===0||o===1?o:EKe(a(o),s,n)}const PKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,IKe=t=>s=>1-t(1-s),LKe=JO(.33,1.53,.69,.99),Hje=IKe(LKe),DKe=PKe(Hje),OKe=t=>t>=1?1:(t*=2)<1?.5*Hje(t):.5*(2-Math.pow(2,-10*(t-1))),Gje=t=>1-Math.sin(Math.acos(t)),RKe=IKe(Gje),FKe=PKe(Gje),f5t=JO(.42,0,1,1),x5t=JO(0,0,.58,1),zKe=JO(.42,0,.58,1),g5t=t=>Array.isArray(t)&&typeof t[0]!="number",BKe=t=>Array.isArray(t)&&typeof t[0]=="number",y5t={linear:Dx,easeIn:f5t,easeInOut:zKe,easeOut:x5t,circIn:Gje,circInOut:FKe,circOut:RKe,backIn:Hje,backInOut:DKe,backOut:LKe,anticipate:OKe},v5t=t=>typeof t=="string",Z6e=t=>{if(BKe(t)){Uje(t.length===4);const[s,r,n,a]=t;return JO(s,r,n,a)}else if(v5t(t))return y5t[t];return t},_z=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function b5t(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(m){l.has(m)&&(u.schedule(m),t()),m(i)}const u={schedule:(m,f=!1,g=!1)=>{const _=g&&a?r:n;return f&&l.add(m),_.add(m),m},cancel:m=>{n.delete(m),l.delete(m)},process:m=>{if(i=m,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(m))}};return u}const _5t=40;function $Ke(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=_z.reduce((M,I)=>(M[I]=b5t(o),M),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:m,update:f,preRender:g,render:y,postRender:_}=l,w=()=>{const M=ww.useManualTiming,I=M?a.timestamp:performance.now();r=!1,M||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,_5t),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),m.process(a),f.process(a),g.process(a),y.process(a),_.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},j=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:_z.reduce((M,I)=>{const P=l[I];return M[I]=(O,q=!1,$=!1)=>(r||j(),P.schedule(O,q,$)),M},{}),cancel:M=>{for(let I=0;I<_z.length;I++)l[_z[I]].cancel(M)},state:a,steps:l}}const{schedule:Rl,cancel:jw,state:wh,steps:Hxe}=$Ke(typeof requestAnimationFrame<"u"?requestAnimationFrame:Dx,!0);let Sie;function w5t(){Sie=void 0}const Tm={now:()=>(Sie===void 0&&Tm.set(wh.isProcessing||ww.useManualTiming?wh.timestamp:performance.now()),Sie),set:t=>{Sie=t,queueMicrotask(w5t)}},qKe=t=>s=>typeof s=="string"&&s.startsWith(t),UKe=qKe("--"),j5t=qKe("var(--"),Wje=t=>j5t(t)?N5t.test(t.split("/*")[0].trim()):!1,N5t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Y6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const mE={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},bD={...mE,transform:t=>O0(0,1,t)},wz={...mE,default:1},d8=t=>Math.round(t*1e5)/1e5,Kje=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function k5t(t){return t==null}const S5t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Zje=(t,s)=>r=>!!(typeof r=="string"&&S5t.test(r)&&r.startsWith(t)||s&&!k5t(r)&&Object.prototype.hasOwnProperty.call(r,s)),VKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Kje);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},C5t=t=>O0(0,255,t),Gxe={...mE,transform:t=>Math.round(C5t(t))},k4={test:Zje("rgb","red"),parse:VKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Gxe.transform(t)+", "+Gxe.transform(s)+", "+Gxe.transform(r)+", "+d8(bD.transform(n))+")"};function M5t(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 r1e={test:Zje("#"),parse:M5t,transform:k4.transform},eR=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Zb=eR("deg"),A0=eR("%"),ha=eR("px"),T5t=eR("vh"),A5t=eR("vw"),Q6e={...A0,parse:t=>A0.parse(t)/100,transform:t=>A0.transform(t*100)},_M={test:Zje("hsl","hue"),parse:VKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+A0.transform(d8(s))+", "+A0.transform(d8(r))+", "+d8(bD.transform(n))+")"},eu={test:t=>k4.test(t)||r1e.test(t)||_M.test(t),parse:t=>k4.test(t)?k4.parse(t):_M.test(t)?_M.parse(t):r1e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?k4.transform(t):_M.transform(t),getAnimatableNone:t=>{const s=eu.parse(t);return s.alpha=0,eu.transform(s)}},E5t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function P5t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(Kje))==null?void 0:s.length)||0)+(((r=t.match(E5t))==null?void 0:r.length)||0)>0}const HKe="number",GKe="color",I5t="var",L5t="var(",X6e="${}",D5t=/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 aA(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(D5t,c=>(eu.test(c)?(n.color.push(o),a.push(GKe),r.push(eu.parse(c))):c.startsWith(L5t)?(n.var.push(o),a.push(I5t),r.push(c)):(n.number.push(o),a.push(HKe),r.push(parseFloat(c))),++o,X6e)).split(X6e);return{values:r,split:i,indexes:n,types:a}}function O5t(t){return aA(t).values}function WKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:eu.test(t)?eu.getAnimatableNone(t):t,z5t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:F5t(t);function B5t(t){const s=aA(t);return WKe(s)(s.values.map((n,a)=>z5t(n,s.split[a])))}const ny={test:P5t,parse:O5t,createTransformer:R5t,getAnimatableNone:B5t};function Wxe(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 $5t({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=Wxe(c,i,t+1/3),o=Wxe(c,i,t),l=Wxe(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Woe(t,s){return r=>r>0?s:t}const Cc=(t,s,r)=>t+(s-t)*r,Kxe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},q5t=[r1e,k4,_M],U5t=t=>q5t.find(s=>s.test(t));function J6e(t){const s=U5t(t);if(!s)return!1;let r=s.parse(t);return s===_M&&(r=$5t(r)),r}const ePe=(t,s)=>{const r=J6e(t),n=J6e(s);if(!r||!n)return Woe(t,s);const a={...r};return o=>(a.red=Kxe(r.red,n.red,o),a.green=Kxe(r.green,n.green,o),a.blue=Kxe(r.blue,n.blue,o),a.alpha=Cc(r.alpha,n.alpha,o),k4.transform(a))},n1e=new Set(["none","hidden"]);function V5t(t,s){return n1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function H5t(t,s){return r=>Cc(t,s,r)}function Yje(t){return typeof t=="number"?H5t:typeof t=="string"?Wje(t)?Woe:eu.test(t)?ePe:K5t:Array.isArray(t)?KKe:typeof t=="object"?eu.test(t)?ePe:G5t:Woe}function KKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>Yje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function W5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=ny.createTransformer(s),n=aA(t),a=aA(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?n1e.has(t)&&!a.values.length||n1e.has(s)&&!n.values.length?V5t(t,s):XO(KKe(W5t(n,a),a.values),r):Woe(t,s)};function ZKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?Cc(t,s,r):Yje(t)(t,s)}const Z5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Rl.update(s,r),stop:()=>jw(s),now:()=>wh.isProcessing?wh.timestamp:Tm.now()}},YKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Koe?1/0:s}function Y5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(Qje(n),Koe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:Sx(a)}}const pd={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 a1e(t,s){return t*Math.sqrt(1-s*s)}const Q5t=12;function X5t(t,s,r){let n=r;for(let a=1;a{const m=u*l,f=m*t,g=m-r,y=a1e(u,l),_=Math.exp(-f);return Zxe-g/y*_},o=u=>{const f=u*l*t,g=f*r+r,y=Math.pow(l,2)*Math.pow(u,2)*t,_=Math.exp(-f),w=a1e(Math.pow(u,2),l);return(-a(u)+Zxe>0?-1:1)*((g-y)*_)/w}):(a=u=>{const m=Math.exp(-u*t),f=(u-r)*t+1;return-Zxe+m*f},o=u=>{const m=Math.exp(-u*t),f=(r-u)*(t*t);return m*f});const i=5/t,c=X5t(a,o,i);if(t=vf(t),isNaN(c))return{stiffness:pd.stiffness,damping:pd.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const eMt=["duration","bounce"],tMt=["stiffness","damping","mass"];function tPe(t,s){return s.some(r=>t[r]!==void 0)}function sMt(t){let s={velocity:pd.velocity,stiffness:pd.stiffness,damping:pd.damping,mass:pd.mass,isResolvedFromDuration:!1,...t};if(!tPe(t,tMt)&&tPe(t,eMt))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*O0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:pd.mass,stiffness:a,damping:o}}else{const r=J5t({...t,velocity:0});s={...s,...r,mass:pd.mass},s.isResolvedFromDuration=!0}return s}function Zoe(t=pd.visualDuration,s=pd.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:m,duration:f,velocity:g,isResolvedFromDuration:y}=sMt({...r,velocity:-Sx(r.velocity||0)}),_=g||0,w=u/(2*Math.sqrt(c*m)),j=l-o,N=Sx(Math.sqrt(c/m)),S=Math.abs(j)<5;n||(n=S?pd.restSpeed.granular:pd.restSpeed.default),a||(a=S?pd.restDelta.granular:pd.restDelta.default);let M,I,P,O,q,$;if(w<1)P=a1e(N,w),O=(_+w*N*j)/P,M=V=>{const X=Math.exp(-w*N*V);return l-X*(O*Math.sin(P*V)+j*Math.cos(P*V))},q=w*N*O+j*P,$=w*N*j-O*P,I=V=>Math.exp(-w*N*V)*(q*Math.sin(P*V)+$*Math.cos(P*V));else if(w===1){M=X=>l-Math.exp(-N*X)*(j+(_+N*j)*X);const V=_+N*j;I=X=>Math.exp(-N*X)*(N*V*X-_)}else{const V=N*Math.sqrt(w*w-1);M=Q=>{const ce=Math.exp(-w*N*Q),ne=Math.min(V*Q,300);return l-ce*((_+w*N*j)*Math.sinh(ne)+V*j*Math.cosh(ne))/V};const X=(_+w*N*j)/V,Y=w*N*X-j*V,J=w*N*j-X*V;I=Q=>{const ce=Math.exp(-w*N*Q),ne=Math.min(V*Q,300);return ce*(Y*Math.sinh(ne)+J*Math.cosh(ne))}}const z={calculatedDuration:y&&f||null,velocity:V=>vf(I(V)),next:V=>{if(!y&&w<1){const Y=Math.exp(-w*N*V),J=Math.sin(P*V),Q=Math.cos(P*V),ce=l-Y*(O*J+j*Q),ne=vf(Y*(q*J+$*Q));return i.done=Math.abs(ne)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const X=M(V);if(y)i.done=V>=f;else{const Y=vf(I(V));i.done=Math.abs(Y)<=n&&Math.abs(l-X)<=a}return i.value=i.done?l:X,i},toString:()=>{const V=Math.min(Qje(z),Koe),X=YKe(Y=>z.next(V*Y).value,V,30);return V+"ms "+X},toTransition:()=>{}};return z}Zoe.applyToOptions=t=>{const s=Y5t(t,100,Zoe);return t.ease=s.ease,t.duration=vf(s.duration),t.type="keyframes",t};const rMt=5;function QKe(t,s,r){const n=Math.max(s-rMt,0);return AKe(r-t(n),s-n)}function i1e({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:m}){const f=t[0],g={done:!1,value:f},y=$=>i!==void 0&&$c,_=$=>i===void 0?c:c===void 0||Math.abs(i-$)-w*Math.exp(-$/n),M=$=>N+S($),I=$=>{const z=S($),V=M($);g.done=Math.abs(z)<=u,g.value=g.done?N:V};let P,O;const q=$=>{y(g.value)&&(P=$,O=Zoe({keyframes:[g.value,_(g.value)],velocity:QKe(M,$,g.value),damping:a,stiffness:o,restDelta:u,restSpeed:m}))};return q(0),{calculatedDuration:null,next:$=>{let z=!1;return!O&&P===void 0&&(z=!0,I($),q($)),P!==void 0&&$>=P?O.next($-P):(!z&&I($),g)}}}function nMt(t,s,r){const n=[],a=r||ww.mix||ZKe,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=nMt(s,n,a),c=i.length,u=m=>{if(l&&m1)for(;fu(O0(t[0],t[o-1],m)):u}function iMt(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=vD(0,s,n);t.push(Cc(r,1,a))}}function oMt(t){const s=[0];return iMt(s,t.length-1),s}function lMt(t,s){return t.map(r=>r*s)}function cMt(t,s){return t.map(()=>s||zKe).splice(0,t.length-1)}function u8({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=g5t(n)?n.map(Z6e):Z6e(n),o={done:!1,value:s[0]},l=lMt(r&&r.length===s.length?r:oMt(s),t),i=aMt(l,s,{ease:Array.isArray(a)?a:cMt(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const dMt=t=>t!==null;function bue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(dMt),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const uMt={decay:i1e,inertia:i1e,tween:u8,keyframes:u8,spring:Zoe};function XKe(t){typeof t.type=="string"&&(t.type=uMt[t.type])}class Xje{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 hMt=t=>t/100;class Yoe extends Xje{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!==Tm.now()&&this.tick(Tm.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;XKe(s);const{type:r=u8,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||u8;c!==u8&&typeof i[0]!="number"&&(this.mixKeyframes=XO(hMt,ZKe(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=Qje(u));const{calculatedDuration:m}=u;this.calculatedDuration=m,this.resolvedDuration=m+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:m,repeat:f,repeatType:g,repeatDelay:y,type:_,onUpdate:w,finalKeyframe:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const 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,I=n;if(f){const $=Math.min(this.currentTime,a)/i;let z=Math.floor($),V=$%1;!V&&$>=1&&(V=1),V===1&&z--,z=Math.min(z,f+1),!!(z%2)&&(g==="reverse"?(V=1-V,y&&(V-=y/i)):g==="mirror"&&(I=l)),M=O0(0,1,V)*i}let P;S?(this.delayState.value=m[0],P=this.delayState):P=I.next(M),o&&!S&&(P.value=o(P.value));let{done:O}=P;!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&&_!==i1e&&(P.value=bue(m,this.options,j,this.speed)),w&&w(P.value),q&&this.finish(),P}then(s,r){return this.finished.then(s,r)}get duration(){return Sx(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+Sx(s)}get time(){return Sx(this.currentTime)}set time(s){s=vf(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 QKe(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(Tm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=Sx(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=Z5t,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(Tm.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 mMt(t){for(let s=1;st*180/Math.PI,o1e=t=>{const s=S4(Math.atan2(t[1],t[0]));return l1e(s)},pMt={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:o1e,rotateZ:o1e,skewX:t=>S4(Math.atan(t[1])),skewY:t=>S4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},l1e=t=>(t=t%360,t<0&&(t+=360),t),sPe=o1e,rPe=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),nPe=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),fMt={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:rPe,scaleY:nPe,scale:t=>(rPe(t)+nPe(t))/2,rotateX:t=>l1e(S4(Math.atan2(t[6],t[5]))),rotateY:t=>l1e(S4(Math.atan2(-t[2],t[0]))),rotateZ:sPe,rotate:sPe,skewX:t=>S4(Math.atan(t[4])),skewY:t=>S4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function c1e(t){return t.includes("scale")?1:0}function d1e(t,s){if(!t||t==="none")return c1e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=fMt,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=pMt,a=i}if(!a)return c1e(s);const o=n[s],l=a[1].split(",").map(gMt);return typeof o=="function"?o(l):l[o]}const xMt=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return d1e(r,s)};function gMt(t){return parseFloat(t.trim())}const pE=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],fE=new Set(pE),aPe=t=>t===mE||t===ha,yMt=new Set(["x","y","z"]),vMt=pE.filter(t=>!yMt.has(t));function bMt(t){const s=[];return vMt.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const I_={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})=>d1e(s,"x"),y:(t,{transform:s})=>d1e(s,"y")};I_.translateX=I_.x;I_.translateY=I_.y;const AS=new Set;let u1e=!1,h1e=!1,m1e=!1;function JKe(){if(h1e){const t=Array.from(AS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=bMt(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)})}h1e=!1,u1e=!1,AS.forEach(t=>t.complete(m1e)),AS.clear()}function eZe(){AS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(h1e=!0)})}function _Mt(){m1e=!0,eZe(),JKe(),m1e=!1}class Jje{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?(AS.add(this),u1e||(u1e=!0,Rl.read(eZe),Rl.resolveKeyframes(JKe))):(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])}mMt(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),AS.delete(this)}cancel(){this.state==="scheduled"&&(AS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const wMt=t=>t.startsWith("--");function tZe(t,s,r){wMt(s)?t.style.setProperty(s,r):t.style[s]=r}const jMt={};function sZe(t,s){const r=TKe(t);return()=>jMt[s]??r()}const NMt=sZe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),rZe=sZe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),UI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,iPe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:UI([0,.65,.55,1]),circOut:UI([.55,0,1,.45]),backIn:UI([.31,.01,.66,-.59]),backOut:UI([.33,1.53,.69,.99])};function nZe(t,s){if(t)return typeof t=="function"?rZe()?YKe(t,s):"ease-out":BKe(t)?UI(t):Array.isArray(t)?t.map(r=>nZe(r,s)||iPe.easeOut):iPe[t]}function kMt(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:c}={},u=void 0){const m={[s]:r};c&&(m.offset=c);const f=nZe(i,a);Array.isArray(f)&&(m.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(m,g)}function aZe(t){return typeof t=="function"&&"applyToOptions"in t}function SMt({type:t,...s}){return aZe(t)&&rZe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class iZe extends Xje{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,Uje(typeof s.type!="string");const u=SMt(s);this.animation=kMt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=bue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(m),tZe(r,n,m),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 Sx(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+Sx(s)}get time(){return Sx(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=vf(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&&NMt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Dx):a(this)}}const oZe={anticipate:OKe,backInOut:DKe,circInOut:FKe};function CMt(t){return t in oZe}function MMt(t){typeof t.ease=="string"&&CMt(t.ease)&&(t.ease=oZe[t.ease])}const Yxe=10;class TMt extends iZe{constructor(s){MMt(s),XKe(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 Yoe({...l,autoplay:!1}),c=Math.max(Yxe,Tm.now()-this.startTime),u=O0(0,Yxe,c-Yxe),m=i.sample(c).value,{name:f}=this.options;o&&f&&tZe(o,f,m),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,m,u),i.stop()}}const oPe=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ny.test(t)||t==="0")&&!t.startsWith("url("));function AMt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function OMt(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:m}=s.owner.getProps();return DMt()&&r&&(lZe.has(r)||LMt.has(r)&&IMt(i))&&(r!=="transform"||!m)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const RMt=40;class FMt extends Xje{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:m,...f}){var _;super(),this.stop=()=>{var w,j;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(j=this.keyframeResolver)==null||j.cancel()},this.createdAt=Tm.now();const g={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:m,...f},y=(m==null?void 0:m.KeyframeResolver)||Jje;this.keyframeResolver=new y(i,(w,j,N)=>this.onKeyframesResolved(w,j,g,!N),c,u,m),(_=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:m}=n;this.resolvedAt=Tm.now();let f=!0;EMt(s,o,l,i)||(f=!1,(ww.instantAnimations||!c)&&(m==null||m(bue(s,n,r))),s[0]=s[s.length-1],p1e(n),n.repeat=0);const y={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>RMt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=f&&!u&&OMt(y),w=(S=(N=y.motionValue)==null?void 0:N.owner)==null?void 0:S.current;let j;if(_)try{j=new TMt({...y,element:w})}catch{j=new Yoe(y)}else j=new Yoe(y);j.finished.then(()=>{this.notifyFinished()}).catch(Dx),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),_Mt()),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 cZe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,m)=>u.sortNodePosition(m)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const zMt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function BMt(t){const s=zMt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function dZe(t,s,r=1){const[n,a]=BMt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return SKe(l)?parseFloat(l):l}return Wje(a)?dZe(a,s,r+1):a}const $Mt={type:"spring",stiffness:500,damping:25,restSpeed:10},qMt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),UMt={type:"keyframes",duration:.8},VMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},HMt=(t,{keyframes:s})=>s.length>2?UMt:fE.has(t)?t.startsWith("scale")?qMt(s[1]):$Mt:VMt;function uZe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function eNe(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?uZe(r,t):r}const GMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function WMt(t){for(const s in t)if(!GMt.has(s))return!0;return!1}const tNe=(t,s,r,n={},a,o)=>l=>{const i=eNe(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-vf(c);const m={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};WMt(i)||Object.assign(m,HMt(t,m)),m.duration&&(m.duration=vf(m.duration)),m.repeatDelay&&(m.repeatDelay=vf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let f=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(p1e(m),m.delay===0&&(f=!0)),(ww.instantAnimations||ww.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,p1e(m),m.delay=0),m.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const g=bue(m.keyframes,i);if(g!==void 0){Rl.update(()=>{m.onUpdate(g),m.onComplete()});return}}return i.isSync?new Yoe(m):new FMt(m)};function lPe(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function sNe(t,s,r,n){if(typeof s=="function"){const[a,o]=lPe(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]=lPe(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function ES(t,s,r){const n=t.getProps();return sNe(n,s,r!==void 0?r:n.custom,t)}const hZe=new Set(["width","height","top","left","right","bottom",...pE]),cPe=30,KMt=t=>!isNaN(parseFloat(t));class ZMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=Tm.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=Tm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=KMt(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 Vje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Rl.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=Tm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>cPe)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,cPe);return AKe(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 iA(t,s){return new ZMt(t,s)}const f1e=t=>Array.isArray(t);function YMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,iA(r))}function QMt(t){return f1e(t)?t[t.length-1]||0:t}function XMt(t,s){const r=ES(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=QMt(o[l]);YMt(t,l,i)}}const Sh=t=>!!(t&&t.getVelocity);function JMt(t){return!!(Sh(t)&&t.add)}function x1e(t,s){const r=t.getValue("willChange");if(JMt(r))return r.add(s);if(!r&&ww.WillChange){const n=new ww.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function rNe(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const eTt="framerAppearId",mZe="data-"+rNe(eTt);function pZe(t){return t.props[mZe]}function tTt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function fZe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?uZe(o,c):c;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const m=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const g in i){const y=t.getValue(g,t.latestValues[g]??null),_=i[g];if(_===void 0||f&&tTt(f,g))continue;const w={delay:r,...eNe(o||{},g)},j=y.get();if(j!==void 0&&!y.isAnimating()&&!Array.isArray(_)&&_===j&&!w.velocity){Rl.update(()=>y.set(_));continue}let N=!1;if(window.MotionHandoffAnimation){const I=pZe(t);if(I){const P=window.MotionHandoffAnimation(I,g,Rl);P!==null&&(w.startTime=P,N=!0)}}x1e(t,g);const S=u??t.shouldReduceMotion;y.start(tNe(g,y,_,S&&hZe.has(g)?{type:!1}:w,t,N));const M=y.animation;M&&m.push(M)}if(l){const g=()=>Rl.update(()=>{l&&XMt(t,l)});m.length?Promise.all(m).then(g):g()}return m}function g1e(t,s,r={}){var c;const n=ES(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(fZe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:m=0,staggerChildren:f,staggerDirection:g}=a;return sTt(t,s,u,m,f,g,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,m]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>m())}else return Promise.all([o(),l(r.delay)])}function sTt(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(g1e(c,s,{...l,delay:r+(typeof n=="function"?0:n)+cZe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function rTt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>g1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=g1e(t,s,r);else{const a=typeof s=="function"?ES(t,s,r.custom):s;n=Promise.all(fZe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const nTt={test:t=>t==="auto",parse:t=>t},xZe=t=>s=>s.test(t),gZe=[mE,ha,A0,Zb,A5t,T5t,nTt],dPe=t=>gZe.find(xZe(t));function aTt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||MKe(t):!0}const iTt=new Set(["brightness","contrast","saturate","opacity"]);function oTt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(Kje)||[];if(!n)return t;const a=r.replace(n,"");let o=iTt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const lTt=/\b([a-z-]*)\(.*?\)/gu,y1e={...ny,getAnimatableNone:t=>{const s=t.match(lTt);return s?s.map(oTt).join(" "):t}},v1e={...ny,getAnimatableNone:t=>{const s=ny.parse(t);return ny.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},uPe={...mE,transform:Math.round},cTt={rotate:Zb,rotateX:Zb,rotateY:Zb,rotateZ:Zb,scale:wz,scaleX:wz,scaleY:wz,scaleZ:wz,skew:Zb,skewX:Zb,skewY:Zb,distance:ha,translateX:ha,translateY:ha,translateZ:ha,x:ha,y:ha,z:ha,perspective:ha,transformPerspective:ha,opacity:bD,originX:Q6e,originY:Q6e,originZ:ha},nNe={borderWidth:ha,borderTopWidth:ha,borderRightWidth:ha,borderBottomWidth:ha,borderLeftWidth:ha,borderRadius:ha,borderTopLeftRadius:ha,borderTopRightRadius:ha,borderBottomRightRadius:ha,borderBottomLeftRadius:ha,width:ha,maxWidth:ha,height:ha,maxHeight:ha,top:ha,right:ha,bottom:ha,left:ha,inset:ha,insetBlock:ha,insetBlockStart:ha,insetBlockEnd:ha,insetInline:ha,insetInlineStart:ha,insetInlineEnd:ha,padding:ha,paddingTop:ha,paddingRight:ha,paddingBottom:ha,paddingLeft:ha,paddingBlock:ha,paddingBlockStart:ha,paddingBlockEnd:ha,paddingInline:ha,paddingInlineStart:ha,paddingInlineEnd:ha,margin:ha,marginTop:ha,marginRight:ha,marginBottom:ha,marginLeft:ha,marginBlock:ha,marginBlockStart:ha,marginBlockEnd:ha,marginInline:ha,marginInlineStart:ha,marginInlineEnd:ha,fontSize:ha,backgroundPositionX:ha,backgroundPositionY:ha,...cTt,zIndex:uPe,fillOpacity:bD,strokeOpacity:bD,numOctaves:uPe},dTt={...nNe,color:eu,backgroundColor:eu,outlineColor:eu,fill:eu,stroke:eu,borderColor:eu,borderTopColor:eu,borderRightColor:eu,borderBottomColor:eu,borderLeftColor:eu,filter:y1e,WebkitFilter:y1e,mask:v1e,WebkitMask:v1e},yZe=t=>dTt[t],uTt=new Set([y1e,v1e]);function vZe(t,s){let r=yZe(t);return uTt.has(r)||(r=ny),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const hTt=new Set(["auto","none","0"]);function mTt(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function aNe(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 bZe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Cie(t){return CKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:iNe}=$Ke(queueMicrotask,!1),Lg={x:!1,y:!1};function _Ze(){return Lg.x||Lg.y}function fTt(t){return t==="x"||t==="y"?Lg[t]?null:(Lg[t]=!0,()=>{Lg[t]=!1}):Lg.x||Lg.y?null:(Lg.x=Lg.y=!0,()=>{Lg.x=Lg.y=!1})}function wZe(t,s){const r=aNe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function xTt(t){return!(t.pointerType==="touch"||_Ze())}function gTt(t,s,r={}){const[n,a,o]=wZe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const m=()=>{l.removeEventListener("pointerleave",_)},f=j=>{u&&(u(j),u=void 0),m()},g=j=>{i=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),c&&(c=!1,f(j))},y=()=>{i=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},_=j=>{if(j.pointerType!=="touch"){if(i){c=!0;return}f(j)}},w=j=>{if(!xTt(j))return;c=!1;const N=s(l,j);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",_,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",y,a)}),o}const jZe=(t,s)=>s?t===s?!0:jZe(t,s.parentElement):!1,oNe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,yTt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function vTt(t){return yTt.has(t.tagName)||t.isContentEditable===!0}const bTt=new Set(["INPUT","SELECT","TEXTAREA"]);function _Tt(t){return bTt.has(t.tagName)||t.isContentEditable===!0}const Mie=new WeakSet;function hPe(t){return s=>{s.key==="Enter"&&t(s)}}function Qxe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const wTt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=hPe(()=>{if(Mie.has(r))return;Qxe(r,"down");const a=hPe(()=>{Qxe(r,"up")}),o=()=>Qxe(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 mPe(t){return oNe(t)&&!_Ze()}const pPe=new WeakSet;function jTt(t,s,r={}){const[n,a,o]=wZe(t,r),l=i=>{const c=i.currentTarget;if(!mPe(i)||pPe.has(i))return;Mie.add(c),r.stopPropagation&&pPe.add(i);const u=s(c,i),m=(y,_)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),Mie.has(c)&&Mie.delete(c),mPe(y)&&typeof u=="function"&&u(y,{success:_})},f=y=>{m(y,c===window||c===document||r.useGlobalTarget||jZe(c,y.target))},g=y=>{m(y,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",g,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Cie(i)&&(i.addEventListener("focus",u=>wTt(u,a)),!vTt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function lNe(t){return CKe(t)&&"ownerSVGElement"in t}const Tie=new WeakMap;let Yb;const NZe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:lNe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],NTt=NZe("inline","width","offsetWidth"),kTt=NZe("block","height","offsetHeight");function STt({target:t,borderBoxSize:s}){var r;(r=Tie.get(t))==null||r.forEach(n=>{n(t,{get width(){return NTt(t,s)},get height(){return kTt(t,s)}})})}function CTt(t){t.forEach(STt)}function MTt(){typeof ResizeObserver>"u"||(Yb=new ResizeObserver(CTt))}function TTt(t,s){Yb||MTt();const r=aNe(t);return r.forEach(n=>{let a=Tie.get(n);a||(a=new Set,Tie.set(n,a)),a.add(s),Yb==null||Yb.observe(n)}),()=>{r.forEach(n=>{const a=Tie.get(n);a==null||a.delete(s),a!=null&&a.size||Yb==null||Yb.unobserve(n)})}}const Aie=new Set;let wM;function ATt(){wM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Aie.forEach(s=>s(t))},window.addEventListener("resize",wM)}function ETt(t){return Aie.add(t),wM||ATt(),()=>{Aie.delete(t),!Aie.size&&typeof wM=="function"&&(window.removeEventListener("resize",wM),wM=void 0)}}function fPe(t,s){return typeof t=="function"?ETt(t):TTt(t,s)}function PTt(t){return lNe(t)&&t.tagName==="svg"}const ITt=[...gZe,eu,ny],LTt=t=>ITt.find(xZe(t)),xPe=()=>({translate:0,scale:1,origin:0,originPoint:0}),jM=()=>({x:xPe(),y:xPe()}),gPe=()=>({min:0,max:0}),vu=()=>({x:gPe(),y:gPe()}),DTt=new WeakMap;function _ue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function _D(t){return typeof t=="string"||Array.isArray(t)}const cNe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],dNe=["initial",...cNe];function wue(t){return _ue(t.animate)||dNe.some(s=>_D(t[s]))}function kZe(t){return!!(wue(t)||t.variants)}function OTt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Sh(a))t.addValue(n,a);else if(Sh(o))t.addValue(n,iA(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,iA(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const b1e={current:null},SZe={current:!1},RTt=typeof window<"u";function FTt(){if(SZe.current=!0,!!RTt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>b1e.current=t.matches;t.addEventListener("change",s),s()}else b1e.current=!1}const yPe=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Qoe={};function CZe(t){Qoe=t}function zTt(){return Qoe}class BTt{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=Jje,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 y=Tm.now();this.renderScheduledAtthis.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(SZe.current||FTt(),this.shouldReduceMotion=b1e.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(),jw(this.notifyUpdate),jw(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&&lZe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:m}=r.accelerate,f=new iZe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:vf(m)}),g=l(f);this.valueSubscriptions.set(s,()=>{g(),f.cancel()});return}const n=fE.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Rl.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 Qoe){const r=Qoe[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):vu()}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=iA(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"&&(SKe(n)||MKe(n))?n=parseFloat(n):!LTt(n)&&ny.test(r)&&(n=vZe(s,r)),this.setBaseTarget(s,Sh(n)?n.get():n)),Sh(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=sNe(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&&!Sh(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 Vje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){iNe.render(this.render)}}class MZe extends BTt{constructor(){super(...arguments),this.KeyframeResolver=pTt}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;Sh(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Bw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function TZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function $Tt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function qTt(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 Xxe(t){return t===void 0||t===1}function _1e({scale:t,scaleX:s,scaleY:r}){return!Xxe(t)||!Xxe(s)||!Xxe(r)}function d4(t){return _1e(t)||AZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function AZe(t){return vPe(t.x)||vPe(t.y)}function vPe(t){return t&&t!=="0%"}function Xoe(t,s,r){const n=t-r,a=s*n;return r+a}function bPe(t,s,r,n,a){return a!==void 0&&(t=Xoe(t,a,n)),Xoe(t,r,n)+s}function w1e(t,s=0,r=1,n,a){t.min=bPe(t.min,s,r,n,a),t.max=bPe(t.max,s,r,n,a)}function EZe(t,{x:s,y:r}){w1e(t.x,s.translate,s.scale,s.originPoint),w1e(t.y,r.translate,r.scale,r.originPoint)}const _Pe=.999999999999,wPe=1.0000000000001;function UTt(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;c_Pe&&(s.x=1),s.y_Pe&&(s.y=1)}function n0(t,s){t.min+=s,t.max+=s}function jPe(t,s,r,n,a=.5){const o=Cc(t.min,t.max,a);w1e(t,s,r,o,n)}function NPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Eie(t,s,r){const n=r??t;jPe(t.x,NPe(s.x,n.x),s.scaleX,s.scale,s.originX),jPe(t.y,NPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function PZe(t,s){return TZe(qTt(t.getBoundingClientRect(),s))}function VTt(t,s,r){const n=PZe(t,r),{scroll:a}=s;return a&&(n0(n.x,a.offset.x),n0(n.y,a.offset.y)),n}const HTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},GTt=pE.length;function WTt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(ha.test(t))t=parseFloat(t);else return t;const r=kPe(t,s.target.x),n=kPe(t,s.target.y);return`${r}% ${n}%`}},KTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=ny.parse(t);if(a.length>5)return n;const o=ny.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=Cc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},j1e={borderRadius:{...cI,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cI,borderTopRightRadius:cI,borderBottomLeftRadius:cI,borderBottomRightRadius:cI,boxShadow:KTt};function LZe(t,{layout:s,layoutId:r}){return fE.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!j1e[t]||t==="opacity")}function hNe(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)(Sh(n[i])||a&&Sh(a[i])||LZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function ZTt(t){return window.getComputedStyle(t)}class YTt extends MZe{constructor(){super(...arguments),this.type="html",this.renderInstance=IZe}readValueFromInstance(s,r){var n;if(fE.has(r))return(n=this.projection)!=null&&n.isProjecting?c1e(r):xMt(s,r);{const a=ZTt(s),o=(UKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return PZe(s,r)}build(s,r,n){uNe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return hNe(s,r,n)}}const QTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},XTt={offset:"strokeDashoffset",array:"strokeDasharray"};function JTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?QTt:XTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const eAt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function DZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,m){if(uNe(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=(m==null?void 0:m.transformBox)??"fill-box",delete f.transformBox);for(const y of eAt)f[y]!==void 0&&(g[y]=f[y],delete f[y]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&JTt(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"]),RZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function tAt(t,s,r,n){IZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(OZe.has(a)?a:rNe(a),s.attrs[a])}function FZe(t,s,r){const n=hNe(t,s,r);for(const a in t)if(Sh(t[a])||Sh(s[a])){const o=pE.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class sAt extends MZe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=vu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(fE.has(r)){const n=yZe(r);return n&&n.default||0}return r=OZe.has(r)?r:rNe(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return FZe(s,r,n)}build(s,r,n){DZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){tAt(s,r,n,a)}mount(s){this.isSVGTag=RZe(s.tagName),super.mount(s)}}const rAt=dNe.length;function zZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?zZe(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})=>rTt(t,r,n)))}function oAt(t){let s=iAt(t),r=SPe(),n=!0,a=!1;const o=u=>(m,f)=>{var y;const g=ES(t,f,u==="exit"?(y=t.presenceContext)==null?void 0:y.custom:void 0);if(g){const{transition:_,transitionEnd:w,...j}=g;m={...m,...j,...w}}return m};function l(u){s=u(t)}function i(u){const{props:m}=t,f=zZe(t.parent)||{},g=[],y=new Set;let _={},w=1/0;for(let N=0;Nw&&P,V=!1;const X=Array.isArray(I)?I:[I];let Y=X.reduce(o(S),{});O===!1&&(Y={});const{prevResolvedValues:J={}}=M,Q={...J,...Y},ce=oe=>{z=!0,y.has(oe)&&(V=!0,y.delete(oe)),M.needsAnimating[oe]=!0;const he=t.getValue(oe);he&&(he.liveStyle=!1)};for(const oe in Q){const he=Y[oe],xe=J[oe];if(_.hasOwnProperty(oe))continue;let ue=!1;f1e(he)&&f1e(xe)?ue=!BZe(he,xe):ue=he!==xe,ue?he!=null?ce(oe):y.add(oe):he!==void 0&&y.has(oe)?ce(oe):M.protectedKeys[oe]=!0}M.prevProp=I,M.prevResolvedValues=Y,M.isActive&&(_={..._,...Y}),(n||a)&&t.blockInitialAnimation&&(z=!1);const ne=q&&$;z&&(!ne||V)&&g.push(...X.map(oe=>{const he={type:S};if(typeof oe=="string"&&(n||a)&&!ne&&t.manuallyAnimateOnMount&&t.parent){const{parent:xe}=t,ue=ES(xe,oe);if(xe.enteringChildren&&ue){const{delayChildren:ge}=ue.transition||{};he.delay=cZe(xe.enteringChildren,t,ge)}}return{animation:oe,options:he}}))}if(y.size){const N={};if(typeof m.initial!="boolean"){const S=ES(t,Array.isArray(m.initial)?m.initial[0]:m.initial);S&&S.transition&&(N.transition=S.transition)}y.forEach(S=>{const M=t.getBaseTarget(S),I=t.getValue(S);I&&(I.liveStyle=!0),N[S]=M??null}),g.push({animation:N})}let j=!!g.length;return n&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(j=!1),n=!1,a=!1,j?s(g):Promise.resolve()}function c(u,m){var g;if(r[u].isActive===m)return Promise.resolve();(g=t.variantChildren)==null||g.forEach(y=>{var _;return(_=y.animationState)==null?void 0:_.setActive(u,m)}),r[u].isActive=m;const f=i(u);for(const y in r)r[y].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=SPe(),a=!0}}}function lAt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!BZe(s,t):!1}function V2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function SPe(){return{animate:V2(!0),whileInView:V2(),whileHover:V2(),whileTap:V2(),whileDrag:V2(),whileFocus:V2(),exit:V2()}}function N1e(t,s){t.min=s.min,t.max=s.max}function Mg(t,s){N1e(t.x,s.x),N1e(t.y,s.y)}function CPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const $Ze=1e-4,cAt=1-$Ze,dAt=1+$Ze,qZe=.01,uAt=0-qZe,hAt=0+qZe;function Am(t){return t.max-t.min}function mAt(t,s,r){return Math.abs(t-s)<=r}function MPe(t,s,r,n=.5){t.origin=n,t.originPoint=Cc(s.min,s.max,t.origin),t.scale=Am(r)/Am(s),t.translate=Cc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=cAt&&t.scale<=dAt||isNaN(t.scale))&&(t.scale=1),(t.translate>=uAt&&t.translate<=hAt||isNaN(t.translate))&&(t.translate=0)}function h8(t,s,r,n){MPe(t.x,s.x,r.x,n?n.originX:void 0),MPe(t.y,s.y,r.y,n?n.originY:void 0)}function TPe(t,s,r,n=0){const a=n?Cc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Am(s)}function pAt(t,s,r,n){TPe(t.x,s.x,r.x,n==null?void 0:n.x),TPe(t.y,s.y,r.y,n==null?void 0:n.y)}function APe(t,s,r,n=0){const a=n?Cc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Am(s)}function Joe(t,s,r,n){APe(t.x,s.x,r.x,n==null?void 0:n.x),APe(t.y,s.y,r.y,n==null?void 0:n.y)}function EPe(t,s,r,n,a){return t-=s,t=Xoe(t,1/r,n),a!==void 0&&(t=Xoe(t,1/a,n)),t}function fAt(t,s=0,r=1,n=.5,a,o=t,l=t){if(A0.test(s)&&(s=parseFloat(s),s=Cc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=Cc(o.min,o.max,n);t===o&&(i-=s),t.min=EPe(t.min,s,r,i,a),t.max=EPe(t.max,s,r,i,a)}function PPe(t,s,[r,n,a],o,l){fAt(t,s[r],s[n],s[a],s.scale,o,l)}const xAt=["x","scaleX","originX"],gAt=["y","scaleY","originY"];function IPe(t,s,r,n){PPe(t.x,s,xAt,r?r.x:void 0,n?n.x:void 0),PPe(t.y,s,gAt,r?r.y:void 0,n?n.y:void 0)}function LPe(t){return t.translate===0&&t.scale===1}function UZe(t){return LPe(t.x)&&LPe(t.y)}function DPe(t,s){return t.min===s.min&&t.max===s.max}function yAt(t,s){return DPe(t.x,s.x)&&DPe(t.y,s.y)}function OPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function VZe(t,s){return OPe(t.x,s.x)&&OPe(t.y,s.y)}function RPe(t){return Am(t.x)/Am(t.y)}function FPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Zy(t){return[t("x"),t("y")]}function vAt(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:m,rotateX:f,rotateY:g,skewX:y,skewY:_}=r;u&&(n=`perspective(${u}px) ${n}`),m&&(n+=`rotate(${m}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),y&&(n+=`skewX(${y}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 HZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],bAt=HZe.length,zPe=t=>typeof t=="string"?parseFloat(t):t,BPe=t=>typeof t=="number"||ha.test(t);function _At(t,s,r,n,a,o){a?(t.opacity=Cc(0,r.opacity??1,wAt(n)),t.opacityExit=Cc(s.opacity??1,0,jAt(n))):o&&(t.opacity=Cc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(vD(t,s,n))}function NAt(t,s,r){const n=Sh(t)?t:iA(t);return n.start(tNe("",n,s,r)),n.animation}function wD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const kAt=(t,s)=>t.depth-s.depth;class SAt{constructor(){this.children=[],this.isDirty=!1}add(s){qje(this.children,s),this.isDirty=!0}remove(s){Goe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(kAt),this.isDirty=!1,this.children.forEach(s)}}function CAt(t,s){const r=Tm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(jw(n),t(o-s))};return Rl.setup(n,!0),()=>jw(n)}function Pie(t){return Sh(t)?t.get():t}class MAt{constructor(){this.members=[]}add(s){qje(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&&(Goe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Goe(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 Iie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Jxe=["","X","Y","Z"],TAt=1e3;let AAt=0;function ege(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function WZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=pZe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Rl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&WZe(n)}function KZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=AAt++,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(IAt),this.nodes.forEach(zAt),this.nodes.forEach(BAt),this.nodes.forEach(LAt)},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;Rl.read(()=>{f=window.innerWidth}),t(l,()=>{const y=window.innerWidth;y!==f&&(f=y,this.root.updateBlockedByResize=!0,m&&m(),m=CAt(g,250),Iie.hasAnimatedSinceResize&&(Iie.hasAnimatedSinceResize=!1,this.nodes.forEach(VPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||u.getDefaultTransition()||HAt,{onLayoutAnimationStart:w,onLayoutAnimationComplete:j}=u.getProps(),N=!this.targetLayout||!VZe(this.targetLayout,y),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={...eNe(_,"layout"),onPlay:w,onComplete:j};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(m,S)}else f||VPe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}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(),jw(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($At),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&&WZe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Am(this.snapshot.measuredBox.x)&&!Am(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 P=I/1e3;HPe(f.x,l.x,P),HPe(f.y,l.y,P),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Joe(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),UAt(this.relativeTarget,this.relativeTargetOrigin,g,P),M&&yAt(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=vu()),Mg(M,this.relativeTarget)),w&&(this.animationValues=m,_At(m,u,this.latestValues,P,S,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},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&&(jw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Rl.update(()=>{Iie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=iA(0)),this.motionValue.jump(0,!1),this.currentAnimation=NAt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:m=>{this.mixTargetDelta(m),l.onUpdate&&l.onUpdate(m)},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(TAt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:c,layout:u,latestValues:m}=l;if(!(!i||!c||!u)){if(this!==l&&this.layout&&u&&ZZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||vu();const f=Am(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const g=Am(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+g}Mg(i,c),Eie(i,m),h8(this.projectionDeltaWithTransform,this.layoutCorrected,i,m)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new MAt),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&&ege("z",l,u,this.animationValues);for(let m=0;m{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(qPe),this.root.sharedNodes.clear()}}}function EAt(t){t.updateLayout()}function PAt(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")Zy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],y=Am(g);g.min=n[f].min,g.max=g.min+y});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";N1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else ZZe(o,s.layoutBox,n)&&Zy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],y=Am(n[f]);g.max=g.min+y,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+y)});const i=jM();h8(i,n,s.layoutBox);const c=jM();l?h8(c,t.applyTransform(a,!0),s.measuredBox):h8(c,n,s.layoutBox);const u=!UZe(i);let m=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:y}=f;if(g&&y){const _=t.options.layoutAnchor||void 0,w=vu();Joe(w,s.layoutBox,g.layoutBox,_);const j=vu();Joe(j,n,y.layoutBox,_),VZe(w,j)||(m=!0),f.options.layoutRoot&&(t.relativeTarget=j,t.relativeTargetOrigin=w,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:c,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:m})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function IAt(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 LAt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function DAt(t){t.clearSnapshot()}function qPe(t){t.clearMeasurements()}function OAt(t){t.isLayoutDirty=!0,t.updateLayout()}function UPe(t){t.isLayoutDirty=!1}function RAt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function FAt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function VPe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function zAt(t){t.resolveTargetDelta()}function BAt(t){t.calcProjection()}function $At(t){t.resetSkewAndRotation()}function qAt(t){t.removeLeadSnapshot()}function HPe(t,s,r){t.translate=Cc(s.translate,0,r),t.scale=Cc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function GPe(t,s,r,n){t.min=Cc(s.min,r.min,n),t.max=Cc(s.max,r.max,n)}function UAt(t,s,r,n){GPe(t.x,s.x,r.x,n),GPe(t.y,s.y,r.y,n)}function VAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const HAt={duration:.45,ease:[.4,0,.1,1]},WPe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),KPe=WPe("applewebkit/")&&!WPe("chrome/")?Math.round:Dx;function ZPe(t){t.min=KPe(t.min),t.max=KPe(t.max)}function GAt(t){ZPe(t.x),ZPe(t.y)}function ZZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!mAt(RPe(s),RPe(r),.2)}function WAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const KAt=KZe({attachResizeListener:(t,s)=>wD(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}),tge={current:void 0},YZe=KZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!tge.current){const t=new KAt({});t.mount(window),t.setOptions({layoutScroll:!0}),tge.current=t}return tge.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),mNe=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function YPe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function ZAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=YPe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:y,height:_,top:w,left:j,right:N,bottom:S}=c.current;if(s||o===!1||!i.current||!y||!_)return;const M=r==="left"?`left: ${j}`:`right: ${N}`,I=n==="bottom"?`bottom: ${S}`:`top: ${w}`;i.current.dataset.motionPopId=l;const P=document.createElement("style");u&&(P.nonce=u);const O=a??document.head;return O.appendChild(P),P.sheet&&P.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${y}px !important; height: ${_}px !important; ${M}px !important; ${I}px !important; } `),()=>{var q;(q=i.current)==null||q.removeAttribute("data-motion-pop-id"),O.contains(P)&&O.removeChild(P)}},[s]),e.jsx(QAt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:k.cloneElement(t,{ref:f})})}const JAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const m=$je(eEt),f=k.useId();let g=!0,y=k.useMemo(()=>(g=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:_=>{m.set(_,!0);for(const w of m.values())if(!w)return;n&&n()},register:_=>(m.set(_,!1),()=>m.delete(_))}),[r,m,n]);return o&&g&&(y={...y}),k.useMemo(()=>{m.forEach((_,w)=>m.set(w,!1))},[r]),k.useEffect(()=>{!r&&!m.size&&n&&n()},[r]),t=e.jsx(XAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(vue.Provider,{value:y,children:t})};function eEt(){return new Map}function QZe(t=!0){const s=k.useContext(vue);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 jz=t=>t.key||"";function QPe(t){const s=[];return k.Children.forEach(t,r=>{k.isValidElement(r)&&s.push(r)}),s}const pNe=({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[m,f]=QZe(l),g=k.useMemo(()=>QPe(t),[t]),y=l&&!m?[]:g.map(jz),_=k.useRef(!0),w=k.useRef(g),j=$je(()=>new Map),N=k.useRef(new Set),[S,M]=k.useState(g),[I,P]=k.useState(g);kKe(()=>{_.current=!1,w.current=g;for(let $=0;${const z=jz($),V=l&&!m?!1:g===I||y.includes(z),X=()=>{if(N.current.has(z))return;if(j.has(z))N.current.add(z),j.set(z,!0);else return;let Y=!0;j.forEach(J=>{J||(Y=!1)}),Y&&(q==null||q(),P(w.current),l&&(f==null||f()),n&&n())};return e.jsx(JAt,{isPresent:V,initial:!_.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:X,anchorX:i,anchorY:c,children:$},z)})})},XZe=k.createContext({strict:!1}),XPe={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 JPe=!1;function tEt(){if(JPe)return;const t={};for(const s in XPe)t[s]={isEnabled:r=>XPe[s].some(n=>!!r[n])};CZe(t),JPe=!0}function JZe(){return tEt(),zTt()}function sEt(t){const s=JZe();for(const r in t)s[r]={...s[r],...t[r]};CZe(s)}const rEt=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 ele(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||rEt.has(t)}let eYe=t=>!ele(t);function nEt(t){typeof t=="function"&&(eYe=s=>s.startsWith("on")?!ele(s):t(s))}try{nEt(require("@emotion/is-prop-valid").default)}catch{}function aEt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||Sh(t[a])||(eYe(a)||r===!0&&ele(a)||!s&&!ele(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const jue=k.createContext({});function iEt(t,s){if(wue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||_D(r)?r:void 0,animate:_D(n)?n:void 0}}return t.inherit!==!1?s:{}}function oEt(t){const{initial:s,animate:r}=iEt(t,k.useContext(jue));return k.useMemo(()=>({initial:s,animate:r}),[eIe(s),eIe(r)])}function eIe(t){return Array.isArray(t)?t.join(" "):t}const fNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function tYe(t,s,r){for(const n in s)!Sh(s[n])&&!LZe(n,r)&&(t[n]=s[n])}function lEt({transformTemplate:t},s){return k.useMemo(()=>{const r=fNe();return uNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function cEt(t,s){const r=t.style||{},n={};return tYe(n,r,t),Object.assign(n,lEt(t,s)),n}function dEt(t,s){const r={},n=cEt(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 sYe=()=>({...fNe(),attrs:{}});function uEt(t,s,r,n){const a=k.useMemo(()=>{const o=sYe();return DZe(o,s,RZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};tYe(o,t.style,t),a.style={...o,...a.style}}return a}const hEt=["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 xNe(t){return typeof t!="string"||t.includes("-")?!1:!!(hEt.indexOf(t)>-1||/[A-Z]/u.test(t))}function mEt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??xNe(t)?uEt:dEt)(s,n,a,t),u=aEt(s,typeof t=="string",o),m=t!==k.Fragment?{...u,...c,ref:r}:{},{children:f}=s,g=k.useMemo(()=>Sh(f)?f.get():f,[f]);return k.createElement(t,{...m,children:g})}function pEt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:fEt(r,n,a,t),renderState:s()}}function fEt(t,s,r,n){const a={},o=n(t,{});for(const g in o)a[g]=Pie(o[g]);let{initial:l,animate:i}=t;const c=wue(t),u=kZe(t);s&&u&&!c&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let m=r?r.initial===!1:!1;m=m||l===!1;const f=m?i:l;if(f&&typeof f!="boolean"&&!_ue(f)){const g=Array.isArray(f)?f:[f];for(let y=0;y(s,r)=>{const n=k.useContext(jue),a=k.useContext(vue),o=()=>pEt(t,s,n,a);return r?o():$je(o)},xEt=rYe({scrapeMotionValuesFromProps:hNe,createRenderState:fNe}),gEt=rYe({scrapeMotionValuesFromProps:FZe,createRenderState:sYe}),yEt=Symbol.for("motionComponentSymbol");function vEt(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 nYe=k.createContext({});function eM(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function bEt(t,s,r,n,a,o){var M,I;const{visualElement:l}=k.useContext(jue),i=k.useContext(XZe),c=k.useContext(vue),u=k.useContext(mNe),m=u.reducedMotion,f=u.skipAnimations,g=k.useRef(null),y=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:m,skipAnimations:f,isSVG:o}),y.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const _=g.current,w=k.useContext(nYe);_&&!_.projection&&a&&(_.type==="html"||_.type==="svg")&&_Et(g.current,r,a,w);const j=k.useRef(!1);k.useInsertionEffect(()=>{_&&j.current&&_.update(r,c)});const N=r[mZe],S=k.useRef(!!N&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return kKe(()=>{y.current=!0,_&&(j.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),S.current&&_.animationState&&_.animationState.animateChanges())}),k.useEffect(()=>{_&&(!S.current&&_.animationState&&_.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var P;(P=window.MotionHandoffMarkAsComplete)==null||P.call(window,N)}),S.current=!1),_.enteringChildren=void 0)}),_}function _Et(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:c,layoutRoot:u,layoutAnchor:m,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:aYe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&eM(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:m})}function aYe(t){if(t)return t.options.allowProjection!==!1?t.projection:aYe(t.parent)}function sge(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&sEt(n);const o=r?r==="svg":xNe(t),l=o?gEt:xEt;function i(u,m){let f;const g={...k.useContext(mNe),...u,layoutId:wEt(u)},{isStatic:y}=g,_=oEt(u),w=l(u,y);if(!y&&typeof window<"u"){jEt();const j=NEt(g);f=j.MeasureLayout,_.visualElement=bEt(t,w,g,a,j.ProjectionNode,o)}return e.jsxs(jue.Provider,{value:_,children:[f&&_.visualElement?e.jsx(f,{visualElement:_.visualElement,...g}):null,mEt(t,u,vEt(w,_.visualElement,m),w,y,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=k.forwardRef(i);return c[yEt]=t,c}function wEt({layoutId:t}){const s=k.useContext(Bje).id;return s&&t!==void 0?s+"-"+t:t}function jEt(t,s){k.useContext(XZe).strict}function NEt(t){const s=JZe(),{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 kEt(t,s){if(typeof Proxy>"u")return sge;const r=new Map,n=(o,l)=>sge(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,sge(l,void 0,t,s)),r.get(l))})}const SEt=(t,s)=>s.isSVG??xNe(t)?new sAt(s):new YTt(s,{allowProjection:t!==k.Fragment});class CEt extends Bw{constructor(s){super(s),s.animationState||(s.animationState=oAt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();_ue(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 MEt=0;class TEt extends Bw{constructor(){super(...arguments),this.id=MEt++,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=ES(this.node,l,i);if(c){const{transition:u,transitionEnd:m,...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 AEt={animation:{Feature:CEt},exit:{Feature:TEt}};function tR(t){return{point:{x:t.pageX,y:t.pageY}}}const EEt=t=>s=>oNe(s)&&t(s,tR(s));function m8(t,s,r,n){return wD(t,s,EEt(r),n)}const iYe=({current:t})=>t?t.ownerDocument.defaultView:null,tIe=(t,s)=>Math.abs(t-s);function PEt(t,s){const r=tIe(t.x,s.x),n=tIe(t.y,s.y);return Math.sqrt(r**2+n**2)}const sIe=new Set(["auto","scroll"]);class oYe{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=y=>{this.handleScroll(y.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Nz(this.lastRawMoveEventInfo,this.transformPagePoint));const y=rge(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,w=PEt(y.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!w)return;const{point:j}=y,{timestamp:N}=wh;this.history.push({...j,timestamp:N});const{onStart:S,onMove:M}=this.handlers;_||(S&&S(this.lastMoveEvent,y),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,y)},this.handlePointerMove=(y,_)=>{this.lastMoveEvent=y,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=Nz(_,this.transformPagePoint),Rl.update(this.updatePoint,!0)},this.handlePointerUp=(y,_)=>{this.end();const{onEnd:w,onSessionEnd:j,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=rge(y.type==="pointercancel"?this.lastMoveEventInfo:Nz(_,this.transformPagePoint),this.history);this.startEvent&&w&&w(y,S),j&&j(y,S)},!oNe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=tR(s),u=Nz(c,this.transformPagePoint),{point:m}=u,{timestamp:f}=wh;this.history=[{...m,timestamp:f}];const{onSessionStart:g}=r;g&&g(s,rge(u,this.history)),this.removeListeners=XO(m8(this.contextWindow,"pointermove",this.handlePointerMove),m8(this.contextWindow,"pointerup",this.handlePointerUp),m8(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(sIe.has(n.overflowX)||sIe.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),Rl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),jw(this.updatePoint)}}function Nz(t,s){return s?{point:s(t.point)}:t}function rIe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function rge({point:t},s){return{point:t,delta:rIe(t,lYe(s)),offset:rIe(t,IEt(s)),velocity:LEt(s,.1)}}function IEt(t){return t[0]}function lYe(t){return t[t.length-1]}function LEt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=lYe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>vf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>vf(s)*2&&(n=t[1]);const o=Sx(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 DEt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?Cc(r,t,n.max):Math.min(t,r)),t}function nIe(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 OEt(t,{top:s,left:r,bottom:n,right:a}){return{x:nIe(t.x,r,a),y:nIe(t.y,s,n)}}function aIe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=vD(s.min,s.max-n,t.min):n>a&&(r=vD(t.min,t.max-a,s.min)),O0(0,1,r)}function zEt(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 k1e=.35;function BEt(t=k1e){return t===!1?t=0:t===!0&&(t=k1e),{x:iIe(t,"left","right"),y:iIe(t,"top","bottom")}}function iIe(t,s,r){return{min:oIe(t,s),max:oIe(t,r)}}function oIe(t,s){return typeof t=="number"?t:t[s]||0}const $Et=new WeakMap;class qEt{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=vu(),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(tR(f).point),this.stopAnimation()},l=(f,g)=>{const{drag:y,dragPropagation:_,onDragStart:w}=this.getProps();if(y&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=fTt(y),!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),Zy(N=>{let S=this.getAxisMotionValue(N).get()||0;if(A0.test(S)){const{projection:M}=this.visualElement;if(M&&M.layout){const I=M.layout.layoutBox[N];I&&(S=Am(I)*(parseFloat(S)/100))}}this.originPoint[N]=S}),w&&Rl.update(()=>w(f,g),!1,!0),x1e(this.visualElement,"transform");const{animationState:j}=this.visualElement;j&&j.setActive("whileDrag",!0)},i=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:y,dragDirectionLock:_,onDirectionLock:w,onDrag:j}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:N}=g;if(_&&this.currentDirection===null){this.currentDirection=VEt(N),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",g.point,N),this.updateAxis("y",g.point,N),this.visualElement.render(),j&&Rl.update(()=>j(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:m}=this.getProps();this.panSession=new oYe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:n,contextWindow:iYe(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&&Rl.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||!kz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=DEt(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&&eM(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=OEt(n.layoutBox,s):this.constraints=!1,this.elastic=BEt(r),a!==this.constraints&&!eM(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Zy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=zEt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!eM(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=VTt(n,a.root,this.visualElement.getTransformPagePoint());let l=REt(a.layout.layoutBox,o);if(r){const i=r($Tt(l));this.hasMutatedConstraints=!!i,i&&(l=TZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Zy(m=>{if(!kz(m,r,this.currentDirection))return;let f=c&&c[m]||{};(l===!0||l===m)&&(f={min:0,max:0});const g=a?200:1e6,y=a?40:1e7,_={type:"inertia",velocity:n?s[m]:0,bounceStiffness:g,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(m,_)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return x1e(this.visualElement,s),n.start(tNe(s,n,0,r,this.visualElement,!1))}stopAnimation(){Zy(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){Zy(r=>{const{drag:n}=this.getProps();if(!kz(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]-Cc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!eM(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Zy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=FEt({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(),Zy(l=>{if(!kz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(Cc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$Et.set(this.visualElement,this);const s=this.visualElement.current,r=m8(s,"pointerdown",u=>{const{drag:m,dragListener:f=!0}=this.getProps(),g=u.target,y=g!==s&&_Tt(g);m&&f&&!y&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();eM(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=UEt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Rl.read(a);const i=wD(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:m})=>{this.isDragging&&m&&(Zy(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=k1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function lIe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function UEt(t,s,r){const n=fPe(t,lIe(r)),a=fPe(s,lIe(r));return()=>{n(),a()}}function kz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function VEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class HEt extends Bw{constructor(s){super(s),this.removeGroupControls=Dx,this.removeListeners=Dx,this.controls=new qEt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Dx}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 nge=t=>(s,r)=>{t&&Rl.update(()=>t(s,r),!1,!0)};class GEt extends Bw{constructor(){super(...arguments),this.removePointerDownListener=Dx}onPointerDown(s){this.session=new oYe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:iYe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:nge(s),onStart:nge(r),onMove:nge(n),onEnd:(o,l)=>{delete this.session,a&&Rl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=m8(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 age=!1;class WEt 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),age&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Iie.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}),age=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Rl.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(),iNe.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;age=!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 cYe(t){const[s,r]=QZe(),n=k.useContext(Bje);return e.jsx(WEt,{...t,layoutGroup:n,switchLayoutGroup:k.useContext(nYe),isPresent:s,safeToRemove:r})}const KEt={pan:{Feature:GEt},drag:{Feature:HEt,ProjectionNode:YZe,MeasureLayout:cYe}};function cIe(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&&Rl.postRender(()=>o(s,tR(s)))}class ZEt extends Bw{mount(){const{current:s}=this.node;s&&(this.unmount=gTt(s,(r,n)=>(cIe(this.node,n,"Start"),a=>cIe(this.node,a,"End"))))}unmount(){}}class YEt extends Bw{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=XO(wD(this.node.current,"focus",()=>this.onFocus()),wD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function dIe(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&&Rl.postRender(()=>o(s,tR(s)))}class QEt extends Bw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=jTt(s,(a,o)=>(dIe(this.node,o,"Start"),(l,{success:i})=>dIe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const S1e=new WeakMap,ige=new WeakMap,XEt=t=>{const s=S1e.get(t.target);s&&s(t)},JEt=t=>{t.forEach(XEt)};function e6t({root:t,...s}){const r=t||document;ige.has(r)||ige.set(r,{});const n=ige.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(JEt,{root:t,...s})),n[a]}function t6t(t,s,r){const n=e6t(s);return S1e.set(t,r),n.observe(t),()=>{S1e.delete(t),n.unobserve(t)}}const s6t={some:0,all:1};class r6t extends Bw{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:s6t[a]},i=u=>{const{isIntersecting:m}=u;if(this.isInView===m||(this.isInView=m,o&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),y=m?f:g;y&&y(u)};this.stopObserver=t6t(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(n6t(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function n6t({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const a6t={inView:{Feature:r6t},tap:{Feature:QEt},focus:{Feature:YEt},hover:{Feature:ZEt}},i6t={layout:{ProjectionNode:YZe,MeasureLayout:cYe}},o6t={...AEt,...a6t,...KEt,...i6t},gs=kEt(o6t,SEt),l6t={some:0,all:1};function c6t(t,s,{root:r,margin:n,amount:a="some"}={}){const o=aNe(t),l=new WeakMap,i=u=>{u.forEach(m=>{const f=l.get(m.target);if(m.isIntersecting!==!!f)if(m.isIntersecting){const g=s(m.target,m);typeof g=="function"?l.set(m.target,g):c.unobserve(m.target)}else typeof f=="function"&&(f(m),l.delete(m.target))})},c=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:l6t[a]});return o.forEach(u=>c.observe(u)),()=>c.disconnect()}function E3(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 c6t(t.current,c,u)},[s,t,r,a,n]),l}function d6t(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 uIe(t){return t.visitor_intent==="buying"&&!t.has_agent}function u6t({token:t}={}){var _;const s=ao(),r=t||s.token,{data:n,isLoading:a,isError:o}=YCt(r),l=Qt(),i=(_=n==null?void 0:n.open_houses)==null?void 0:_.id,{data:c}=pt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:w,error:j}=await H.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(j)throw j;return w},enabled:!!i});if(k.useEffect(()=>{if(!i)return;const w=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(w)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,m=(c==null?void 0:c.length)||0,f=(c==null?void 0:c.filter(w=>w.visitor_intent==="buying").length)||0,g=(c==null?void 0:c.filter(uIe).length)||0,y=w=>{if(!w)return"";const[j,N]=w.split(":"),S=parseInt(j);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(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:m})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(rh,{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(xn,{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:ds(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[y(u.start_time),u.end_time?` – ${y(u.end_time)}`:""]})]}),e.jsx(Li,{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(pNe,{children:c.map((w,j)=>{var M;const N=d6t(w.visitor_intent),S=uIe(w);return e.jsxs(gs.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:j*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(M=w.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:[w.first_name," ",w.last_name||""]}),S&&e.jsx(Ye,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),w.has_agent&&e.jsx(Ye,{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(Ye,{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:ds(new Date(w.created_at),"h:mm a")})]})]})]},w.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(y1,{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 h6t(){const s=hc().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(u6t,{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(uKe,{slug:s})}function m6t({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(xn,{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(aa,{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(Nn,{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(rr,{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(Uc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function p6t({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(ba,{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 Fl(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 g6t(t,s){const r=ds(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 y6t(t,s){const r=ds(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 v6t({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:UM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:sn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:xn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:fn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const m=Fl(c);if(u==="google")window.open(g6t(i,m),"_blank");else{const f=y6t(i,m),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:m})=>{const f=Fl(c),g=M0(f)&&!Nu(f),y=Nu(f),_=!g&&!y;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${m}`,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 ${y?"text-emerald-600":g?"text-slate-400":"text-slate-800"}`,children:[ds(f,"MMM d, yyyy"),y&&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(G_,{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 b6t({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(wn,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(vi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function _6t({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(wd,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Fm,{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:ds(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 w6t({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var _,w;const[l,i]=k.useState({first_name:((_=t.client_name)==null?void 0:_.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[c,u]=k.useState({}),[m,f]=k.useState(!1),g=Tt({mutationFn:async()=>{const{error:j}=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:m&&l.spouse_first_name||null,spouse_last_name:m&&l.spouse_last_name||null,spouse_email:m&&l.spouse_email||null,spouse_phone:m&&l.spouse_phone||null});if(j)throw j},onSuccess:o,onError:j=>{console.error("[PortalOnboarding] Submit failed:",j),me.error("Something went wrong. Please try again.")}}),y=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"}),y&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(aa,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),g.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Le,{required:!0,value:l.first_name,onChange:j=>i(N=>({...N,first_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Le,{value:l.last_name,onChange:j=>i(N=>({...N,last_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Le,{type:"email",value:l.email,onChange:j=>i(N=>({...N,email:j.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Le,{type:"tel",value:l.phone,onChange:j=>i(N=>({...N,phone:j.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:j.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===j.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.label},j.value))})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:j})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===j?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),n.map(j=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-xs text-slate-600",children:[j.question_text," ",j.is_required&&"*"]}),j.field_type==="text"&&e.jsx(Le,{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.id]:N.target.value})),className:"mt-1 rounded-xl"}),j.field_type==="textarea"&&e.jsx("textarea",{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.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"}),j.field_type==="dropdown"&&e.jsxs("select",{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.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..."}),(j.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),j.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,[j.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[j.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},j.id)),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:j=>i(N=>({...N,notes:j.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!m),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:m?"− Remove spouse/partner":"+ Add spouse/partner"}),m&&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(ye,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Le,{value:l.spouse_first_name,onChange:j=>i(N=>({...N,spouse_first_name:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Le,{value:l.spouse_last_name,onChange:j=>i(N=>({...N,spouse_last_name:j.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Le,{type:"email",value:l.spouse_email,onChange:j=>i(N=>({...N,spouse_email:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Le,{type:"tel",value:l.spouse_phone,onChange:j=>i(N=>({...N,spouse_phone:j.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(G,{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 j6t(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function N6t(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 k6t={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. 🎉"}},dYe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function gNe(t){return dYe.map(s=>{if(s==="Active")return{key:"Active",label:j6t(t),description:N6t(t)};const r=k6t[s];return{key:s,label:r.label,description:r.description}})}function hIe(t){if(!t)return 0;const s=dYe.indexOf(t);return s>=0?s:0}function S6t(t,s){return pt({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 C6t(t){return pt({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 uYe({slug:t}){var J,Q,ce,ne,re,oe;const[s,r]=k.useState(!1),[n,a]=k.useState("primary"),[o]=k.useState(()=>{const he=`portal_fp_${t}`;let xe=localStorage.getItem(he);return xe||(xe=localStorage.getItem("portal_fp"),xe?localStorage.setItem(he,xe):(xe=crypto.randomUUID(),localStorage.setItem(he,xe),localStorage.setItem("portal_fp",xe))),xe});k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=S6t(t,!0),u=l==null?void 0:l.linked_portal_id,{data:m}=C6t(u),f=(J=l==null?void 0:l.deal_pipeline)==null?void 0:J.owner_user_id,{data:g}=pt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:he,error:xe}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(xe)throw xe;return he},enabled:!!f}),{data:y}=pt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:he,error:xe}=await H.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(xe)throw xe;return he},enabled:!!f}),_=n==="linked"&&m?m:l,w=_==null?void 0:_.id,{data:j}=pt({queryKey:["portal-updates-public",w],queryFn:async()=>{const{data:he,error:xe}=await H.from("portal_updates").select("*").eq("portal_id",w).order("created_at",{ascending:!1});if(xe)throw xe;return he},enabled:!!w}),N=(Q=_==null?void 0:_.deal_pipeline)==null?void 0:Q.id,{data:S}=pt({queryKey:["portal-documents",N],queryFn:async()=>{const{data:he,error:xe}=await H.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(xe)throw xe;return he},enabled:!!N}),M=l==null?void 0:l.id,{data:I,isLoading:P}=pt({queryKey:["portal-onboarding-check",M,o],queryFn:async()=>{const{data:he,error:xe}=await H.from("portal_onboarding_submissions").select("id").eq("portal_id",M).eq("device_fingerprint",o).maybeSingle();if(xe)throw xe;return he},enabled:!!M&&!!(l!=null&&l.require_onboarding)}),{data:O}=pt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:he,error:xe}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(xe)throw xe;return he},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),q=!!I||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&P)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(ws,{className:"h-48 w-full rounded-2xl"}),e.jsx(ws,{className:"h-10 w-48 mx-auto"}),e.jsx(ws,{className:"h-32 w-full rounded-2xl"}),e.jsx(ws,{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 he=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(w6t,{portal:l,dealData:he,agentProfile:y,customQuestions:O||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const $=(ce=l==null?void 0:l.deal_pipeline)==null?void 0:ce.deal_type,z=(ne=m==null?void 0:m.deal_pipeline)==null?void 0:ne.deal_type,V=!!m,X=he=>he==="listing"?"Your Sale":he==="buy-side"?"Your Purchase":"Transaction",Y=he=>he==="listing"?e.jsx(xn,{className:"w-3.5 h-3.5"}):e.jsx(Mp,{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(m6t,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:y,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(oe=(re=_==null?void 0:_.deal_pipeline)==null?void 0:re.deal_pipeline_stages)==null?void 0:oe.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:[Y($),X($)]}),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:[Y(z),X(z)]})]}),e.jsx(M6t,{portal:_,updates:j,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(ou,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),y&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:y.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function M6t({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=gNe(i);c&&c.length>0&&(u=c.map((y,_)=>{var w,j;return{key:`custom-${_}`,label:y.label||((w=u[_])==null?void 0:w.label)||`Stage ${_+1}`,description:y.description||((j=u[_])==null?void 0:j.description)||"",video_url:y.video_url||void 0}}));const m=c&&c.length>0?Math.min(hIe(o==null?void 0:o.name),u.length-1):hIe(o==null?void 0:o.name),f=u[m],g=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(f6t,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(p6t,{journeyStages:u,currentIndex:m}),f&&e.jsx(x6t,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:g||t.next_step_video_url}),e.jsx(v6t,{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(b6t,{documents:r}),s&&s.length>0&&e.jsx(_6t,{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 T6t(){const s=hc().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(uYe,{slug:s})}const C1e="levelup_affiliate_ref",A6t=30,E6t=()=>{const[t]=Ul();k.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(C1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},P6t=()=>{try{const t=localStorage.getItem(C1e);if(!t)return null;const s=JSON.parse(t),r=A6t*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(C1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},tle="/assets/levelup-logo-header-_ZX7DvlA.png",I6t="/assets/scale-your-team-ku4MPatU.png";function L6t({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(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(Ta,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(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 Gu={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"]}},D6t=[{icon:fp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:$l,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:fn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Uc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:wn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:bo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],O6t=[{icon:ur,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:nn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Nn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Eh,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:aa,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:co,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ja,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Jh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],R6t=[{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."}],F6t=()=>{const{user:t,loading:s}=Fs(),r=ar(),[n]=Ul();k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",$=window.location.pathname==="/";if(q&&$){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!1),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState(""),[j,N]=k.useState(!1),[S,M]=k.useState(!1),I=(q,$=!1)=>{i({tier:q,skipTrial:$}),u(!0)};E6t(),k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",$=location.pathname.startsWith("/public/");!s&&t&&!q&&!$&&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 P=async(q,$=!1)=>{if(!m){me.error("Please enter your email address");return}if(!g.trim()){me.error("Please enter your full name");return}N(!0),o(q+($?"_direct":""));const z=P6t();try{const{data:V,error:X}=await H.functions.invoke("create-checkout",{body:{tier:q,email:m,name:g.trim(),couponCode:_.trim()||void 0,skipTrial:$,referralCode:z}});if(X)throw X;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&&P(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:tle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(G,{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(G,{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(G,{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(G,{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(ba,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(G,{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(G,{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(Ta,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(G,{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(Zi,{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:D6t.map((q,$)=>e.jsxs(Pe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Et,{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(Lt,{className:"text-xl font-sans",children:q.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:q.description})})]},$))})]})}),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(nn,{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:O6t.map((q,$)=>e.jsxs(Pe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Et,{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(Lt,{className:"text-lg font-semibold text-white",children:q.title})]}),e.jsx(De,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:q.description})})]},$))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(G,{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(ba,{className:"ml-2 w-5 h-5"})]})})]})]}),e.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#4a6b6d]/10 text-[#4a6b6d] text-sm font-medium",children:[e.jsx(Ta,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map((q,$)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ua,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:q})]},$))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(G,{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(G,{size:"lg",variant:"outline",onClick:()=>M(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(fn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:I6t,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:R6t.map((q,$)=>e.jsx(Pe,{className:"bg-muted/30 border-0",children:e.jsxs(De,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(z=>e.jsx(ea,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},z))}),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})]})]})},$))})]})}),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(G,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>I("individual_agent"),children:["Start Free Trial",e.jsx(ba,{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(Pe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Et,{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(Zi,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Lt,{className:"text-xl font-sans",children:Gu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Gu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Gu.individual_agent.period})]}),e.jsx(vr,{className:"text-base mt-2",children:Gu.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(mn,{className:"w-4 h-4"}),Gu.individual_agent.trial]})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Gu.individual_agent.features.map((q,$)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},$))})}),e.jsxs(i8,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(G,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(G,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>I("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Pe,{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(Et,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(Ta,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-xl font-sans",children:Gu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Gu.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:Gu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Gu.brokerage_under_25.period})]}),e.jsx(vr,{className:"text-base mt-2",children:Gu.brokerage_under_25.description})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Gu.brokerage_under_25.features.map((q,$)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},$))})}),e.jsx(i8,{className:"pt-4",children:e.jsx(G,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Pe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Et,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Ta,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-xl font-sans",children:Gu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Gu.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:Gu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Gu.brokerage_over_25.period})]}),e.jsx(vr,{className:"text-base mt-2",children:Gu.brokerage_over_25.description})]}),e.jsx(De,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Gu.brokerage_over_25.features.map((q,$)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},$))})}),e.jsx(i8,{className:"pt-4",children:e.jsx(G,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(G,{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(ba,{className:"ml-2 w-5 h-5"})]}),e.jsx(G,{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:tle,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(L6t,{open:S,onOpenChange:M}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{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(ye,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Le,{id:"dialog-name",type:"text",placeholder:"John Smith",value:g,onChange:q=>y(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ye,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Le,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:m,onChange:q=>f(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ye,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(Le,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:_,onChange:q=>w(q.target.value),className:"mt-1"})]})]}),e.jsx(G,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:j,children:j?"Loading...":"Continue to Checkout"})]})})]})},mIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{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. Mobile Information Sharing Policy"}),e.jsx("p",{children:"We respect your privacy. Mobile information (including phone numbers) collected through our website or platform will not be shared, sold, or disclosed to third parties for marketing or promotional purposes."}),e.jsx("p",{className:"mt-3",children:e.jsx("strong",{className:"text-foreground",children:"No mobile information will be shared with third parties/affiliates for marketing/promotional purposes."})}),e.jsx("p",{className:"mt-3",children:"This information is used solely for the purpose of providing services, including sending transactional messages such as account notifications and lead alerts."}),e.jsx("p",{className:"mt-3",children:"By providing your phone number, you consent to receive SMS communications related to your use of our services. Message and data rates may apply. You may opt out at any time."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. 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:"9. 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"})]})]})]})]})})]}),pIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{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"})]})]})]})]})})]}),z6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{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"})]})]})]})]})})]}),B6t=A3({email:wc().email("Invalid email address"),password:wc().min(6,"Password must be at least 6 characters")}),$6t=()=>{const{signIn:t,user:s}=Fs(),r=ar(),[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(""),[u,m]=k.useState(!1),[f,g]=k.useState(!1);k.useEffect(()=>{if(s){const w=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),r(w)}},[s,r]);const y=async w=>{w.preventDefault(),l({}),a(!0);const j=new FormData(w.currentTarget),N=j.get("email"),S=j.get("password");try{B6t.parse({email:N,password:S}),await t(N,S)}catch(M){if(M instanceof D0){const I={};M.errors.forEach(P=>{P.path[0]&&(I[P.path[0]]=P.message)}),l(I)}}finally{a(!1)}},_=async()=>{if(!i){me.error("Please enter your email address");return}m(!0);try{const{error:w}=await H.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;me.success("Password reset email sent! Check your inbox."),g(!1),c("")}catch(w){me.error(w.message||"Failed to send reset email")}finally{m(!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(la,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Ga,{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:UGe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Pe,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Et,{className:"space-y-1 text-center pb-4",children:[e.jsx(Lt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(vr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(De,{children:e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(Le,{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(ye,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Le,{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(G,{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(Oi,{asChild:!0,children:e.jsx(G,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ps,{className:"bg-white",children:[e.jsxs(js,{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(ye,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Le,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>c(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(G,{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(la,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},q6t=()=>{const[t]=Ul(),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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Et,{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(wi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Lt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(vr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(De,{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(rr,{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."})})]})]})})},hYe=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)}}}},mYe=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},U6t=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(),m=Math.ceil((u-c)/(1e3*60*60*24)),f=m<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:m,loading:!1})}else if(i){const c=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),m=Math.ceil((u-c)/(1e3*60*60*24)),f=m<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:m,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},pYe=()=>{const{data:t,isLoading:s}=pt({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")}},fIe="community_last_seen_post_at";function V6t(){const{user:t}=Fs(),s=hc(),[r,n]=k.useState(0),[a,o]=k.useState(null);k.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${fIe}_${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:m,error:f}=await c;!f&&m!==null&&n(m)})()},[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 m=s.pathname==="/community";m||n(w=>w+1);const{data:f}=await H.from("profiles").select("name").eq("id",u.user_id).single(),g=(f==null?void 0:f.name)||"Someone",y=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),_=y.length>50?y.substring(0,50)+"...":y;m||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(`${fIe}_${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 H6t(){const{isAdmin:t}=Fs(),{data:s=0}=pt({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 xE=sue,yNe=wje,G6t=rue,fYe=k.forwardRef(({className:t,...s},r)=>e.jsx(dE,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));fYe.displayName=dE.displayName;const W6t=S3("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"}}),P3=k.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(G6t,{children:[e.jsx(fYe,{}),e.jsxs(uE,{ref:a,className:Pt(W6t({side:t}),s),...n,children:[r,e.jsxs(ZO,{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(Er,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));P3.displayName=uE.displayName;const gE=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});gE.displayName="SheetHeader";const yE=k.forwardRef(({className:t,...s},r)=>e.jsx(WO,{ref:r,className:Pt("text-lg font-semibold text-foreground",t),...s}));yE.displayName=WO.displayName;const xYe=k.forwardRef(({className:t,...s},r)=>e.jsx(KO,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));xYe.displayName=KO.displayName;var Nue="Collapsible",[K6t]=od(Nue),[Z6t,vNe]=K6t(Nue),gYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=lh({prop:n,defaultProp:a??!1,onChange:l,caller:Nue});return e.jsx(Z6t,{scope:r,disabled:o,contentId:Iu(),open:c,onOpenToggle:k.useCallback(()=>u(m=>!m),[u]),children:e.jsx(cn.div,{"data-state":_Ne(c),"data-disabled":o?"":void 0,...i,ref:s})})});gYe.displayName=Nue;var yYe="CollapsibleTrigger",vYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=vNe(yYe,r);return e.jsx(cn.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":_Ne(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Or(t.onClick,a.onOpenToggle)})});vYe.displayName=yYe;var bNe="CollapsibleContent",bYe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=vNe(bNe,t.__scopeCollapsible);return e.jsx(qd,{present:r||a.open,children:({present:o})=>e.jsx(Y6t,{...n,ref:s,present:o})})});bYe.displayName=bNe;var Y6t=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=vNe(bNe,r),[i,c]=k.useState(n),u=k.useRef(null),m=Ka(s,u),f=k.useRef(0),g=f.current,y=k.useRef(0),_=y.current,w=l.open||i,j=k.useRef(w),N=k.useRef(void 0);return k.useEffect(()=>{const S=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(S)},[]),kd(()=>{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,y.current=M.width,j.current||(S.style.transitionDuration=N.current.transitionDuration,S.style.animationName=N.current.animationName),c(n)}},[l.open,n]),e.jsx(cn.div,{"data-state":_Ne(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:m,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...t.style},children:w&&a})});function _Ne(t){return t?"open":"closed"}var Q6t=gYe;const bf=Q6t,_f=vYe,wf=bYe,X6t="/assets/levelup-logo-Eif24dqY.png",J6t="/assets/levelup-logo-icon-C-7iromj.png",ePt="/assets/levelup-logo-mobile-B9skSjUG.png";var sR=t=>t.type==="checkbox",C4=t=>t instanceof Date,Cm=t=>t==null;const _Ye=t=>typeof t=="object";var $d=t=>!Cm(t)&&!Array.isArray(t)&&_Ye(t)&&!C4(t),wYe=t=>$d(t)&&t.target?sR(t.target)?t.target.checked:t.target.value:t,tPt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,jYe=(t,s)=>t.has(tPt(s)),sPt=t=>{const s=t.constructor&&t.constructor.prototype;return $d(s)&&s.hasOwnProperty("isPrototypeOf")},wNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function yu(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(!(wNe&&(t instanceof Blob||n))&&(r||$d(t)))if(s=r?[]:{},!r&&!sPt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=yu(t[a]));else return t;return s}var kue=t=>/^\w*$/.test(t),Id=t=>t===void 0,jNe=t=>Array.isArray(t)?t.filter(Boolean):[],NNe=t=>jNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),In=(t,s,r)=>{if(!s||!$d(t))return r;const n=(kue(s)?[s]:NNe(s)).reduce((a,o)=>Cm(a)?a:a[o],t);return Id(n)||n===t?Id(t[s])?r:t[s]:n},af=t=>typeof t=="boolean",gl=(t,s,r)=>{let n=-1;const a=kue(s)?[s]:NNe(s),o=a.length,l=o-1;for(;++nmt.useContext(kNe),rPt=t=>{const{children:s,...r}=t;return mt.createElement(kNe.Provider,{value:r},s)};var NYe=(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]!==Hg.all&&(s._proxyFormState[l]=!n||Hg.all),r&&(r[l]=!0),t[l]}});return a};const SNe=typeof window<"u"?mt.useLayoutEffect:mt.useEffect;function nPt(t){const s=Sue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=mt.useState(r._formState),c=mt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return SNe(()=>r._subscribe({name:a,formState:c.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),mt.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),mt.useMemo(()=>NYe(l,r,c.current,!1),[l,r])}var d0=t=>typeof t=="string",kYe=(t,s,r,n,a)=>d0(t)?(n&&s.watch.add(t),In(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),In(r,o))):(n&&(s.watchAll=!0),r),M1e=t=>Cm(t)||!_Ye(t);function Qv(t,s,r=new WeakSet){if(M1e(t)||M1e(s))return t===s;if(C4(t)&&C4(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(C4(l)&&C4(i)||$d(l)&&$d(i)||Array.isArray(l)&&Array.isArray(i)?!Qv(l,i,r):l!==i)return!1}}return!0}function aPt(t){const s=Sue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},c=mt.useRef(a),u=mt.useRef(i),m=mt.useRef(void 0);u.current=i;const f=mt.useMemo(()=>r._getWatch(n,c.current),[r,n]),[g,y]=mt.useState(u.current?u.current(f):f);return SNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:_=>{if(!o){const w=kYe(n,r._names,_.values||r._formValues,!1,c.current);if(u.current){const j=u.current(w);Qv(j,m.current)||(y(j),m.current=j)}else y(w)}}}),[r,o,n,l]),mt.useEffect(()=>r._removeUnmounted()),g}function iPt(t){const s=Sue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=jYe(a._names.array,r),c=mt.useMemo(()=>In(a._formValues,r,In(a._defaultValues,r,l)),[a,r,l]),u=aPt({control:a,name:r,defaultValue:c,exact:!0}),m=nPt({control:a,name:r,exact:!0}),f=mt.useRef(t),g=mt.useRef(a.register(r,{...t.rules,value:u,...af(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const y=mt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!In(m.errors,r)},isDirty:{enumerable:!0,get:()=>!!In(m.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!In(m.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!In(m.validatingFields,r)},error:{enumerable:!0,get:()=>In(m.errors,r)}}),[m,r]),_=mt.useCallback(S=>g.current.onChange({target:{value:wYe(S),name:r},type:sle.CHANGE}),[r]),w=mt.useCallback(()=>g.current.onBlur({target:{value:In(a._formValues,r),name:r},type:sle.BLUR}),[r,a._formValues]),j=mt.useCallback(S=>{const M=In(a._fields,r);M&&S&&(M._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:I=>S.setCustomValidity(I),reportValidity:()=>S.reportValidity()})},[a._fields,r]),N=mt.useMemo(()=>({name:r,value:u,...af(n)||m.disabled?{disabled:m.disabled||n}:{},onChange:_,onBlur:w,ref:j}),[r,n,m.disabled,_,w,j,u]);return mt.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...af(f.current.disabled)?{disabled:f.current.disabled}:{}});const M=(I,P)=>{const O=In(a._fields,I);O&&O._f&&(O._f.mount=P)};if(M(r,!0),S){const I=yu(In(a._options.defaultValues,r));gl(a._defaultValues,r,I),Id(In(a._formValues,r))&&gl(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):M(r,!1)}},[r,a,i,o]),mt.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),mt.useMemo(()=>({field:N,formState:m,fieldState:y}),[N,m,y])}const oPt=t=>t.render(iPt(t));var SYe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},p8=t=>Array.isArray(t)?t:[t],xIe=()=>{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=[]}}},up=t=>$d(t)&&!Object.keys(t).length,CNe=t=>t.type==="file",Gg=t=>typeof t=="function",rle=t=>{if(!wNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},CYe=t=>t.type==="select-multiple",MNe=t=>t.type==="radio",lPt=t=>MNe(t)||sR(t),oge=t=>rle(t)&&t.isConnected;function cPt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Gg(t[s]))return!0;return!1};function nle(t,s={}){const r=Array.isArray(t);if($d(t)||r)for(const n in t)Array.isArray(t[n])||$d(t[n])&&!MYe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},nle(t[n],s[n])):Cm(t[n])||(s[n]=!0);return s}function TYe(t,s,r){const n=Array.isArray(t);if($d(t)||n)for(const a in t)Array.isArray(t[a])||$d(t[a])&&!MYe(t[a])?Id(s)||M1e(r[a])?r[a]=Array.isArray(t[a])?nle(t[a],[]):{...nle(t[a])}:TYe(t[a],Cm(s)?{}:s[a],r[a]):r[a]=!Qv(t[a],s[a]);return r}var dI=(t,s)=>TYe(t,s,nle(s));const gIe={value:!1,isValid:!1},yIe={value:!0,isValid:!0};var AYe=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&&!Id(t[0].attributes.value)?Id(t[0].value)||t[0].value===""?yIe:{value:t[0].value,isValid:!0}:yIe:gIe}return gIe},EYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Id(t)?t:s?t===""?NaN:t&&+t:r&&d0(t)?new Date(t):n?n(t):t;const vIe={isValid:!1,value:null};var PYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,vIe):vIe;function bIe(t){const s=t.ref;return CNe(s)?s.files:MNe(s)?PYe(t.refs).value:CYe(s)?[...s.selectedOptions].map(({value:r})=>r):sR(s)?AYe(t.refs).value:EYe(Id(s.value)?t.ref.value:s.value,t)}var uPt=(t,s,r,n)=>{const a={};for(const o of t){const l=In(s,o);l&&gl(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},ale=t=>t instanceof RegExp,uI=t=>Id(t)?t:ale(t)?t.source:$d(t)?ale(t.value)?t.value.source:t.value:t,_Ie=t=>({isOnSubmit:!t||t===Hg.onSubmit,isOnBlur:t===Hg.onBlur,isOnChange:t===Hg.onChange,isOnAll:t===Hg.all,isOnTouch:t===Hg.onTouched});const wIe="AsyncFunction";var hPt=t=>!!t&&!!t.validate&&!!(Gg(t.validate)&&t.validate.constructor.name===wIe||$d(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===wIe)),mPt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),jIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const f8=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=In(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(f8(i,s))break}else if($d(i)&&f8(i,s))break}}};function NIe(t,s,r){const n=In(t,r);if(n||kue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=In(s,o),i=In(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 pPt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return up(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Hg.all))},fPt=(t,s,r)=>!t||!s||t===s||p8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),xPt=(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,gPt=(t,s)=>!jNe(In(t,s)).length&&Yd(t,s),yPt=(t,s,r)=>{const n=p8(In(t,r));return gl(n,"root",s[r]),gl(t,r,n),t},Lie=t=>d0(t);function kIe(t,s,r="validate"){if(Lie(t)||Array.isArray(t)&&t.every(Lie)||af(t)&&!t)return{type:r,message:Lie(t)?t:"",ref:s}}var O5=t=>$d(t)&&!ale(t)?t:{value:t,message:""},SIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:m,min:f,max:g,pattern:y,validate:_,name:w,valueAsNumber:j,mount:N}=t._f,S=In(r,w);if(!N||s.has(w))return{};const M=i?i[0]:l,I=Y=>{a&&M.reportValidity&&(M.setCustomValidity(af(Y)?"":Y||""),M.reportValidity())},P={},O=MNe(l),q=sR(l),$=O||q,z=(j||CNe(l))&&Id(l.value)&&Id(S)||rle(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,V=SYe.bind(null,w,n,P),X=(Y,J,Q,ce=Mv.maxLength,ne=Mv.minLength)=>{const re=Y?J:Q;P[w]={type:Y?ce:ne,message:re,ref:l,...V(Y?ce:ne,re)}};if(o?!Array.isArray(S)||!S.length:c&&(!$&&(z||Cm(S))||af(S)&&!S||q&&!AYe(i).isValid||O&&!PYe(i).isValid)){const{value:Y,message:J}=Lie(c)?{value:!!c,message:c}:O5(c);if(Y&&(P[w]={type:Mv.required,message:J,ref:M,...V(Mv.required,J)},!n))return I(J),P}if(!z&&(!Cm(f)||!Cm(g))){let Y,J;const Q=O5(g),ce=O5(f);if(!Cm(S)&&!isNaN(S)){const ne=l.valueAsNumber||S&&+S;Cm(Q.value)||(Y=ne>Q.value),Cm(ce.value)||(J=nenew Date(new Date().toDateString()+" "+xe),oe=l.type=="time",he=l.type=="week";d0(Q.value)&&S&&(Y=oe?re(S)>re(Q.value):he?S>Q.value:ne>new Date(Q.value)),d0(ce.value)&&S&&(J=oe?re(S)+Y.value,ce=!Cm(J.value)&&S.length<+J.value;if((Q||ce)&&(X(Q,Y.message,J.message),!n))return I(P[w].message),P}if(y&&!z&&d0(S)){const{value:Y,message:J}=O5(y);if(ale(Y)&&!S.match(Y)&&(P[w]={type:Mv.pattern,message:J,ref:l,...V(Mv.pattern,J)},!n))return I(J),P}if(_){if(Gg(_)){const Y=await _(S,r),J=kIe(Y,M);if(J&&(P[w]={...J,...V(Mv.validate,J.message)},!n))return I(J.message),P}else if($d(_)){let Y={};for(const J in _){if(!up(Y)&&!n)break;const Q=kIe(await _[J](S,r),M,J);Q&&(Y={...Q,...V(J,Q.message)},I(Q.message),n&&(P[w]=Y))}if(!up(Y)&&(P[w]={ref:M,...Y},!n))return P}}return I(!0),P};const vPt={mode:Hg.onSubmit,reValidateMode:Hg.onChange,shouldFocusError:!0};function bPt(t={}){let s={...vPt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Gg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=$d(s.defaultValues)||$d(s.values)?yu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:yu(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 m={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...m};const g={array:xIe(),state:xIe()},y=s.criteriaMode===Hg.all,_=Ge=>lt=>{clearTimeout(u),u=setTimeout(Ge,lt)},w=async Ge=>{if(!s.disabled&&(m.isValid||f.isValid||Ge)){const lt=s.resolver?up((await q()).errors):await z(n,!0);lt!==r.isValid&&g.state.next({isValid:lt})}},j=(Ge,lt)=>{!s.disabled&&(m.isValidating||m.validatingFields||f.isValidating||f.validatingFields)&&((Ge||Array.from(i.mount)).forEach(He=>{He&&(lt?gl(r.validatingFields,He,lt):Yd(r.validatingFields,He))}),g.state.next({validatingFields:r.validatingFields,isValidating:!up(r.validatingFields)}))},N=(Ge,lt=[],He,We,tt=!0,Ke=!0)=>{if(We&&He&&!s.disabled){if(l.action=!0,Ke&&Array.isArray(In(n,Ge))){const rt=He(In(n,Ge),We.argA,We.argB);tt&&gl(n,Ge,rt)}if(Ke&&Array.isArray(In(r.errors,Ge))){const rt=He(In(r.errors,Ge),We.argA,We.argB);tt&&gl(r.errors,Ge,rt),gPt(r.errors,Ge)}if((m.touchedFields||f.touchedFields)&&Ke&&Array.isArray(In(r.touchedFields,Ge))){const rt=He(In(r.touchedFields,Ge),We.argA,We.argB);tt&&gl(r.touchedFields,Ge,rt)}(m.dirtyFields||f.dirtyFields)&&(r.dirtyFields=dI(a,o)),g.state.next({name:Ge,isDirty:X(Ge,lt),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else gl(o,Ge,lt)},S=(Ge,lt)=>{gl(r.errors,Ge,lt),g.state.next({errors:r.errors})},M=Ge=>{r.errors=Ge,g.state.next({errors:r.errors,isValid:!1})},I=(Ge,lt,He,We)=>{const tt=In(n,Ge);if(tt){const Ke=In(o,Ge,Id(He)?In(a,Ge):He);Id(Ke)||We&&We.defaultChecked||lt?gl(o,Ge,lt?Ke:bIe(tt._f)):Q(Ge,Ke),l.mount&&w()}},P=(Ge,lt,He,We,tt)=>{let Ke=!1,rt=!1;const it={name:Ge};if(!s.disabled){if(!He||We){(m.isDirty||f.isDirty)&&(rt=r.isDirty,r.isDirty=it.isDirty=X(),Ke=rt!==it.isDirty);const It=Qv(In(a,Ge),lt);rt=!!In(r.dirtyFields,Ge),It?Yd(r.dirtyFields,Ge):gl(r.dirtyFields,Ge,!0),it.dirtyFields=r.dirtyFields,Ke=Ke||(m.dirtyFields||f.dirtyFields)&&rt!==!It}if(He){const It=In(r.touchedFields,Ge);It||(gl(r.touchedFields,Ge,He),it.touchedFields=r.touchedFields,Ke=Ke||(m.touchedFields||f.touchedFields)&&It!==He)}Ke&&tt&&g.state.next(it)}return Ke?it:{}},O=(Ge,lt,He,We)=>{const tt=In(r.errors,Ge),Ke=(m.isValid||f.isValid)&&af(lt)&&r.isValid!==lt;if(s.delayError&&He?(c=_(()=>S(Ge,He)),c(s.delayError)):(clearTimeout(u),c=null,He?gl(r.errors,Ge,He):Yd(r.errors,Ge)),(He?!Qv(tt,He):tt)||!up(We)||Ke){const rt={...We,...Ke&&af(lt)?{isValid:lt}:{},errors:r.errors,name:Ge};r={...r,...rt},g.state.next(rt)}},q=async Ge=>{j(Ge,!0);const lt=await s.resolver(o,s.context,uPt(Ge||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return j(Ge),lt},$=async Ge=>{const{errors:lt}=await q(Ge);if(Ge)for(const He of Ge){const We=In(lt,He);We?gl(r.errors,He,We):Yd(r.errors,He)}else r.errors=lt;return lt},z=async(Ge,lt,He={valid:!0})=>{for(const We in Ge){const tt=Ge[We];if(tt){const{_f:Ke,...rt}=tt;if(Ke){const it=i.array.has(Ke.name),It=tt._f&&hPt(tt._f);It&&m.validatingFields&&j([We],!0);const Vt=await SIe(tt,i.disabled,o,y,s.shouldUseNativeValidation&&!lt,it);if(It&&m.validatingFields&&j([We]),Vt[Ke.name]&&(He.valid=!1,lt))break;!lt&&(In(Vt,Ke.name)?it?yPt(r.errors,Vt,Ke.name):gl(r.errors,Ke.name,Vt[Ke.name]):Yd(r.errors,Ke.name))}!up(rt)&&await z(rt,lt,He)}}return He.valid},V=()=>{for(const Ge of i.unMount){const lt=In(n,Ge);lt&&(lt._f.refs?lt._f.refs.every(He=>!oge(He)):!oge(lt._f.ref))&&Ae(Ge)}i.unMount=new Set},X=(Ge,lt)=>!s.disabled&&(Ge&<&&gl(o,Ge,lt),!Qv(xe(),a)),Y=(Ge,lt,He)=>kYe(Ge,i,{...l.mount?o:Id(lt)?a:d0(Ge)?{[Ge]:lt}:lt},He,lt),J=Ge=>jNe(In(l.mount?o:a,Ge,s.shouldUnregister?In(a,Ge,[]):[])),Q=(Ge,lt,He={})=>{const We=In(n,Ge);let tt=lt;if(We){const Ke=We._f;Ke&&(!Ke.disabled&&gl(o,Ge,EYe(lt,Ke)),tt=rle(Ke.ref)&&Cm(lt)?"":lt,CYe(Ke.ref)?[...Ke.ref.options].forEach(rt=>rt.selected=tt.includes(rt.value)):Ke.refs?sR(Ke.ref)?Ke.refs.forEach(rt=>{(!rt.defaultChecked||!rt.disabled)&&(Array.isArray(tt)?rt.checked=!!tt.find(it=>it===rt.value):rt.checked=tt===rt.value||!!tt)}):Ke.refs.forEach(rt=>rt.checked=rt.value===tt):CNe(Ke.ref)?Ke.ref.value="":(Ke.ref.value=tt,Ke.ref.type||g.state.next({name:Ge,values:yu(o)})))}(He.shouldDirty||He.shouldTouch)&&P(Ge,tt,He.shouldTouch,He.shouldDirty,!0),He.shouldValidate&&he(Ge)},ce=(Ge,lt,He)=>{for(const We in lt){if(!lt.hasOwnProperty(We))return;const tt=lt[We],Ke=Ge+"."+We,rt=In(n,Ke);(i.array.has(Ge)||$d(tt)||rt&&!rt._f)&&!C4(tt)?ce(Ke,tt,He):Q(Ke,tt,He)}},ne=(Ge,lt,He={})=>{const We=In(n,Ge),tt=i.array.has(Ge),Ke=yu(lt);gl(o,Ge,Ke),tt?(g.array.next({name:Ge,values:yu(o)}),(m.isDirty||m.dirtyFields||f.isDirty||f.dirtyFields)&&He.shouldDirty&&g.state.next({name:Ge,dirtyFields:dI(a,o),isDirty:X(Ge,Ke)})):We&&!We._f&&!Cm(Ke)?ce(Ge,Ke,He):Q(Ge,Ke,He),jIe(Ge,i)&&g.state.next({...r,name:Ge}),g.state.next({name:l.mount?Ge:void 0,values:yu(o)})},re=async Ge=>{l.mount=!0;const lt=Ge.target;let He=lt.name,We=!0;const tt=In(n,He),Ke=It=>{We=Number.isNaN(It)||C4(It)&&isNaN(It.getTime())||Qv(It,In(o,He,It))},rt=_Ie(s.mode),it=_Ie(s.reValidateMode);if(tt){let It,Vt;const hs=lt.type?bIe(tt._f):wYe(Ge),Es=Ge.type===sle.BLUR||Ge.type===sle.FOCUS_OUT,Ts=!mPt(tt._f)&&!s.resolver&&!In(r.errors,He)&&!tt._f.deps||xPt(Es,In(r.touchedFields,He),r.isSubmitted,it,rt),cr=jIe(He,i,Es);gl(o,He,hs),Es?(tt._f.onBlur&&tt._f.onBlur(Ge),c&&c(0)):tt._f.onChange&&tt._f.onChange(Ge);const zr=P(He,hs,Es),Ft=!up(zr)||cr;if(!Es&&g.state.next({name:He,type:Ge.type,values:yu(o)}),Ts)return(m.isValid||f.isValid)&&(s.mode==="onBlur"?Es&&w():Es||w()),Ft&&g.state.next({name:He,...cr?{}:zr});if(!Es&&cr&&g.state.next({...r}),s.resolver){const{errors:Ps}=await q([He]);if(Ke(hs),We){const yr=NIe(r.errors,n,He),Is=NIe(Ps,n,yr.name||He);It=Is.error,He=Is.name,Vt=up(Ps)}}else j([He],!0),It=(await SIe(tt,i.disabled,o,y,s.shouldUseNativeValidation))[He],j([He]),Ke(hs),We&&(It?Vt=!1:(m.isValid||f.isValid)&&(Vt=await z(n,!0)));We&&(tt._f.deps&&he(tt._f.deps),O(He,Vt,It,zr))}},oe=(Ge,lt)=>{if(In(r.errors,lt)&&Ge.focus)return Ge.focus(),1},he=async(Ge,lt={})=>{let He,We;const tt=p8(Ge);if(s.resolver){const Ke=await $(Id(Ge)?Ge:tt);He=up(Ke),We=Ge?!tt.some(rt=>In(Ke,rt)):He}else Ge?(We=(await Promise.all(tt.map(async Ke=>{const rt=In(n,Ke);return await z(rt&&rt._f?{[Ke]:rt}:rt)}))).every(Boolean),!(!We&&!r.isValid)&&w()):We=He=await z(n);return g.state.next({...!d0(Ge)||(m.isValid||f.isValid)&&He!==r.isValid?{}:{name:Ge},...s.resolver||!Ge?{isValid:He}:{},errors:r.errors}),lt.shouldFocus&&!We&&f8(n,oe,Ge?tt:i.mount),We},xe=Ge=>{const lt={...l.mount?o:a};return Id(Ge)?lt:d0(Ge)?In(lt,Ge):Ge.map(He=>In(lt,He))},ue=(Ge,lt)=>({invalid:!!In((lt||r).errors,Ge),isDirty:!!In((lt||r).dirtyFields,Ge),error:In((lt||r).errors,Ge),isValidating:!!In(r.validatingFields,Ge),isTouched:!!In((lt||r).touchedFields,Ge)}),ge=Ge=>{Ge&&p8(Ge).forEach(lt=>Yd(r.errors,lt)),g.state.next({errors:Ge?r.errors:{}})},_e=(Ge,lt,He)=>{const We=(In(n,Ge,{_f:{}})._f||{}).ref,tt=In(r.errors,Ge)||{},{ref:Ke,message:rt,type:it,...It}=tt;gl(r.errors,Ge,{...It,...lt,ref:We}),g.state.next({name:Ge,errors:r.errors,isValid:!1}),He&&He.shouldFocus&&We&&We.focus&&We.focus()},Be=(Ge,lt)=>Gg(Ge)?g.state.subscribe({next:He=>"values"in He&&Ge(Y(void 0,lt),He)}):Y(Ge,lt,!0),Se=Ge=>g.state.subscribe({next:lt=>{fPt(Ge.name,lt.name,Ge.exact)&&pPt(lt,Ge.formState||m,et,Ge.reRenderRoot)&&Ge.callback({values:{...o},...r,...lt,defaultValues:a})}}).unsubscribe,Ee=Ge=>(l.mount=!0,f={...f,...Ge.formState},Se({...Ge,formState:f})),Ae=(Ge,lt={})=>{for(const He of Ge?p8(Ge):i.mount)i.mount.delete(He),i.array.delete(He),lt.keepValue||(Yd(n,He),Yd(o,He)),!lt.keepError&&Yd(r.errors,He),!lt.keepDirty&&Yd(r.dirtyFields,He),!lt.keepTouched&&Yd(r.touchedFields,He),!lt.keepIsValidating&&Yd(r.validatingFields,He),!s.shouldUnregister&&!lt.keepDefaultValue&&Yd(a,He);g.state.next({values:yu(o)}),g.state.next({...r,...lt.keepDirty?{isDirty:X()}:{}}),!lt.keepIsValid&&w()},Me=({disabled:Ge,name:lt})=>{(af(Ge)&&l.mount||Ge||i.disabled.has(lt))&&(Ge?i.disabled.add(lt):i.disabled.delete(lt))},ke=(Ge,lt={})=>{let He=In(n,Ge);const We=af(lt.disabled)||af(s.disabled);return gl(n,Ge,{...He||{},_f:{...He&&He._f?He._f:{ref:{name:Ge}},name:Ge,mount:!0,...lt}}),i.mount.add(Ge),He?Me({disabled:af(lt.disabled)?lt.disabled:s.disabled,name:Ge}):I(Ge,!0,lt.value),{...We?{disabled:lt.disabled||s.disabled}:{},...s.progressive?{required:!!lt.required,min:uI(lt.min),max:uI(lt.max),minLength:uI(lt.minLength),maxLength:uI(lt.maxLength),pattern:uI(lt.pattern)}:{},name:Ge,onChange:re,onBlur:re,ref:tt=>{if(tt){ke(Ge,lt),He=In(n,Ge);const Ke=Id(tt.value)&&tt.querySelectorAll&&tt.querySelectorAll("input,select,textarea")[0]||tt,rt=lPt(Ke),it=He._f.refs||[];if(rt?it.find(It=>It===Ke):Ke===He._f.ref)return;gl(n,Ge,{_f:{...He._f,...rt?{refs:[...it.filter(oge),Ke,...Array.isArray(In(a,Ge))?[{}]:[]],ref:{type:Ke.type,name:Ge}}:{ref:Ke}}}),I(Ge,!1,void 0,Ke)}else He=In(n,Ge,{}),He._f&&(He._f.mount=!1),(s.shouldUnregister||lt.shouldUnregister)&&!(jYe(i.array,Ge)&&l.action)&&i.unMount.add(Ge)}}},Oe=()=>s.shouldFocusError&&f8(n,oe,i.mount),qe=Ge=>{af(Ge)&&(g.state.next({disabled:Ge}),f8(n,(lt,He)=>{const We=In(n,He);We&&(lt.disabled=We._f.disabled||Ge,Array.isArray(We._f.refs)&&We._f.refs.forEach(tt=>{tt.disabled=We._f.disabled||Ge}))},0,!1))},ve=(Ge,lt)=>async He=>{let We;He&&(He.preventDefault&&He.preventDefault(),He.persist&&He.persist());let tt=yu(o);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:Ke,values:rt}=await q();r.errors=Ke,tt=yu(rt)}else await z(n);if(i.disabled.size)for(const Ke of i.disabled)Yd(tt,Ke);if(Yd(r.errors,"root"),up(r.errors)){g.state.next({errors:{}});try{await Ge(tt,He)}catch(Ke){We=Ke}}else lt&&await lt({...r.errors},He),Oe(),setTimeout(Oe);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:up(r.errors)&&!We,submitCount:r.submitCount+1,errors:r.errors}),We)throw We},dt=(Ge,lt={})=>{In(n,Ge)&&(Id(lt.defaultValue)?ne(Ge,yu(In(a,Ge))):(ne(Ge,lt.defaultValue),gl(a,Ge,yu(lt.defaultValue))),lt.keepTouched||Yd(r.touchedFields,Ge),lt.keepDirty||(Yd(r.dirtyFields,Ge),r.isDirty=lt.defaultValue?X(Ge,yu(In(a,Ge))):X()),lt.keepError||(Yd(r.errors,Ge),m.isValid&&w()),g.state.next({...r}))},pe=(Ge,lt={})=>{const He=Ge?yu(Ge):a,We=yu(He),tt=up(Ge),Ke=tt?a:We;if(lt.keepDefaultValues||(a=He),!lt.keepValues){if(lt.keepDirtyValues){const rt=new Set([...i.mount,...Object.keys(dI(a,o))]);for(const it of Array.from(rt))In(r.dirtyFields,it)?gl(Ke,it,In(o,it)):ne(it,In(Ke,it))}else{if(wNe&&Id(Ge))for(const rt of i.mount){const it=In(n,rt);if(it&&it._f){const It=Array.isArray(it._f.refs)?it._f.refs[0]:it._f.ref;if(rle(It)){const Vt=It.closest("form");if(Vt){Vt.reset();break}}}}if(lt.keepFieldsRef)for(const rt of i.mount)ne(rt,In(Ke,rt));else n={}}o=s.shouldUnregister?lt.keepDefaultValues?yu(a):{}:yu(Ke),g.array.next({values:{...Ke}}),g.state.next({values:{...Ke}})}i={mount:lt.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!lt.keepIsValid||!!lt.keepDirtyValues,l.watch=!!s.shouldUnregister,g.state.next({submitCount:lt.keepSubmitCount?r.submitCount:0,isDirty:tt?!1:lt.keepDirty?r.isDirty:!!(lt.keepDefaultValues&&!Qv(Ge,a)),isSubmitted:lt.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:tt?{}:lt.keepDirtyValues?lt.keepDefaultValues&&o?dI(a,o):r.dirtyFields:lt.keepDefaultValues&&Ge?dI(a,Ge):lt.keepDirty?r.dirtyFields:{},touchedFields:lt.keepTouched?r.touchedFields:{},errors:lt.keepErrors?r.errors:{},isSubmitSuccessful:lt.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ue=(Ge,lt)=>pe(Gg(Ge)?Ge(o):Ge,lt),Xe=(Ge,lt={})=>{const He=In(n,Ge),We=He&&He._f;if(We){const tt=We.refs?We.refs[0]:We.ref;tt.focus&&(tt.focus(),lt.shouldSelect&&Gg(tt.select)&&tt.select())}},et=Ge=>{r={...r,...Ge}},Je={control:{register:ke,unregister:Ae,getFieldState:ue,handleSubmit:ve,setError:_e,_subscribe:Se,_runSchema:q,_focusError:Oe,_getWatch:Y,_getDirty:X,_setValid:w,_setFieldArray:N,_setDisabledField:Me,_setErrors:M,_getFieldArray:J,_reset:pe,_resetDefaultValues:()=>Gg(s.defaultValues)&&s.defaultValues().then(Ge=>{Ue(Ge,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:qe,_subjects:g,_proxyFormState:m,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Ge){l=Ge},get _defaultValues(){return a},get _names(){return i},set _names(Ge){i=Ge},get _formState(){return r},get _options(){return s},set _options(Ge){s={...s,...Ge}}},subscribe:Ee,trigger:he,register:ke,handleSubmit:ve,watch:Be,setValue:ne,getValues:xe,reset:Ue,resetField:dt,clearErrors:ge,unregister:Ae,setError:_e,setFocus:Xe,getFieldState:ue};return{...Je,formControl:Je}}function Cue(t={}){const s=mt.useRef(void 0),r=mt.useRef(void 0),[n,a]=mt.useState({isDirty:!1,isValidating:!1,isLoading:Gg(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:Gg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Gg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=bPt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,SNe(()=>{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]),mt.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),mt.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),mt.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),mt.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),mt.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),mt.useEffect(()=>{t.values&&!Qv(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]),mt.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=NYe(n,o),s.current}const CIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=In(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},IYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?CIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>CIe(a,r,t))}},_Pt=(t,s)=>{s.shouldUseNativeValidation&&IYe(t,s);const r={};for(const n in t){const a=In(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(wPt(s.names||Object.keys(t),n)){const l=Object.assign({},In(r,n));gl(l,"root",o),gl(r,n,l)}else gl(r,n,o)}return r},wPt=(t,s)=>t.some(r=>r.startsWith(s+"."));var jPt=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(m){return m.errors.forEach(function(f){return t.push(f)})}),s){var c=r[l].types,u=c&&c[n.code];r[l]=SYe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Mue=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&&IYe({},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:_Pt(jPt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Tue=rPt,LYe=k.createContext({}),Yc=({...t})=>e.jsx(LYe.Provider,{value:{name:t.name},children:e.jsx(oPt,{...t})}),Aue=()=>{const t=k.useContext(LYe),s=k.useContext(DYe),{getFieldState:r,formState:n}=Sue(),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}},DYe=k.createContext({}),Oc=k.forwardRef(({className:t,...s},r)=>{const n=k.useId();return e.jsx(DYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Pt("space-y-2",t),...s})})});Oc.displayName="FormItem";const Rc=k.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Aue();return e.jsx(ye,{ref:r,className:Pt(n&&"text-destructive",t),htmlFor:a,...s})});Rc.displayName="FormLabel";const Fc=k.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Aue();return e.jsx(S2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Fc.displayName="FormControl";const Die=k.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Aue();return e.jsx("p",{ref:r,id:n,className:Pt("text-sm text-muted-foreground",t),...s})});Die.displayName="FormDescription";const Em=k.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Aue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Pt("text-sm font-medium text-destructive",t),...r,children:l}):null});Em.displayName="FormMessage";const NPt=A3({category:dKe(["general","technology","crm","marketing"]),subject:wc().min(5,"Subject must be at least 5 characters").max(200),description:wc().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),kPt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function T1e({trigger:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(!1),{user:o}=Fs(),l=Cue({resolver:Mue(NPt),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:kPt[c.category],subject:c.subject}})}catch(m){console.log("Notification send attempted:",m)}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(Oi,{asChild:!0,children:t||e.jsxs(G,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(EL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ps,{className:"sm:max-w-[500px]",children:[e.jsxs(js,{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(Nn,{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(Tue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Yc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Category"}),e.jsxs(Rs,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Fc,{children:e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a category"})})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"general",children:"General Support"}),e.jsx(ft,{value:"technology",children:"Technology Support"}),e.jsx(ft,{value:"crm",children:"CRM Support"}),e.jsx(ft,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Subject"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"Brief description of your issue",...c})}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Description"}),e.jsx(Fc,{children:e.jsx(Tr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(Em,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const SPt=()=>{const{user:t}=Fs(),s=ar(),[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 w=c;if(!w){const S=localStorage.getItem(_);S&&(w=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 I=w?new Date(w):null,P=S.filter(O=>I?new Date(O.created_at)>I:!0);o(P.length)}})();const N=H.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const M=S.new;n(P=>[M,...P].slice(0,20));const I=w?new Date(w):null;(!I||new Date(M.created_at)>I)&&o(P=>P+1),Notification.permission==="granted"&&new Notification(M.title,{body:M.body,icon:"/favicon.ico"})}).subscribe();return()=>{H.removeChannel(N)}},[t,c]);const m=_=>{const w=_.toLowerCase();return w.includes("community")||w.includes("post")?Ki:w.includes("academy")||w.includes("video")?An:w.includes("template")?$l:w.includes("event")?fn:w.includes("newsletter")?x1:w.includes("brokerage")?sh:w.includes("swag")||w.includes("social")?bo:w.includes("toolbox")||w.includes("tool")?ry:w.includes("brief")?nn:Ki},f=_=>{i(!1),_.url&&_.url!=="/"&&s(_.url)},g=()=>{if(!t)return;const _=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,_),u(_),o(0)},y=_=>{i(_),_&&a>0&&g()};return e.jsxs(du,{open:l,onOpenChange:y,children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Fm,{className:"h-5 w-5"}),a>0&&e.jsx(Ye,{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(Ud,{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(G,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:g,children:"Mark all read"})]}),e.jsx(Li,{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 w=m(_.title);return e.jsxs(La,{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(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:_.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:ql(new Date(_.created_at),{addSuffix:!0})})]})]},_.id)})})]})]})};var MIe=1,CPt=.9,MPt=.8,TPt=.17,lge=.1,cge=.999,APt=.9999,EPt=.99,PPt=/[\\\/_+.#"@\[\(\{&]/,IPt=/[\\\/_+.#"@\[\(\{&]/g,LPt=/[\s-]/,OYe=/[\s-]/g;function A1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?MIe:EPt;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var c=n.charAt(o),u=r.indexOf(c,a),m=0,f,g,y,_;u>=0;)f=A1e(t,s,r,n,u+1,o+1,l),f>m&&(u===a?f*=MIe:PPt.test(t.charAt(u-1))?(f*=MPt,y=t.slice(a,u-1).match(IPt),y&&a>0&&(f*=Math.pow(cge,y.length))):LPt.test(t.charAt(u-1))?(f*=CPt,_=t.slice(a,u-1).match(OYe),_&&a>0&&(f*=Math.pow(cge,_.length))):(f*=TPt,a>0&&(f*=Math.pow(cge,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=APt)),(ff&&(f=g*lge)),f>m&&(m=f),u=r.indexOf(c,u+1);return l[i]=m,m}function TIe(t){return t.toLowerCase().replace(OYe," ")}function DPt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,A1e(t,s,TIe(t),TIe(s),0,0,{})}var hI='[cmdk-group=""]',dge='[cmdk-group-items=""]',OPt='[cmdk-group-heading=""]',RYe='[cmdk-item=""]',AIe=`${RYe}:not([aria-disabled="true"])`,E1e="cmdk-item-select",tM="data-value",RPt=(t,s,r)=>DPt(t,s,r),FYe=k.createContext(void 0),rR=()=>k.useContext(FYe),zYe=k.createContext(void 0),TNe=()=>k.useContext(zYe),BYe=k.createContext(void 0),$Ye=k.forwardRef((t,s)=>{let r=sM(()=>{var ge,_e;return{search:"",value:(_e=(ge=t.value)!=null?ge:t.defaultValue)!=null?_e:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=sM(()=>new Set),a=sM(()=>new Map),o=sM(()=>new Map),l=sM(()=>new Set),i=qYe(t),{label:c,children:u,value:m,onValueChange:f,filter:g,shouldFilter:y,loop:_,disablePointerSelection:w=!1,vimBindings:j=!0,...N}=t,S=Iu(),M=Iu(),I=Iu(),P=k.useRef(null),O=KPt();n3(()=>{if(m!==void 0){let ge=m.trim();r.current.value=ge,q.emit()}},[m]),n3(()=>{O(6,J)},[]);let q=k.useMemo(()=>({subscribe:ge=>(l.current.add(ge),()=>l.current.delete(ge)),snapshot:()=>r.current,setState:(ge,_e,Be)=>{var Se,Ee,Ae,Me;if(!Object.is(r.current[ge],_e)){if(r.current[ge]=_e,ge==="search")Y(),V(),O(1,X);else if(ge==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ke=document.getElementById(I);ke?ke.focus():(Se=document.getElementById(S))==null||Se.focus()}if(O(7,()=>{var ke;r.current.selectedItemId=(ke=Q())==null?void 0:ke.id,q.emit()}),Be||O(5,J),((Ee=i.current)==null?void 0:Ee.value)!==void 0){let ke=_e??"";(Me=(Ae=i.current).onValueChange)==null||Me.call(Ae,ke);return}}q.emit()}},emit:()=>{l.current.forEach(ge=>ge())}}),[]),$=k.useMemo(()=>({value:(ge,_e,Be)=>{var Se;_e!==((Se=o.current.get(ge))==null?void 0:Se.value)&&(o.current.set(ge,{value:_e,keywords:Be}),r.current.filtered.items.set(ge,z(_e,Be)),O(2,()=>{V(),q.emit()}))},item:(ge,_e)=>(n.current.add(ge),_e&&(a.current.has(_e)?a.current.get(_e).add(ge):a.current.set(_e,new Set([ge]))),O(3,()=>{Y(),V(),r.current.value||X(),q.emit()}),()=>{o.current.delete(ge),n.current.delete(ge),r.current.filtered.items.delete(ge);let Be=Q();O(4,()=>{Y(),(Be==null?void 0:Be.getAttribute("id"))===ge&&X(),q.emit()})}),group:ge=>(a.current.has(ge)||a.current.set(ge,new Set),()=>{o.current.delete(ge),a.current.delete(ge)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:I,labelId:M,listInnerRef:P}),[]);function z(ge,_e){var Be,Se;let Ee=(Se=(Be=i.current)==null?void 0:Be.filter)!=null?Se:RPt;return ge?Ee(ge,r.current.search,_e):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let ge=r.current.filtered.items,_e=[];r.current.filtered.groups.forEach(Se=>{let Ee=a.current.get(Se),Ae=0;Ee.forEach(Me=>{let ke=ge.get(Me);Ae=Math.max(ke,Ae)}),_e.push([Se,Ae])});let Be=P.current;ce().sort((Se,Ee)=>{var Ae,Me;let ke=Se.getAttribute("id"),Oe=Ee.getAttribute("id");return((Ae=ge.get(Oe))!=null?Ae:0)-((Me=ge.get(ke))!=null?Me:0)}).forEach(Se=>{let Ee=Se.closest(dge);Ee?Ee.appendChild(Se.parentElement===Ee?Se:Se.closest(`${dge} > *`)):Be.appendChild(Se.parentElement===Be?Se:Se.closest(`${dge} > *`))}),_e.sort((Se,Ee)=>Ee[1]-Se[1]).forEach(Se=>{var Ee;let Ae=(Ee=P.current)==null?void 0:Ee.querySelector(`${hI}[${tM}="${encodeURIComponent(Se[0])}"]`);Ae==null||Ae.parentElement.appendChild(Ae)})}function X(){let ge=ce().find(Be=>Be.getAttribute("aria-disabled")!=="true"),_e=ge==null?void 0:ge.getAttribute(tM);q.setState("value",_e||void 0)}function Y(){var ge,_e,Be,Se;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ee=0;for(let Ae of n.current){let Me=(_e=(ge=o.current.get(Ae))==null?void 0:ge.value)!=null?_e:"",ke=(Se=(Be=o.current.get(Ae))==null?void 0:Be.keywords)!=null?Se:[],Oe=z(Me,ke);r.current.filtered.items.set(Ae,Oe),Oe>0&&Ee++}for(let[Ae,Me]of a.current)for(let ke of Me)if(r.current.filtered.items.get(ke)>0){r.current.filtered.groups.add(Ae);break}r.current.filtered.count=Ee}function J(){var ge,_e,Be;let Se=Q();Se&&(((ge=Se.parentElement)==null?void 0:ge.firstChild)===Se&&((Be=(_e=Se.closest(hI))==null?void 0:_e.querySelector(OPt))==null||Be.scrollIntoView({block:"nearest"})),Se.scrollIntoView({block:"nearest"}))}function Q(){var ge;return(ge=P.current)==null?void 0:ge.querySelector(`${RYe}[aria-selected="true"]`)}function ce(){var ge;return Array.from(((ge=P.current)==null?void 0:ge.querySelectorAll(AIe))||[])}function ne(ge){let _e=ce()[ge];_e&&q.setState("value",_e.getAttribute(tM))}function re(ge){var _e;let Be=Q(),Se=ce(),Ee=Se.findIndex(Me=>Me===Be),Ae=Se[Ee+ge];(_e=i.current)!=null&&_e.loop&&(Ae=Ee+ge<0?Se[Se.length-1]:Ee+ge===Se.length?Se[0]:Se[Ee+ge]),Ae&&q.setState("value",Ae.getAttribute(tM))}function oe(ge){let _e=Q(),Be=_e==null?void 0:_e.closest(hI),Se;for(;Be&&!Se;)Be=ge>0?GPt(Be,hI):WPt(Be,hI),Se=Be==null?void 0:Be.querySelector(AIe);Se?q.setState("value",Se.getAttribute(tM)):re(ge)}let he=()=>ne(ce().length-1),xe=ge=>{ge.preventDefault(),ge.metaKey?he():ge.altKey?oe(1):re(1)},ue=ge=>{ge.preventDefault(),ge.metaKey?ne(0):ge.altKey?oe(-1):re(-1)};return k.createElement(cn.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:ge=>{var _e;(_e=N.onKeyDown)==null||_e.call(N,ge);let Be=ge.nativeEvent.isComposing||ge.keyCode===229;if(!(ge.defaultPrevented||Be))switch(ge.key){case"n":case"j":{j&&ge.ctrlKey&&xe(ge);break}case"ArrowDown":{xe(ge);break}case"p":case"k":{j&&ge.ctrlKey&&ue(ge);break}case"ArrowUp":{ue(ge);break}case"Home":{ge.preventDefault(),ne(0);break}case"End":{ge.preventDefault(),he();break}case"Enter":{ge.preventDefault();let Se=Q();if(Se){let Ee=new Event(E1e);Se.dispatchEvent(Ee)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:$.inputId,id:$.labelId,style:YPt},c),Eue(t,ge=>k.createElement(zYe.Provider,{value:q},k.createElement(FYe.Provider,{value:$},ge))))}),FPt=k.forwardRef((t,s)=>{var r,n;let a=Iu(),o=k.useRef(null),l=k.useContext(BYe),i=rR(),c=qYe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;n3(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let m=UYe(a,o,[t.value,t.children,o],t.keywords),f=TNe(),g=Nw(O=>O.value&&O.value===m.current),y=Nw(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(E1e,_),()=>O.removeEventListener(E1e,_)},[y,t.onSelect,t.disabled]);function _(){var O,q;w(),(q=(O=c.current).onSelect)==null||q.call(O,m.current)}function w(){f.setState("value",m.current,!0)}if(!y)return null;let{disabled:j,value:N,onSelect:S,forceMount:M,keywords:I,...P}=t;return k.createElement(cn.div,{ref:I1(o,s),...P,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!g,"data-disabled":!!j,"data-selected":!!g,onPointerMove:j||i.getDisablePointerSelection()?void 0:w,onClick:j?void 0:_},t.children)}),zPt=k.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Iu(),i=k.useRef(null),c=k.useRef(null),u=Iu(),m=rR(),f=Nw(y=>a||m.filter()===!1?!0:y.search?y.filtered.groups.has(l):!0);n3(()=>m.group(l),[]),UYe(l,i,[t.value,t.heading,c]);let g=k.useMemo(()=>({id:l,forceMount:a}),[a]);return k.createElement(cn.div,{ref:I1(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),Eue(t,y=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},k.createElement(BYe.Provider,{value:g},y))))}),BPt=k.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=k.useRef(null),o=Nw(l=>!l.search);return!r&&!o?null:k.createElement(cn.div,{ref:I1(a,s),...n,"cmdk-separator":"",role:"separator"})}),$Pt=k.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=TNe(),l=Nw(u=>u.search),i=Nw(u=>u.selectedItemId),c=rR();return k.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),k.createElement(cn.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)}})}),qPt=k.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=k.useRef(null),l=k.useRef(null),i=Nw(u=>u.selectedItemId),c=rR();return k.useEffect(()=>{if(l.current&&o.current){let u=l.current,m=o.current,f,g=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let y=u.offsetHeight;m.style.setProperty("--cmdk-list-height",y.toFixed(1)+"px")})});return g.observe(u),()=>{cancelAnimationFrame(f),g.unobserve(u)}}},[]),k.createElement(cn.div,{ref:I1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},Eue(t,u=>k.createElement("div",{ref:I1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),UPt=k.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return k.createElement(sue,{open:r,onOpenChange:n},k.createElement(rue,{container:l},k.createElement(dE,{"cmdk-overlay":"",className:a}),k.createElement(uE,{"aria-label":t.label,"cmdk-dialog":"",className:o},k.createElement($Ye,{ref:s,...i}))))}),VPt=k.forwardRef((t,s)=>Nw(r=>r.filtered.count===0)?k.createElement(cn.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),HPt=k.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return k.createElement(cn.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Eue(t,l=>k.createElement("div",{"aria-hidden":!0},l)))}),Ip=Object.assign($Ye,{List:qPt,Item:FPt,Input:$Pt,Group:zPt,Separator:BPt,Dialog:UPt,Empty:VPt,Loading:HPt});function GPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function WPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function qYe(t){let s=k.useRef(t);return n3(()=>{s.current=t}),s}var n3=typeof window>"u"?k.useEffect:k.useLayoutEffect;function sM(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function Nw(t){let s=TNe(),r=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,r,r)}function UYe(t,s,r,n=[]){let a=k.useRef(),o=rR();return n3(()=>{var l;let i=(()=>{var u;for(let m of r){if(typeof m=="string")return m.trim();if(typeof m=="object"&&"current"in m)return m.current?(u=m.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(tM,i),a.current=i}),a}var KPt=()=>{let[t,s]=k.useState(),r=sM(()=>new Map);return n3(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function ZPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Eue({asChild:t,children:s},r){return t&&k.isValidElement(s)?k.cloneElement(ZPt(s),{ref:s.ref},r(s.props.children)):r(s)}var YPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Bx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ip,{ref:r,className:Pt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Bx.displayName=Ip.displayName;const QPt=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ps,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Bx,{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})})}),$x=k.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(sn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ip.Input,{ref:r,className:Pt("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));$x.displayName=Ip.Input.displayName;const qx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ip.List,{ref:r,className:Pt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));qx.displayName=Ip.List.displayName;const Ux=k.forwardRef((t,s)=>e.jsx(Ip.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Ux.displayName=Ip.Empty.displayName;const Vx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ip.Group,{ref:r,className:Pt("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Vx.displayName=Ip.Group.displayName;const XPt=k.forwardRef(({className:t,...s},r)=>e.jsx(Ip.Separator,{ref:r,className:Pt("-mx-1 h-px bg-border",t),...s}));XPt.displayName=Ip.Separator.displayName;const _p=k.forwardRef(({className:t,...s},r)=>e.jsx(Ip.Item,{ref:r,className:Pt("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));_p.displayName=Ip.Item.displayName;const JPt={event:{label:"Events",icon:Fd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:$l,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Qh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:ry,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:nn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},EIe=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(""),[a,o]=k.useState([]),[l,i]=k.useState(!1),c=ar();k.useEffect(()=>{const g=y=>{y.key==="k"&&(y.metaKey||y.ctrlKey)&&(y.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 y=`%${g}%`;try{const[_,w,j,N,S]=await Promise.all([H.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${y},description.ilike.${y}`).limit(5),H.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${y},description.ilike.${y}`).limit(5),H.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${y},description.ilike.${y}`).limit(5),H.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${y},description.ilike.${y}`).limit(5),H.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${y},description.ilike.${y}`).limit(5)]),M=[];_.data&&_.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),w.data&&w.data.forEach(I=>{M.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),j.data&&j.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),N.data&&N.data.forEach(I=>{M.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),S.data&&S.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.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 m=g=>{s(!1),n(""),c(g)},f=a.reduce((g,y)=>(g[y.type]||(g[y.type]=[]),g[y.type].push(y),g),{});return e.jsxs(e.Fragment,{children:[e.jsxs(G,{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(sn,{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(QPt,{open:t,onOpenChange:s,children:[e.jsx($x,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(qx,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Ux,{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,y])=>{const _=JPt[g],w=_.icon;return e.jsx(Vx,{heading:_.label,children:y.map(j=>e.jsxs(_p,{value:`${j.type}-${j.id}-${j.title}`,onSelect:()=>m(j.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${_.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:j.title}),j.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:j.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Ye,{variant:"secondary",className:"text-xs",children:_.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ql(new Date(j.date),{addSuffix:!0})})]})]},`${j.type}-${j.id}`))},g)})]})]})]})},eIt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=k.useState(null),o=ar();if(k.useEffect(()=>{const u=()=>{const f=new Date().getTime(),y=new Date(t).getTime()-f;if(y<=0){a({days:0,hours:0,minutes:0});return}const _=Math.floor(y/(1e3*60*60*24)),w=Math.floor(y%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(y%(1e3*60*60)/(1e3*60));a({days:_,hours:w,minutes:j})};u();const m=setInterval(u,6e4);return()=>clearInterval(m)},[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:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vd,{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(G,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Pt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":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(mn,{className:Pt("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:Pt("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:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Pt("text-xs",i?"text-destructive/70":c?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(G,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":c?"default":"outline",className:Pt("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(nn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},tIt=()=>{const t=ar();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(Pe,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Et,{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(vd,{className:"h-8 w-8 text-destructive"})}),e.jsx(Lt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(vr,{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(De,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Pe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(De,{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(ur,{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(G,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Pe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(De,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-6 w-6 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),e.jsxs(G,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Nn,{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(rr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},sIt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"icon",onClick:s,className:Pt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Ph,{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(sc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var Pue="Checkbox",[rIt]=od(Pue),[nIt,ANe]=rIt(Pue);function aIt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:c,required:u,value:m="on",internal_do_not_use_render:f}=t,[g,y]=lh({prop:r,defaultProp:a??!1,onChange:c,caller:Pue}),[_,w]=k.useState(null),[j,N]=k.useState(null),S=k.useRef(!1),M=_?!!l||!!_.closest("form"):!0,I={checked:g,disabled:o,setChecked:y,control:_,setControl:w,name:i,form:l,value:m,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:aw(a)?!1:a,isFormControl:M,bubbleInput:j,setBubbleInput:N};return e.jsx(nIt,{scope:s,...I,children:iIt(f)?f(I):n})}var VYe="CheckboxTrigger",HYe=k.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:c,required:u,setControl:m,setChecked:f,hasConsumerStoppedPropagationRef:g,isFormControl:y,bubbleInput:_}=ANe(VYe,t),w=Ka(a,m),j=k.useRef(c);return k.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const S=()=>f(j.current);return N.addEventListener("reset",S),()=>N.removeEventListener("reset",S)}},[o,f]),e.jsx(cn.button,{type:"button",role:"checkbox","aria-checked":aw(c)?"mixed":c,"aria-required":u,"data-state":YYe(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:Or(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Or(r,N=>{f(S=>aw(S)?!0:!S),_&&y&&(g.current=N.isPropagationStopped(),g.current||N.stopPropagation())})})});HYe.displayName=VYe;var ENe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c,onCheckedChange:u,form:m,...f}=t;return e.jsx(aIt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:m,value:c,internal_do_not_use_render:({isFormControl:g})=>e.jsxs(e.Fragment,{children:[e.jsx(HYe,{...f,ref:s,__scopeCheckbox:r}),g&&e.jsx(ZYe,{__scopeCheckbox:r})]})})});ENe.displayName=Pue;var GYe="CheckboxIndicator",WYe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=ANe(GYe,r);return e.jsx(qd,{present:n||aw(o.checked)||o.checked===!0,children:e.jsx(cn.span,{"data-state":YYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});WYe.displayName=GYe;var KYe="CheckboxBubbleInput",ZYe=k.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:c,name:u,value:m,form:f,bubbleInput:g,setBubbleInput:y}=ANe(KYe,t),_=Ka(r,y),w=YO(o),j=RO(n);k.useEffect(()=>{const S=g;if(!S)return;const M=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(M,"checked").set,O=!a.current;if(w!==o&&P){const q=new Event("click",{bubbles:O});S.indeterminate=aw(o),P.call(S,aw(o)?!1:o),S.dispatchEvent(q)}},[g,w,o,a]);const N=k.useRef(aw(o)?!1:o);return e.jsx(cn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:c,name:u,value:m,form:f,...s,tabIndex:-1,ref:_,style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ZYe.displayName=KYe;function iIt(t){return typeof t=="function"}function aw(t){return t==="indeterminate"}function YYe(t){return aw(t)?"indeterminate":t?"checked":"unchecked"}const Mo=k.forwardRef(({className:t,...s},r)=>e.jsx(ENe,{ref:r,className:Pt("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(WYe,{className:Pt("flex items-center justify-center text-current"),children:e.jsx(ua,{className:"h-4 w-4"})})}));Mo.displayName=ENe.displayName;var PNe="Radio",[oIt,QYe]=od(PNe),[lIt,cIt]=oIt(PNe),XYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:c,form:u,...m}=t,[f,g]=k.useState(null),y=Ka(s,j=>g(j)),_=k.useRef(!1),w=f?u||!!f.closest("form"):!0;return e.jsxs(lIt,{scope:r,checked:a,disabled:l,children:[e.jsx(cn.button,{type:"button",role:"radio","aria-checked":a,"data-state":sQe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...m,ref:y,onClick:Or(t.onClick,j=>{a||c==null||c(),w&&(_.current=j.isPropagationStopped(),_.current||j.stopPropagation())})}),w&&e.jsx(tQe,{control:f,bubbles:!_.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});XYe.displayName=PNe;var JYe="RadioIndicator",eQe=k.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=cIt(JYe,r);return e.jsx(qd,{present:n||o.checked,children:e.jsx(cn.span,{"data-state":sQe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});eQe.displayName=JYe;var dIt="RadioBubbleInput",tQe=k.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ka(l,o),c=YO(r),u=RO(s);return k.useEffect(()=>{const m=l.current;if(!m)return;const f=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&y){const _=new Event("click",{bubbles:n});y.call(m,r),m.dispatchEvent(_)}},[c,r,n]),e.jsx(cn.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}})});tQe.displayName=dIt;function sQe(t){return t?"checked":"unchecked"}var uIt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Iue="RadioGroup",[hIt]=od(Iue,[Ow,QYe]),rQe=Ow(),nQe=QYe(),[mIt,pIt]=hIt(Iue),aQe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:c,dir:u,loop:m=!0,onValueChange:f,...g}=t,y=rQe(r),_=Dw(u),[w,j]=lh({prop:o,defaultProp:a??null,onChange:f,caller:Iue});return e.jsx(mIt,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:j,children:e.jsx(Kde,{asChild:!0,...y,orientation:c,dir:_,loop:m,children:e.jsx(cn.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...g,ref:s})})})});aQe.displayName=Iue;var iQe="RadioGroupItem",oQe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=pIt(iQe,r),l=o.disabled||n,i=rQe(r),c=nQe(r),u=k.useRef(null),m=Ka(s,u),f=o.value===a.value,g=k.useRef(!1);return k.useEffect(()=>{const y=w=>{uIt.includes(w.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",y),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",y),document.removeEventListener("keyup",_)}},[]),e.jsx(Zde,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(XYe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:m,onCheck:()=>o.onValueChange(a.value),onKeyDown:Or(y=>{y.key==="Enter"&&y.preventDefault()}),onFocus:Or(a.onFocus,()=>{var y;g.current&&((y=u.current)==null||y.click())})})})});oQe.displayName=iQe;var fIt="RadioGroupIndicator",lQe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=nQe(r);return e.jsx(eQe,{...a,...n,ref:s})});lQe.displayName=fIt;var cQe=aQe,dQe=oQe,xIt=lQe;const INe=k.forwardRef(({className:t,...s},r)=>e.jsx(cQe,{className:Pt("grid gap-2",t),...s,ref:r}));INe.displayName=cQe.displayName;const ile=k.forwardRef(({className:t,...s},r)=>e.jsx(dQe,{ref:r,className:Pt("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(xIt,{className:"flex items-center justify-center",children:e.jsx(jd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ile.displayName=dQe.displayName;const gIt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Fs(),[o,l]=k.useState({}),[i,c]=k.useState({}),[u,m]=k.useState([]);k.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const j=t.polls.map(S=>S.id),{data:N}=await H.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",j);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=(j,N)=>{l(S=>({...S,[j]:N}))},y=(j,N,S)=>{l(M=>{const I=M[j]||[];return S?{...M,[j]:[...I,N]}:{...M,[j]:I.filter(P=>P!==N)}})},_=async j=>{if(!a)return;const N=o[j];if(!N||Array.isArray(N)&&N.length===0){me.error("Please select an option");return}m(S=>[...S,j]);try{await H.from("levelup_brief_poll_responses").delete().eq("poll_id",j).eq("user_id",a.id);const S=Array.isArray(N)?N:[N],M=S.map(P=>({poll_id:j,option_id:P,user_id:a.id})),{error:I}=await H.from("levelup_brief_poll_responses").insert(M);if(I)throw I;c(P=>({...P,[j]:S})),me.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),me.error("Failed to submit response")}finally{m(S=>S.filter(M=>M!==j))}},w=j=>(j.includes("mediadelivery.net")||j.includes("bunny"),j);return e.jsx(fs,{open:s,onOpenChange:j=>!j&&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(Er,{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(Ph,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(Ye,{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(Li,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(j=>e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>window.open(j.url,"_blank"),className:"gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),j.title]},j.id))})]}),t.polls.map(j=>{var M,I;const N=((M=i[j.id])==null?void 0:M.length)>0,S=u.includes(j.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:j.question}),N&&e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(sa,{className:"h-3 w-3"}),"Responded"]})]}),j.poll_type==="single"?e.jsx(INe,{value:o[j.id]||((I=i[j.id])==null?void 0:I[0])||"",onValueChange:P=>g(j.id,P),className:"space-y-2",children:j.options.map(P=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ile,{value:P.id,id:P.id}),e.jsx(ye,{htmlFor:P.id,className:"cursor-pointer",children:P.option_text})]},P.id))}):e.jsx("div",{className:"space-y-2",children:j.options.map(P=>{const q=(o[j.id]||i[j.id]||[]).includes(P.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Mo,{id:P.id,checked:q,onCheckedChange:$=>y(j.id,P.id,$)}),e.jsx(ye,{htmlFor:P.id,className:"cursor-pointer",children:P.option_text})]},P.id)})}),e.jsx(G,{size:"sm",onClick:()=>_(j.id),disabled:S,children:S?"Submitting...":N?"Update Response":"Submit"})]},j.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(G,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(G,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},yIt=()=>{const{user:t}=Fs(),[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:w}=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(w||!_){l(!1);return}const{data:j}=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 $ of S.data){const{data:z}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",$.id).order("sort_order");M.push({...$,options:z||[]})}const I={brief:_,links:N.data||[],polls:M};r(I);const P=!!j,O=(j==null?void 0:j.dismissed_at)!=null,q=localStorage.getItem(`brief-dismissed-${_.id}`)==="true";if(O||q)c(!1),a(!1);else if(!P)a(!0),c(!0);else if(_.show_frequency==="every_login")a(!0),c(!0);else if(_.show_frequency==="daily"){const $=new Date(j.viewed_at);(new Date().getTime()-$.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 m=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),m()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),c(!1);try{const{data:_,error:w}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),_){const{error:j}=await H.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",_.id).eq("user_id",t.id);j&&console.error("Error updating brief dismiss:",j)}else{const{error:j}=await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});j&&console.error("Error inserting brief dismiss:",j)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(_){console.error("Error dismissing brief:",_),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function vIt(){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=y=>{y.preventDefault(),o(y)};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(vi,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),r?e.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",e.jsx(WL,{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(G,{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(Er,{className:"h-4 w-4"})})]})]})}):null}const bIt=({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),m=Qt(),f=80,g=120,y=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 P=S.touches[0].clientY-u.current;if(P>0){const q=Math.min(P*.5,g);o(q),q>10&&S.preventDefault()}},[r,l]),w=k.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await m.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,m]),j=Math.min(a/f,1),N=j*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:y,onTouchMove:_,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:j},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(zo,{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})]})},uQe=()=>{const{user:t}=Fs(),[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:y}=await H.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(y){a(!0),r(!1),c(!1);return}const{data:_}=await H.from("profiles").select("login_count").eq("id",t.id).single(),w=(_==null?void 0:_.login_count)||0;l(w);const j=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!j)}catch(y){console.error("Error checking review eligibility:",y)}finally{c(!1)}})()},[t]);const u=k.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),m=k.useCallback(async(g,y)=>{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:y});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:m,markPostedToGoogle:f}},_It="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",wIt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=uQe(),[o,l]=k.useState(!1),[i,c]=k.useState("review"),[u,m]=k.useState(0),[f,g]=k.useState(0),[y,_]=k.useState(""),[w,j]=k.useState(!1),[N,S]=k.useState(!1);if(s||!t&&!N)return null;const M=async()=>{if(u===0){kn({title:"Please select a rating",variant:"destructive"});return}j(!0);const O=await n(u,y);j(!1),O.success?(S(!0),kn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):kn({title:"Error submitting review",description:O.error,variant:"destructive"})},I=async O=>{O&&(await navigator.clipboard.writeText(y||`${u} star rating for LevelUp!`),kn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(_It,"_blank")),l(!1),r()},P=()=>{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(ea,{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:P,children:e.jsx(ps,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(js,{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:()=>m(O),onMouseEnter:()=>g(O),onMouseLeave:()=>g(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(ea,{className:Pt("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(Tr,{placeholder:"Tell us about your experience (optional)",value:y,onChange:O=>_(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:P,className:"flex-1",children:"Maybe Later"}),e.jsx(G,{onClick:M,disabled:w||u===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{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(G,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(G,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function jIt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const w="vapid_public_key";let j=localStorage.getItem(w);if(!j){const{data:M,error:I}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(j=(M==null?void 0:M.vapidPublicKey)??null,!j)throw new Error("Missing VAPID public key");localStorage.setItem(w,j)}m(j);const N=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});c(N),r(Notification.permission);const S=await N.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}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(I){console.warn("Failed to unsubscribe existing push subscription:",I)}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 w=jIt(u);let j;try{j=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(M){console.error("PushManager.subscribe() failed:",M);const I=(M==null?void 0:M.message)||String(M);return I.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?me.error("Push configuration error. Please contact support."):I.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${I}`),!1}const N=j.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 w=_ instanceof Error?_.message:"Unknown error";me.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[f,i,t,u]),y=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 w=_ instanceof Error?_.message:"Unknown error";return me.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:g,unsubscribe:y}}const uge="push_notification_prompt_dismissed",NIt=["/dashboard","/admin"],kIt=()=>{const{user:t}=Fs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=hQe(),o=hc(),[l,i]=k.useState(!1),[c,u]=k.useState(!1),m=NIt.some(y=>o.pathname===y||o.pathname.startsWith(`${y}/`));k.useEffect(()=>{if(m){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${uge}_${t.id}`))return;const _=setTimeout(()=>{i(!0)},2e3);return()=>clearTimeout(_)},[t,s,r,n,m]);const f=async()=>{u(!0);const y=await a();u(!1),y&&(t&&localStorage.setItem(`${uge}_${t.id}`,"true"),i(!1))},g=()=>{t&&localStorage.setItem(`${uge}_${t.id}`,"true"),i(!1)};return!s||r||m?null:e.jsx(fs,{open:l,onOpenChange:y=>!y&&g(),children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{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(Fm,{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(G,{onClick:f,disabled:c,className:"w-full",children:c?"Enabling...":"Enable Notifications"}),e.jsx(G,{variant:"ghost",onClick:g,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."})]})})},PIe=t=>{let s;const r=new Set,n=(u,m)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const g=s;s=m??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(y=>y(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},SIt=t=>t?PIe(t):PIe,CIt=t=>t;function MIt(t,s=CIt){const r=mt.useSyncExternalStore(t.subscribe,mt.useCallback(()=>s(t.getState()),[t,s]),mt.useCallback(()=>s(t.getInitialState()),[t,s]));return mt.useDebugValue(r),r}const IIe=t=>{const s=SIt(t),r=n=>MIt(s,n);return Object.assign(r,s),r},TIt=t=>t?IIe(t):IIe;function AIt(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 P1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return P1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return P1e(n)(r)}}}},EIt=(t,s)=>(r,n,a)=>{let o={storage:AIt(()=>localStorage),partialize:w=>w,version:0,merge:(w,j)=>({...j,...w}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const m=()=>{const w=o.partialize({...n()});return u.setItem(o.name,{state:w,version:o.version})},f=a.setState;a.setState=(w,j)=>(f(w,j),m());const g=t((...w)=>(r(...w),m()),n,a);a.getInitialState=()=>g;let y;const _=()=>{var w,j;if(!u)return;l=!1,i.forEach(S=>{var M;return S((M=n())!=null?M:g)});const N=((j=o.onRehydrateStorage)==null?void 0:j.call(o,(w=n())!=null?w:g))||void 0;return P1e(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(I=>[!0,I]):[!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[I,P]=S;if(y=o.merge(P,(M=n())!=null?M:g),r(y,!0),I)return m()}).then(()=>{N==null||N(y,void 0),y=n(),l=!0,c.forEach(S=>S(y))}).catch(S=>{N==null||N(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>_(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},o.skipHydration||_(),y||g},PIt=EIt,Lue=TIt()(PIt((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 vE(){const{user:t}=Fs(),{data:s,isLoading:r}=pt({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).order("created_at",{ascending:!0}).limit(1).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 mQe=k.createContext({onlineUsers:[],totalOnline:0}),IIt=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{}},LIt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Fs(),[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 m=u.presenceState(),f=[];Object.entries(m).forEach(([g,y])=>{if(y&&y.length>0){const _=y[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 m=>{var f;if(m==="SUBSCRIBED"){const{data:g}=await H.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),y=await IIt(s.id);await u.track({name:(g==null?void 0:g.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:y,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(mQe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},pQe=()=>k.useContext(mQe),LIe="dashboard-sidebar-collapsed",Ms=({children:t,title:s})=>{var dt;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Fs(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=cje(),{isImpersonating:m}=Gde(),g=(i&&!!c?40:0)+(m?40:0),{avatarUrl:y}=hYe(r==null?void 0:r.id),{isTrial:_,isExpired:w,expiresAt:j}=U6t(r==null?void 0:r.id),{isMarketplaceEnabled:N}=pYe(),{currentBrief:S,shouldShowPopup:M,hasUnseenBrief:I,openBrief:P,closeBrief:O,dismissBrief:q}=yIt(),{unreadCount:$}=V6t(),{openCount:z}=H6t(),{data:V}=Gx(),X=!!V,J=Lue(pe=>pe.cartItems).reduce((pe,Ue)=>pe+Ue.quantity,0),{leadSite:Q,hasLeadSite:ce,siteUrl:ne}=vE(),re=ar(),oe=hc(),[he,xe]=k.useState(null);k.useEffect(()=>{r!=null&&r.id&&H.from("profiles").select("name").eq("id",r.id).single().then(({data:pe})=>{pe!=null&&pe.name&&xe(pe.name)})},[r==null?void 0:r.id]);const ue=he||((dt=r==null?void 0:r.user_metadata)==null?void 0:dt.name)||(r==null?void 0:r.email)||"User",[ge,_e]=k.useState(()=>typeof window<"u"?localStorage.getItem(LIe)==="true":!1);k.useEffect(()=>{localStorage.setItem(LIe,String(ge))},[ge]);const[Be,Se]=k.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Ee=pe=>{Se(Ue=>({...Ue,[pe]:!Ue[pe]}))},Ae=pe=>pe.split(" ").map(Ue=>Ue[0]).join("").toUpperCase().slice(0,2),Me=pe=>oe.pathname===pe,ke=pe=>pe.some(Ue=>oe.pathname===Ue),Oe=({path:pe,icon:Ue,label:Xe,badgeCount:et})=>{const Ce=e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(pe)&&"bg-sidebar-accent text-sidebar-accent-foreground",ge?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>re(pe),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ue,{className:"h-4 w-4 shrink-0"}),ge&&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"})]}),!ge&&Xe,!ge&&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 ge?e.jsxs(kc,{delayDuration:0,children:[e.jsx(Sc,{asChild:!0,children:Ce}),e.jsxs(sc,{side:"right",className:"flex items-center gap-2",children:[Xe,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})]})]}):Ce},qe=({id:pe,label:Ue,icon:Xe,children:et,activePaths:Ce,showBetaBadge:Je,defaultPath:Ge,badgeCount:lt})=>{if(ge){const He=Ge||Ce[0];return e.jsxs(kc,{delayDuration:0,children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ke(Ce)&&"text-primary"),onClick:()=>re(He),children:e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{className:"h-4 w-4"}),lt!=null&<>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(sc,{side:"right",className:"flex items-center gap-2",children:[Ue,Je&&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"}),lt!=null&<>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:lt>9?"9+":lt})]})]})}return e.jsxs(bf,{open:Be[pe],onOpenChange:()=>Ee(pe),children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke(Ce)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Xe,{className:"h-4 w-4"}),Ue,Je&&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:[lt!=null&<>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:lt>9?"9+":lt}),e.jsx(Ji,{className:Pt("h-4 w-4 transition-transform duration-200",Be[pe]&&"rotate-180")})]})]})}),e.jsx(wf,{className:"pl-4 space-y-1 mt-1",children:et})]})},ve=({isMobile:pe=!1})=>{const Ue=pe?!1:ge;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Pt("p-3 border-b border-sidebar-border",Ue?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Ue?e.jsx("img",{src:J6t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:X6t,alt:"LevelUp",className:"h-8 w-auto"}),!pe&&e.jsxs(kc,{delayDuration:0,children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>_e(!Ue),children:e.jsx(tl,{className:Pt("h-4 w-4 transition-transform duration-300",Ue&&"rotate-180")})})}),e.jsx(sc,{side:"right",children:Ue?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Li,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Pt("p-3 space-y-1",Ue&&"flex flex-col items-center"),children:[e.jsx(Oe,{path:"/dashboard",icon:hS,label:"Dashboard"}),e.jsx(Oe,{path:"/apps",icon:dx,label:"Apps & Tools"}),ge?e.jsxs(kc,{delayDuration:0,children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Qh,{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(sc,{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(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Qh,{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(Oe,{path:"/events",icon:Fd,label:"Events"}),e.jsxs(qe,{id:"agentos",label:"Agent OS",icon:BM,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(Oe,{path:"/mission-control",icon:Ja,label:"Mission Control"}),u("contacts")&&!Ue&&e.jsxs(bf,{open:Be.contacts,onOpenChange:()=>Ee("contacts"),children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke(["/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(ur,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Ji,{className:Pt("h-3.5 w-3.5 transition-transform duration-200",Be.contacts&&"rotate-180")})]})}),e.jsxs(wf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Oe,{path:"/mission-control/contacts",icon:ur,label:"All Contacts"}),e.jsx(Oe,{path:"/mission-control/relationship-scorecard",icon:Mh,label:"Relationship Report"}),e.jsx(Oe,{path:"/mission-control/sphere-gaps",icon:HL,label:"Sphere Gaps"}),e.jsx(Oe,{path:"/mission-control/connect-page",icon:pl,label:"Connect Page"})]})]}),u("contacts")&&Ue&&e.jsx(Oe,{path:"/mission-control/contacts",icon:ur,label:"Contacts"}),u("contacts")&&e.jsx(Oe,{path:"/mission-control/plans",icon:Fd,label:"TouchPlans"}),u("pipeline")&&e.jsx(Oe,{path:"/mission-control/pipeline",icon:x0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Oe,{path:"/mission-control/tasks",icon:Wv,label:"Tasks"}),u("popbys")&&e.jsx(Oe,{path:"/mission-control/popbys",icon:bo,label:"Popbys"}),u("videos")&&e.jsx(Oe,{path:"/mission-control/video-library",icon:An,label:"Video Library"}),u("scorecard")&&e.jsx(Oe,{path:"/mission-control/scorecard",icon:co,label:"Scorecard"}),u("listings")&&e.jsx(Oe,{path:"/mission-control/listings",icon:Ta,label:"Listing Exchange"}),!Ue&&e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/mission-control/smart-drips"),children:[e.jsx(Jh,{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"})]}),Ue&&e.jsx(Oe,{path:"/mission-control/smart-drips",icon:Jh,label:"Smart Drips"})]}),ce&&Q&&e.jsxs(qe,{id:"website",label:"My Website",icon:Nd,activePaths:[`/admin/lead-sites/${Q.id}/edit`],defaultPath:`/admin/lead-sites/${Q.id}/edit`,children:[Ue?e.jsxs(kc,{delayDuration:0,children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{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(ne||"#","_blank"),children:e.jsx(Tn,{className:"h-4 w-4"})})}),e.jsx(sc,{side:"right",children:"View Site"})]}):e.jsxs(G,{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(ne||"#","_blank"),children:[e.jsx(Tn,{className:"h-4 w-4"}),"View Site",e.jsx(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Oe,{path:`/my-website/${Q.id}/edit`,icon:Pa,label:"Edit Website"}),e.jsx(Oe,{path:"/my-website/mls-listings",icon:xn,label:"MLS Listings"}),e.jsx(Oe,{path:"/my-website/market-report",icon:co,label:"Market Reports"}),e.jsx(Oe,{path:"/mission-control/website-activity",icon:Mh,label:"Website Activity"}),e.jsx(Oe,{path:"/m",icon:N0,label:"Mobile Command"})]}),e.jsxs(qe,{id:"marketing",label:"Marketing",icon:Ph,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Oe,{path:"/templates",icon:$l,label:"Templates"}),e.jsx(Oe,{path:"/social-swag-2",icon:N0,label:"Social Swag"}),e.jsx(Oe,{path:"/newsletters",icon:x1,label:"Newsletters"})]}),e.jsxs(qe,{id:"learning",label:"Learning",icon:Ah,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Oe,{path:"/academy",icon:Qh,label:"Academy"}),e.jsx(Oe,{path:"/toolbox",icon:ry,label:"Toolbox"})]}),e.jsxs(qe,{id:"community",label:"Community",icon:Ki,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:$,children:[e.jsx(Oe,{path:"/community",icon:ur,label:"Community",badgeCount:$}),e.jsx(Oe,{path:"/wishlist",icon:Q_,label:"Wishlist",badgeCount:z}),!Ue&&e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(qe,{id:"goods",label:"The Goods",icon:bp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!Ue&&e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",oe.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/marketplace"),children:[e.jsx(bp,{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&&Ue&&e.jsx(Oe,{path:"/marketplace",icon:bp,label:"Marketplace"}),e.jsx(Oe,{path:"/reward-store",icon:_o,label:"Reward Store"})]}),e.jsxs(qe,{id:"help",label:"Help & Services",icon:Uv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Oe,{path:"/support",icon:QM,label:"Support"}),e.jsx(Oe,{path:"/additional-services",icon:nn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Ue&&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"})}),Ue?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Oe,{path:"/admin",icon:zd,label:"Admin Dashboard"})}):e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",oe.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/admin"),children:[e.jsx(zd,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Ue&&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"})}),Ue?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(Oe,{path:"/my-brokerage",icon:Ta,label:"My Brokerage"}),e.jsx(Oe,{path:"/brokerage-content",icon:Ah,label:"Brokerage Content"})]}),X&&!o&&e.jsx(Oe,{path:"/my-team",icon:ur,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{path:"/brokerage/dashboard",icon:el,label:"Manage Brokerages"}),e.jsx(Oe,{path:"/brokerage/teams",icon:ur,label:"Teams"}),e.jsx(Oe,{path:"/brokerage/recruiting",icon:Ph,label:"Recruiting"}),e.jsx(Oe,{path:"/brokerage-resources",icon:sh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-brokerage"),children:[e.jsx(Ta,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-content"),children:[e.jsx(Ah,{className:"h-4 w-4"}),"Brokerage Content"]})]}),X&&!o&&e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-team"),children:[e.jsx(ur,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/dashboard"),children:[e.jsx(el,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/teams"),children:[e.jsx(ur,{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(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/recruiting"),children:[e.jsx(Ph,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-resources"),children:[e.jsx(sh,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/profile"),children:[e.jsx(Zi,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(G,{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(fS,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(LIt,{children:e.jsx(W1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[_&&w&&e.jsx(tIt,{}),typeof document<"u"&&vp.createPortal(e.jsx("aside",{className:Pt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",ge?"w-16":"w-56"),style:{top:`${g}px`,height:`calc(100vh - ${g}px)`},children:e.jsx(ve,{})}),document.body),e.jsxs("div",{className:Pt("flex-1 flex flex-col overflow-hidden transition-all duration-300",ge?"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(xE,{children:[e.jsx(yNe,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(gS,{className:"h-5 w-5"})})}),e.jsx(P3,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(ve,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:ePt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(EIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[_&&!w&&j&&e.jsx(eIt,{expiresAt:j,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(EIe,{})}),S&&e.jsx(sIt,{hasUnseenBrief:I,onClick:P}),N&&e.jsxs(G,{variant:"ghost",size:"icon",className:"relative",onClick:()=>re("/marketplace/cart"),children:[e.jsx(bp,{className:"h-5 w-5"}),J>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:J>99?"99+":J})]}),e.jsx(SPt,{}),e.jsx(T1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",ue.split(" ")[0],"!"]}),e.jsxs(du,{children:[e.jsx(uu,{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(Cn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Wa,{src:y||void 0}),e.jsx(Mn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ae(ue)})]})})}),e.jsxs(Ud,{align:"end",className:"w-48",children:[e.jsxs(La,{onClick:()=>re("/profile"),className:"cursor-pointer",children:[e.jsx(Zi,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(La,{onClick:()=>re("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(FL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(yw,{}),e.jsxs(La,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(fS,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(bIt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(gIt,{brief:S,open:M,onClose:O,onDismiss:q}),e.jsx(vIt,{}),e.jsx(wIt,{}),e.jsx(kIt,{})]})]})})})},DIt=()=>{const{user:t}=Fs(),[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:y,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(y!=null&&y.url)window.open(y.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(y){console.error("Checkout error:",y),me.error(y.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"],m=["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(ye,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Le,{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(Pe,{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(Et,{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(ur,{className:"h-7 w-7 text-primary"})}),e.jsx(Lt,{className:"text-xl",children:"Individual Agent"}),e.jsx(vr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(De,{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(ua,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(G,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Et,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Lt,{className:"text-xl",children:"Brokerage"}),e.jsx(vr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(De,{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(ua,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(G,{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(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Et,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Lt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(vr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(De,{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:m.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ua,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(G,{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(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Pe,{className:"bg-muted/50",children:e.jsxs(De,{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(Nn,{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(rr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},OIt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Fs(),a=ar(),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,m]=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(),y=g.session;if(!t||!y){me.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!y,userId:t==null?void 0:t.id});const{data:_,error:w}=await H.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:_,error:w}),w)throw w;if(!(_!=null&&_.ok))throw new Error((_==null?void 0:_.error)||"Failed to create brokerage");c(!1),m(!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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Et,{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(ys,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Lt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(vr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(wi,{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(ys,{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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Et,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Ta,{className:"w-10 h-10 text-primary"})}),e.jsx(Lt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(vr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Le,{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(ur,{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(wi,{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(wi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(wi,{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(wi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(G,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(ba,{className:"w-4 h-4 ml-2"})]})]})]})})},DIe=()=>{const t=ar(),[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(m){console.log("Trial claim hook (non-critical):",m)}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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{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(Lt,{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(vr,{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(De,{children:e.jsx(G,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},RIt=()=>{const t=ar(),[s]=Ul(),[r,n]=k.useState(s.get("code")||""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[m,f]=k.useState(!1),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(!1),[S,M]=k.useState(null),[I,P]=k.useState(null),[O,q]=k.useState(null),[$,z]=k.useState(null);k.useEffect(()=>{const J=s.get("code");J&&(n(J),V(J))},[s]);const V=async J=>{w(!0);const{data:Q,error:ce}=await H.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",J.toUpperCase().trim()).single();if(ce||!Q){me.error("Invalid invite code"),w(!1);return}if(!Q.is_active){me.error("This invite code is no longer active"),w(!1);return}if(Q.max_uses&&Q.uses_count>=Q.max_uses){me.error("This invite code has reached its maximum uses"),w(!1);return}if(Q.expires_at&&new Date(Q.expires_at){J.preventDefault(),V(r)},Y=async J=>{var Q;if(J.preventDefault(),!c.trim()){me.error("Please enter your name");return}if(l.length<6){me.error("Password must be at least 6 characters");return}y(!0);try{const ce=`${window.location.origin}/`,{data:ne,error:re}=await H.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:c.trim()}}});if(re){re.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(re.message);return}ne.user&&(await H.rpc("add_default_signup_tag",{user_id:ne.user.id}),I?await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,brokerageId:I}}):$?await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,trialDays:$}}):await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,grandfathered:!0}}),S&&await H.from("invite_codes").update({uses_count:((Q=(await H.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:Q.uses_count)+1}).eq("id",S),me.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),me.error("An unexpected error occurred")}finally{y(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[e.jsx(Lt,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(vr,{children:j?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(De,{children:j?e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Full Name"}),e.jsx(Le,{id:"name",type:"text",placeholder:"John Doe",value:c,onChange:J=>u(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:J=>o(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{id:"password",type:m?"text":"password",placeholder:"••••••••",value:l,onChange:J=>i(J.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(!m),children:m?e.jsx(Cp,{className:"h-4 w-4"}):e.jsx(Tn,{className:"h-4 w-4"})})]})]}),e.jsx(G,{type:"submit",className:"w-full",disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Le,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:J=>n(J.target.value),required:!0,autoFocus:!0})]}),e.jsx(G,{type:"submit",className:"w-full",disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},FIt="/assets/testimonial-avatar-1-BsCQFauB.jpg",zIt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",BIt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",$It="/assets/testimonial-avatar-4-98iKMtkB.jpg",qIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",UIt=[FIt,zIt,BIt,$It,qIt],VIt=A3({name:wc().trim().min(2,"Name must be at least 2 characters").max(100),email:wc().trim().email("Please enter a valid email address").max(255),phone:wc().trim().min(10,"Please enter a valid phone number").max(20).optional().or(Uoe("")),brokerage:wc().trim().max(200).optional().or(Uoe(""))}),HIt=[{icon:fp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:$l,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:fn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Uc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:wn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:bo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],GIt=[{icon:ur,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:nn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Nn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Eh,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:aa,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:co,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ja,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Jh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],WIt=[{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."}],KIt=()=>{const t=ar(),[s,r]=k.useState(!1),[n,a]=k.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=k.useState({}),i=async c=>{var m,f;c.preventDefault(),l({});const u=VIt.safeParse(n);if(!u.success){const g={};u.error.errors.forEach(y=>{y.path[0]&&(g[y.path[0]]=y.message)}),l(g);return}r(!0);try{const{data:g,error:y}=await H.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((m=n.phone)==null?void 0:m.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(y){console.error("Trial signup error:",y),me.error(y.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(Pl,{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:tle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(G,{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(G,{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(nn,{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:UIt.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(ea,{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(Pe,{className:"bg-white shadow-2xl border-0",children:e.jsxs(De,{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(_0,{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(ye,{htmlFor:"name",children:"Full Name *"}),e.jsx(Le,{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(ye,{htmlFor:"email",children:"Email Address *"}),e.jsx(Le,{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(ye,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Le,{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(ye,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Le,{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(G,{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(ys,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(ba,{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:HIt.map((c,u)=>e.jsxs(Pe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Et,{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(Lt,{className:"text-xl font-sans",children:c.title})]}),e.jsx(De,{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(nn,{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:GIt.map((c,u)=>e.jsxs(Pe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Et,{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(Lt,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(De,{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:WIt.map((c,u)=>e.jsx(Pe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(De,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(m=>e.jsx(ea,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},m))}),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(ou,{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(Jh,{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(ur,{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(Pe,{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(De,{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(G,{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(ba,{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:jje,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."})]})})})]})]})},ZIt=()=>{const t=ar();return e.jsxs(e.Fragment,{children:[e.jsx(Pl,{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:tle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(G,{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(Pe,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(De,{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(iu,{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(rr,{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(G,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(ba,{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:jje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},YIt=A3({viewerName:wc().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:wc().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:wc().max(20,"Phone must be less than 20 characters").optional(),message:wc().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function QIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),u=Cue({resolver:Mue(YIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),m=async f=>{a(!0),c(null);try{const{data:g,error:y}=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(y)throw new Error(y.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(Pe,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Uc,{className:"h-5 w-5 text-primary"}),e.jsx(Lt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(vr,{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(De,{children:e.jsx(Tue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(m),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Yc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Your Name *"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"John Smith",...f})}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Email *"}),e.jsx(Fc,{children:e.jsx(Le,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Em,{})]})})]}),!r&&e.jsx(Yc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Phone (optional)"}),e.jsx(Fc,{children:e.jsx(Le,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Message *"}),e.jsx(Fc,{children:e.jsx(Tr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Em,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(G,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const XIt=()=>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(ea,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(ea,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(ea,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(ea,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(ea,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(m1,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),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-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(nn,{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(ea,{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(nn,{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(ea,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(ea,{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(m1,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),eLt=()=>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(Zg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Zg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Zg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Zg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Ja,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Ja,{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(Ja,{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"})]}),tLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(rc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(ea,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(ea,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(ea,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),sLt=()=>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(Zg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Zg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(VM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),rLt=()=>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(lS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(lS,{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(nn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(nn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),nLt=()=>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(S0,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(S0,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(S0,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(l0,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(l0,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(l0,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(l0,{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(ea,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),aLt=()=>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(Ja,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Ja,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),iLt=()=>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(ea,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(ea,{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(ea,{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(ea,{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(nn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(iu,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(iu,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),oLt=()=>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(ea,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(nn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(nn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),lLt=()=>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(s1,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(s1,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(s1,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(s1,{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"})]})]})]}),cLt=()=>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(ea,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(ea,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(rc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(m1,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),dLt=()=>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(Eh,{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(iu,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(bo,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),uLt=()=>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(Ja,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Ja,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Ja,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Ja,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Ja,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Ja,{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(Ja,{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(Ja,{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"})]}),hLt=()=>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(b1,{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(b1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(nn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(b1,{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"})]}),mLt=()=>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(xn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(xn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Mp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Mp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Ja,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Ja,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(nn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(iu,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),pLt=()=>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(iu,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(iu,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Mp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(xn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(nn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(nn,{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"})]}),fLt=()=>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(Mp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Mp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Mp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(xn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(iu,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(nn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(ea,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),xLt=()=>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(xn,{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(Mp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Ja,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(nn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(u1,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),OIe=()=>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"})]}),gLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Ja,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Ja,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Ja,{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(Ja,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),yLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(u1,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(nn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(xn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),vLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(aS,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(JM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(aS,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),mI=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(nn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(iu,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(nn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),RIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(xn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(nn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(xn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),I1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(nn,{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(Ja,{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(gLt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(xL,{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(mI,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(aS,{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(vLt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(co,{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(ur,{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(mI,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(OIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(aa,{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(RIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(JM,{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(mI,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Eh,{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(dLt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Ja,{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(uLt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(b1,{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(hLt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(ea,{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(iLt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(VM,{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(sLt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Zg,{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(eLt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(tLt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(m1,{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(XIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(rh,{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(JIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(cLt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(lS,{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(rLt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Ja,{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(aLt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(S0,{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(nLt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(nn,{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(oLt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(s1,{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(lLt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(xn,{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(mLt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(iu,{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(pLt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(fn,{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(RIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(ml,{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(mI,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(CS,{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(u1,{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(yLt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Mp,{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(fLt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(xn,{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(xLt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(ah,{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(mI,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(OIe,{})}],bLt=[{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 _Lt(t){return I1e.filter(s=>s.category===t)}function pT(t){return I1e.find(s=>s.id===t)||I1e[0]}function FIe(){const{shareToken:t,recipientToken:s}=ao(),[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!0),[m,f]=k.useState(null),[g,y]=k.useState(!0),_=k.useRef(null),w=k.useRef(0),j=k.useRef(0),N=(()=>{const Y=new URLSearchParams(window.location.search);return s||Y.get("rt")||null})(),S=k.useCallback((Y,J=!1)=>{if(!N||Y<=0)return;const Q=Math.max(1,Math.round(Y));if(Q<=j.current)return;const ne=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${Q}`;J&&navigator.sendBeacon?navigator.sendBeacon(ne):fetch(ne,{method:"GET",keepalive:J}).catch(()=>{}),j.current=Math.max(j.current,Q)},[N]);k.useEffect(()=>{var oe;if(!g||!(r!=null&&r.playback_url)||!N)return;let Y=!1;const J=()=>{w.current>0&&S(w.current,!0)},Q=()=>{document.visibilityState==="hidden"&&J()},ce=()=>{J()},ne=()=>{var xe;if(Y||!_.current||!((xe=window.playerjs)!=null&&xe.Player))return;const he=new window.playerjs.Player(_.current);he.on("timeupdate",ue=>{const ge=Math.floor(Number((ue==null?void 0:ue.seconds)??0));!Number.isFinite(ge)||ge<=0||(w.current=Math.max(w.current,ge))}),he.on("pause",()=>{w.current>0&&S(w.current)}),he.on("ended",()=>{w.current>0&&S(w.current,!0)})},re=document.querySelector('script[data-bunny-playerjs="true"]');if((oe=window.playerjs)!=null&&oe.Player)ne();else if(re)re.addEventListener("load",ne,{once:!0});else{const he=document.createElement("script");he.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",he.async=!0,he.defer=!0,he.dataset.bunnyPlayerjs="true",he.onload=ne,document.body.appendChild(he)}return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",ce),()=>{Y=!0,document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",ce),J()}},[g,r==null?void 0:r.playback_url,N,S]),k.useEffect(()=>{w.current=0,j.current=0},[N,t]),k.useEffect(()=>{const Y=()=>{['[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(ne=>{document.querySelectorAll(ne).forEach(re=>{re.style.display="none"})})};Y();const J=[setTimeout(Y,500),setTimeout(Y,1500),setTimeout(Y,3e3)],Q=new MutationObserver(Y);return Q.observe(document.body,{childList:!0,subtree:!0}),()=>{J.forEach(clearTimeout),Q.disconnect()}},[]),k.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:J,error:Q}=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(Q||!J){f("Video not found or has been removed"),u(!1);return}n(J);try{await H.rpc("log_video_view",{p_video_id:J.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ce){console.warn("Failed to log video view:",ce)}if(J.owner_user_id){const{data:ce}=await H.from("profiles").select("id, name, email, phone").eq("id",J.owner_user_id).single();if(ce){o(ce);try{const{data:ne}=await H.storage.from("avatars").list(`${J.owner_user_id}`);if(ne&&ne.length>0){const{data:re}=H.storage.from("avatars").getPublicUrl(`${J.owner_user_id}/${ne[0].name}`);i(re.publicUrl)}}catch{}}}u(!1)})()},[t]);const M=Y=>{if(!Y)return"0:00";const J=Math.floor(Y/60),Q=Y%60;return`${J}:${Q.toString().padStart(2,"0")}`},I=Y=>Y.includes("iframe.mediadelivery.net/play/")?Y.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Y,P=Y=>{if(!Y)return"?";const J=Y.split(" ");return J.length>=2?`${J[0][0]}${J[1][0]}`.toUpperCase():Y.substring(0,2).toUpperCase()},O=pT((r==null?void 0:r.page_template)||"default"),q=(r==null?void 0:r.recipient_name)||null,$=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(ys,{className:"h-8 w-8 animate-spin text-primary"})});if(m||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Pe,{className:"max-w-md w-full",children:e.jsxs(De,{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:m||"This video is no longer available."})]})})});const X=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{children:[e.jsx("title",{children:$}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:$}),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:$}),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:Pt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[X&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[X&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:Pt("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:$}),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(Cn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Wa,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(Mn,{className:"bg-primary/10 text-primary font-semibold",children:P(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:X?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(G,{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(Nn,{className:"h-4 w-4"})})}),a.email&&e.jsx(G,{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(rr,{className:"h-4 w-4"})})})]})]}),e.jsx(Pe,{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:I(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>y(!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:Y=>{var Q;Y.currentTarget.style.display="none";const J=(Q=Y.currentTarget.parentElement)==null?void 0:Q.querySelector(".video-fallback");J&&(J.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(sl,{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)})]})}),!X&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(G,{size:"lg",onClick:()=>y(!0),className:"gap-2",children:[e.jsx(sl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(QIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function wLt(){return k.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(K1t,{})}function jLt(){const{token:t}=ao();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(ys,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}var Due="Tabs",[NLt]=od(Due,[Ow]),fQe=Ow(),[kLt,LNe]=NLt(Due),xQe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,m=Dw(i),[f,g]=lh({prop:n,onChange:a,defaultProp:o??"",caller:Due});return e.jsx(kLt,{scope:r,baseId:Iu(),value:f,onValueChange:g,orientation:l,dir:m,activationMode:c,children:e.jsx(cn.div,{dir:m,"data-orientation":l,...u,ref:s})})});xQe.displayName=Due;var gQe="TabsList",yQe=k.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=LNe(gQe,r),l=fQe(r);return e.jsx(Kde,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(cn.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});yQe.displayName=gQe;var vQe="TabsTrigger",bQe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=LNe(vQe,r),i=fQe(r),c=jQe(l.baseId,n),u=NQe(l.baseId,n),m=n===l.value;return e.jsx(Zde,{asChild:!0,...i,focusable:!a,active:m,children:e.jsx(cn.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:s,onMouseDown:Or(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Or(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Or(t.onFocus,()=>{const f=l.activationMode!=="manual";!m&&!a&&f&&l.onValueChange(n)})})})});bQe.displayName=vQe;var _Qe="TabsContent",wQe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=LNe(_Qe,r),c=jQe(i.baseId,n),u=NQe(i.baseId,n),m=n===i.value,f=k.useRef(m);return k.useEffect(()=>{const g=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(qd,{present:a||m,children:({present:g})=>e.jsx(cn.div,{"data-state":m?"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})})});wQe.displayName=_Qe;function jQe(t,s){return`${t}-trigger-${s}`}function NQe(t,s){return`${t}-content-${s}`}var SLt=xQe,kQe=yQe,SQe=bQe,CQe=wQe;const ga=SLt,fa=k.forwardRef(({className:t,...s},r)=>e.jsx(kQe,{ref:r,className:Pt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));fa.displayName=kQe.displayName;const ss=k.forwardRef(({className:t,...s},r)=>e.jsx(SQe,{ref:r,className:Pt("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));ss.displayName=SQe.displayName;const bs=k.forwardRef(({className:t,...s},r)=>e.jsx(CQe,{ref:r,className:Pt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));bs.displayName=CQe.displayName;const CLt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},MLt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},R5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function TLt(){var Be,Se,Ee,Ae;const{slugOrId:t}=ao(),[s]=Ul(),{data:r,isLoading:n}=TWe(t||""),a=AWe(),o=zkt(),l=s.get("ref"),[i,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(""),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState(""),[P,O]=k.useState("in_person"),[q,$]=k.useState("info"),[z,V]=k.useState(!1),[X,Y]=k.useState(!1),[J,Q]=k.useState(null),[ce,ne]=k.useState(!1);k.useEffect(()=>{l&&o.mutate(l)},[l]);const re=Me=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Me),oe=async Me=>{if(Me.preventDefault(),!i.trim()||!f.trim()||!r)return;const ke=q==="showing";if(ke&&!N){me.error("Please pick a preferred date for your showing");return}V(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:y.trim(),shareToken:l,leadType:ke?"showing_request":"info_request",preferredDate:ke?N:null,preferredTime:ke&&M||null,showingMode:ke?P:null,message:w.trim()||null}),Y(!0),me.success(ke?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(Oe){console.error("Lead submission error:",Oe),me.error(`Failed to submit: ${Oe.message||"Please try again"}`)}finally{V(!1)}},he=(r==null?void 0:r.photos)||[],xe=he.find(Me=>Me.is_primary)||he[0],ue=()=>{J!==null&&Q(J===0?he.length-1:J-1)},ge=()=>{J!==null&&Q(J===he.length-1?0:J+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(ws,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ws,{className:"h-10 w-48 mb-6"}),e.jsx(ws,{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(ws,{className:"h-12 w-48"}),e.jsx(ws,{className:"h-6 w-full"}),e.jsx(ws,{className:"h-6 w-3/4"})]}),e.jsx(ws,{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(la,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Ooe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(xn,{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(G,{asChild:!0,children:e.jsx(la,{to:"/public/listings",children:"Browse All Listings"})})]})]});const _e=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(Pl,{children:[e.jsxs("title",{children:[_e," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${re(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${R5[r.property_type]} in ${r.city}, ${r.state}. ${((Be=r.description)==null?void 0:Be.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:_e}),e.jsx("meta",{property:"og:description",content:`${re(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${R5[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}`}),xe&&e.jsx("meta",{property:"og:image",content:xe.photo_url}),xe&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${R5[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:_e}),e.jsx("meta",{name:"twitter:description",content:`${re(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),xe&&e.jsx("meta",{name:"twitter:image",content:xe.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||`${R5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:he.map(Me=>Me.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:(Se=r.agent.brokerage)!=null&&Se.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(la,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Ooe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(la,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),he.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:()=>Q(0),children:e.jsx("img",{src:xe==null?void 0:xe.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${R5[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:he.slice(1,5).map((Me,ke)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>Q(ke+1),children:[e.jsx("img",{src:Me.photo_url,alt:`${r.property_address||r.city} - Photo ${ke+2} of ${he.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ke===3&&he.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",he.length-5," more"]})]},Me.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(Ye,{className:`${CLt[r.status]} text-white border-0`,children:MLt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:re(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(aa,{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(Th,{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(au,{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(k0,{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(fn,{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(Ye,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),R5[r.property_type]]}),r.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(Ye,{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(G,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Pe,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(De,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>ne(!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(sl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(G,{onClick:()=>ne(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(sl,{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(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Zi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(De,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((Ee=r.agent.brokerage)==null?void 0:Ee.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Et,{className:"pb-3",children:e.jsx(Lt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(De,{children:X?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(rr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:q==="showing"?"Showing request sent!":"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q==="showing"?"The listing agent will reach out to confirm your showing time.":"The listing agent will contact you soon."})]}):e.jsxs(ga,{value:q,onValueChange:Me=>$(Me),children:[e.jsxs(fa,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(ss,{value:"info",className:"gap-1.5",children:[e.jsx(rr,{className:"h-3.5 w-3.5"}),"Get Info"]}),e.jsxs(ss,{value:"showing",className:"gap-1.5",children:[e.jsx($M,{className:"h-3.5 w-3.5"}),"Request Tour"]})]}),e.jsxs("form",{onSubmit:oe,className:"space-y-3",children:[e.jsxs(bs,{value:"showing",className:"mt-0 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"preferredDate",children:"Preferred Date *"}),e.jsx(Le,{id:"preferredDate",type:"date",value:N,onChange:Me=>S(Me.target.value),min:new Date().toISOString().split("T")[0],required:q==="showing"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"preferredTime",children:"Preferred Time"}),e.jsxs(Rs,{value:M,onValueChange:I,children:[e.jsx(Ls,{id:"preferredTime",children:e.jsx($s,{placeholder:"Any time"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"morning",children:"Morning (9am–12pm)"}),e.jsx(ft,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),e.jsx(ft,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"showingMode",children:"Tour Type"}),e.jsxs(Rs,{value:P,onValueChange:Me=>O(Me),children:[e.jsx(Ls,{id:"showingMode",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"in_person",children:"🏡 In-person showing"}),e.jsx(ft,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),e.jsx(ft,{value:"either",children:"Either works for me"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Le,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:Me=>c(Me.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Le,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:Me=>m(Me.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email *"}),e.jsx(Le,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:Me=>g(Me.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(ye,{htmlFor:"phone",children:["Phone ",q==="showing"&&"*"]}),e.jsx(Le,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:y,onChange:Me=>_(Me.target.value),required:q==="showing"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"message",children:q==="showing"?"Anything else?":"Message (optional)"}),e.jsx(Tr,{id:"message",placeholder:q==="showing"?"e.g. I have flexibility on weekends":"Any specific questions about the property?",value:w,onChange:Me=>j(Me.target.value),rows:2})]}),e.jsx(G,{type:"submit",className:"w-full",disabled:z,children:z?"Submitting...":q==="showing"?"Request Showing":"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:J!==null,onOpenChange:()=>Q(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{className:"sr-only",children:e.jsx(vs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>Q(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(Er,{className:"h-5 w-5"})}),J!==null&&he[J]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:he[J].photo_url,alt:`Photo ${J+1}`,className:"w-full max-h-[80vh] object-contain"}),he.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:ue,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(tl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:ge,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:[J+1," / ",he.length]})]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ne,children:e.jsxs(ps,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(js,{className:"sr-only",children:e.jsx(vs,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>ne(!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(Er,{className:"h-5 w-5"})}),((Ae=r==null?void 0:r.video)==null?void 0:Ae.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function ALt(){var o;const{slug:t}=ao(),{data:s,isLoading:r,error:n}=LWe(t);if(k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),k.useEffect(()=>{s!=null&&s.id&&vo(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(ws,{className:"h-28 w-28 rounded-full"}),e.jsx(ws,{className:"h-6 w-48"}),e.jsx(ws,{className:"h-4 w-36"})]}),e.jsx(ws,{className:"h-12 w-full"}),e.jsx(ws,{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(Pl,{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(kje,{card:s})]})}function MQe({slugOverride:t}={}){var Ce;const{slug:s}=ao(),r=t||s,[n]=Ul(),a=n.get("t"),[o,l]=k.useState(!0),[i,c]=k.useState(null),[u,m]=k.useState(null),f=k.useRef(null),g=k.useRef(null),[y,_]=k.useState(null),[w,j]=k.useState(null),[N,S]=k.useState(!1),[M,I]=k.useState(!1),[P,O]=k.useState(0),[q,$]=k.useState(!1),[z,V]=k.useState(""),[X,Y]=k.useState(""),[J,Q]=k.useState(""),[ce,ne]=k.useState(""),[re,oe]=k.useState(""),[he,xe]=k.useState(""),[ue,ge]=k.useState(""),[_e,Be]=k.useState(""),[Se,Ee]=k.useState(""),[Ae,Me]=k.useState(""),[ke,Oe]=k.useState(""),[qe,ve]=k.useState("");k.useEffect(()=>{dt()},[r,a]);const dt=async()=>{if(!r)return;l(!0);const{data:Je,error:Ge}=await H.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(Ge||!Je){$(!0),l(!1);return}m(Je),g.current=Je;const{data:lt}=await H.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",Je.user_id).single();if(lt){let He;if(lt.brokerage_id){const{data:Ke}=await H.from("brokerages").select("name").eq("id",lt.brokerage_id).single();He=(Ke==null?void 0:Ke.name)||void 0}let We=lt.avatar_url||null;if(!We){const{data:Ke}=H.storage.from("avatars").getPublicUrl(`${Je.user_id}/avatar.jpg`);Ke!=null&&Ke.publicUrl&&(We=`${Ke.publicUrl}?t=${Date.now()}`)}const tt={...lt,avatar_url:We,brokerage_name:He};c(tt),f.current=tt}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",Je.id);const{data:He,error:We}=await H.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:Je.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:He,resolveErr:We}),!We&&(He!=null&&He.contact_id)){j(He.contact_id);const tt=He.contact;tt&&(_(tt),V(tt.first_name||""),Y(tt.last_name||""),Q(tt.email||""),ne(tt.phone||""),oe(tt.address||""),xe(tt.city||""),ge(tt.state||""),Be(tt.zip||""),Ee(tt.birthday||""),Me(tt.home_anniversary||""))}}catch(He){console.error("Failed to resolve token:",He)}l(!1)},pe=async()=>{var Je,Ge;if(!z.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}I(!0);try{let lt=(Je=g.current)==null?void 0:Je.id,He=(Ge=g.current)==null?void 0:Ge.user_id;if(!lt||!He){const{data:tt}=await H.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!tt){me.error("This page is no longer active. Please contact the agent directly."),I(!1);return}lt=tt.id,He=tt.user_id}const{error:We}=await H.from("contact_intake_submissions").insert({intake_page_id:lt,agent_user_id:He,existing_contact_id:w,first_name:z.trim(),last_name:X.trim()||null,email:J.trim()||null,phone:ce.trim()||null,address:re.trim()||null,city:he.trim()||null,state:ue.trim()||null,zip:_e.trim()||null,birthday:Se||null,home_anniversary:Ae||null,real_estate_interest:ke||null,message:qe.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:We}),We)throw We;a&&await H.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const tt=[z.trim(),X.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:He,contactName:tt,contactEmail:J.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(tt){console.warn("Connect page notification failed (non-blocking):",tt)}S(!0)}catch(lt){console.error(lt),me.error("Something went wrong. Please try again.")}finally{I(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(ys,{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(Pl,{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(Ja,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Ue=!!a&&!!y,Xe=3,et=[{title:Ue?"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:z,onChange:Je=>V(Je.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:X,onChange:Je=>Y(Je.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:J,onChange:Je=>Q(Je.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:ce,onChange:Je=>ne(Je.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:re,onChange:Je=>oe(Je.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:he,onChange:Je=>xe(Je.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:Je=>ge(Je.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:Je=>Be(Je.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:Se,onChange:Je=>Ee(Je.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:Ae,onChange:Je=>Me(Je.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(Je=>e.jsxs("button",{type:"button",onClick:()=>Oe(ke===Je.value?"":Je.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${ke===Je.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:Je.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:Je.desc})]},Je.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:qe,onChange:Je=>ve(Je.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(Pl,{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:((Ce=i==null?void 0:i.name)==null?void 0:Ce.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(Nn,{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(rr,{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:Xe}).map((Je,Ge)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${Ge<=P?"bg-blue-500":"bg-slate-200"}`},Ge))}),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(pNe,{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(nn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:et[P].title})]}),et[P].fields]},P)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[P>0?e.jsx("button",{type:"button",onClick:()=>O(Je=>Je-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",{}),P{if(P===0&&!z.trim()){me.error("Please enter your first name");return}O(Je=>Je+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:()=>pe(),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(ys,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),P>0&&PO(Je=>Je+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(Ja,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}const bE=()=>({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)}},[])});function pI({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=k.useState(0),[o,l]=k.useState(!1),{trackEngagement:i}=bE(),c=k.useCallback(y=>{i("newsletter",y.id,y.title,"click_link")},[i]),u=k.useCallback(()=>{a(y=>(y+1)%t.length)},[t.length]),m=k.useCallback(()=>{a(y=>(y-1+t.length)%t.length)},[t.length]),f=k.useCallback(y=>{a(y)},[]);if(k.useEffect(()=>{if(t.length<=1||o)return;const y=setInterval(u,s);return()=>clearInterval(y)},[t.length,o,s,u]),!t||t.length===0)return null;const g=t[n];return e.jsxs("div",{className:Pt("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:g.image_url,alt:g.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"ghost",size:"icon",className:Pt("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:m,children:e.jsx(tl,{className:"h-6 w-6"})}),e.jsx(G,{variant:"ghost",size:"icon",className:Pt("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:u,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((y,_)=>e.jsx("button",{onClick:()=>f(_),className:Pt("w-2 h-2 rounded-full transition-all duration-300",_===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${_+1}`},_))})]}),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:g.title}),g.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:g.description})]}),g.link_url&&e.jsx("a",{href:g.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",onClick:()=>c(g),children:e.jsx(G,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:g.link_text||"Learn More"})})]})]})}function ELt(t){return"EST"}function jD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=ELt();return`${r} ${n}`}function fT(t){const s=new Date,r=new Date(t),n=bM(r,-15),a=bM(r,30);return s>a?"ended":$g(s,{start:r,end:a})?"live":$g(s,{start:n,end:r})?"starting_soon":"upcoming"}function DNe(t){const s=fT(t);return s==="starting_soon"||s==="live"}const zIe=DNe,PLt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=k.useState(new Date);k.useEffect(()=>{const y=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(y)},[]);const o=t.filter(y=>DNe(y.event_date));if(o.length===0)return null;const l=o[0],i=fT(l.event_date),c=s.find(y=>y.event_id===l.id),u=(c==null?void 0:c.zoom_join_url)||l.zoom_link,m=!!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(y1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{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 ${jD(new Date(l.event_date))}`:`Starts at ${jD(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:m?e.jsxs(G,{onClick:()=>window.open(u,"_blank"),className:`${g.button} text-white gap-2`,children:[e.jsx(rn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(G,{variant:"outline",onClick:r,className:`${g.outlineButton} gap-2`,children:[e.jsx(ur,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var ONe="Progress",RNe=100,[ILt]=od(ONe),[LLt,DLt]=ILt(ONe),TQe=k.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=OLt,...l}=t;(a||a===0)&&!BIe(a)&&console.error(RLt(`${a}`,"Progress"));const i=BIe(a)?a:RNe;n!==null&&!$Ie(n,i)&&console.error(FLt(`${n}`,"Progress"));const c=$Ie(n,i)?n:null,u=ole(c)?o(c,i):void 0;return e.jsx(LLt,{scope:r,value:c,max:i,children:e.jsx(cn.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":ole(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":PQe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});TQe.displayName=ONe;var AQe="ProgressIndicator",EQe=k.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=DLt(AQe,r);return e.jsx(cn.div,{"data-state":PQe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});EQe.displayName=AQe;function OLt(t,s){return`${Math.round(t/s*100)}%`}function PQe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function ole(t){return typeof t=="number"}function BIe(t){return ole(t)&&!isNaN(t)&&t>0}function $Ie(t,s){return ole(t)&&!isNaN(t)&&t<=s&&t>=0}function RLt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${RNe}\`.`}function FLt(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 ${RNe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var IQe=TQe,zLt=EQe;const qi=k.forwardRef(({className:t,value:s,...r},n)=>e.jsx(IQe,{ref:n,className:Pt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(zLt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));qi.displayName=IQe.displayName;function BLt(){const{user:t,isBrokerageManager:s}=Fs(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),[c,u]=k.useState(!0),m=s?"brokerage_manager":"agent";k.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,m]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:P}=await H.from("onboarding_checklist_items").select("*").eq("target_role",m).eq("is_active",!0).order("sort_order");if(P)throw P;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:$,error:z}=await H.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(z)throw z;n(I||[]),o(O||[]),i(!!$),I&&I.length>0&&await g(I,O||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},g=async(I,P)=>{var Me,ke;if(!(t!=null&&t.id))return;const O=P.map(Oe=>Oe.item_id),q=I.filter(Oe=>!O.includes(Oe.id));if(q.length===0)return;const[$,z,V,X,Y,J,Q,ce,ne,re,oe,he,xe,ue,ge]=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={},Be=(Me=$.data)==null?void 0:Me.brokerage_id;_e.share_resource=(z.count||0)>0,_e.post_community=(V.count||0)>0,_e.register_event=(X.count||0)>0,_e.view_template=(Y.count||0)>0,_e.watch_academy=(J.count||0)>0,_e.use_toolbox=(Q.count||0)>0,_e.launch_app=(ce.count||0)>0,_e.add_contact=(ne.count||0)>0,_e.create_video=(re.count||0)>0,_e.complete_touch=(oe.count||0)>0,_e.add_transaction=(he.count||0)>0,_e.add_listing=(xe.count||0)>0,_e.add_deal=(ge.count||0)>0;const Se=((ke=ue.data)==null?void 0:ke.map(Oe=>Oe.id))||[],Ee=[];Be?Ee.push(H.from("profiles").select("id").eq("brokerage_id",Be).neq("id",t.id).then(Oe=>{var qe;_e.add_agent=(((qe=Oe.data)==null?void 0:qe.length)||0)>0})):_e.add_agent=!1,Se.length>0?(Ee.push(H.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Se).then(Oe=>{_e.add_plan=(Oe.count||0)>0})),Ee.push(H.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Se).then(Oe=>{_e.schedule_popby=(Oe.count||0)>0}))):(_e.add_plan=!1,_e.schedule_popby=!1),await Promise.all(Ee);const Ae=q.filter(Oe=>_e[Oe.action_type]);if(Ae.length>0){const Oe=Ae.map(ve=>({user_id:t.id,item_id:ve.id})),{error:qe}=await H.from("onboarding_checklist_progress").upsert(Oe,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!qe){const ve=Ae.map(dt=>({item_id:dt.id,completed_at:new Date().toISOString()}));o(dt=>[...dt,...ve])}}},y=async I=>{if(t!=null&&t.id)try{const{error:P}=await H.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(P)throw P;o(O=>[...O,{item_id:I,completed_at:new Date().toISOString()}])}catch(P){console.error("Error marking item complete:",P)}},_=async()=>{if(t!=null&&t.id)try{const{error:I}=await H.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},w=a.length,j=r.length,N=j>0&&w>=j,S=j>0?w/j*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:w,totalCount:j,isComplete:N,progressPercentage:S,isItemComplete:I=>a.some(P=>P.item_id===I),markComplete:y,dismiss:_,refetch:f}}const $Lt={add_agent:e.jsx(ur,{className:"h-4 w-4"}),share_resource:e.jsx(nd,{className:"h-4 w-4"}),post_community:e.jsx(Ki,{className:"h-4 w-4"}),register_event:e.jsx(fn,{className:"h-4 w-4"}),view_template:e.jsx(Hv,{className:"h-4 w-4"}),watch_academy:e.jsx(Qh,{className:"h-4 w-4"}),use_toolbox:e.jsx(ry,{className:"h-4 w-4"}),launch_app:e.jsx(dL,{className:"h-4 w-4"}),add_deal:e.jsx(x0,{className:"h-4 w-4"}),add_listing:e.jsx(xn,{className:"h-4 w-4"})},qLt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function ULt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=BLt(),m=ar(),[f,g]=k.useState(!0);return r||s||a===0||o?null:e.jsxs(Pe,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Et,{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(_0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{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(G,{variant:"ghost",size:"sm",onClick:()=>g(!f),className:"h-8 w-8 p-0",children:f?e.jsx(Sp,{className:"h-4 w-4"}):e.jsx(Ji,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Er,{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(qi,{value:l,className:"h-2"})]})]}),f&&e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(y=>{const _=i(y.id);return e.jsxs("div",{className:Pt("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 w=qLt[y.action_type];w?m(w):c(y.id)},children:[e.jsx("div",{className:"mt-0.5",children:_?e.jsx(sa,{className:"h-5 w-5 text-primary"}):e.jsx(jd,{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:$Lt[y.action_type]||e.jsx(jd,{className:"h-4 w-4"})}),e.jsx("span",{className:Pt("font-medium",_&&"line-through text-muted-foreground"),children:y.title})]}),y.description&&e.jsx("p",{className:Pt("text-sm text-muted-foreground mt-1",_&&"line-through"),children:y.description})]})]},y.id)})})})]})}const Rf=()=>pt({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}}),nm=t=>{const s=Fa(),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})},VLt=t=>pt({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}),LQe=()=>{const t=Fa();return pt({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})},Oue=()=>{const t=Qt(),s=Fa();return Tt({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"]}),kn({title:"Contact created successfully"})},onError:r=>{kn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},FNe=()=>{const t=Qt();return Tt({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(m=>({contact_id:s,relationship_type_id:m})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),kn({title:"Contact updated successfully"})},onError:s=>{kn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},DQe=()=>{const t=Qt();return Tt({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"]}),kn({title:"Spouse link updated"})},onError:s=>{kn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},zNe=()=>{const t=Qt();return Tt({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"]}),kn({title:"Contact deleted successfully"})},onError:s=>{kn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},nR=()=>pt({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}}),HLt=t=>pt({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}}),GLt=()=>pt({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}}),WLt=()=>{const t=Qt(),s=Fa();return Tt({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"]}),kn({title:"Plan created successfully"})},onError:r=>{kn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},KLt=()=>{const t=Qt(),s=Fa();return Tt({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(m=>({plan_id:l.id,month_number:m.month_number,action_type_id:m.action_type_id,default_script_id:m.default_script_id,notes:m.notes})),{error:u}=await H.from("touchpoint_plan_items").insert(c);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),kn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{kn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},ZLt=()=>{const t=Qt();return Tt({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"]}),kn({title:"Plan updated successfully"})}})},YLt=()=>{const t=Qt();return Tt({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"]}),kn({title:"Plan deleted successfully"})}})},QLt=()=>{const t=Qt();return Tt({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"]}),kn({title:"Plan schedule updated"})}})},XLt=()=>{const t=Qt();return Tt({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"]}),kn({title:"Script created successfully"})},onError:s=>{kn({title:"Error creating script",description:s.message,variant:"destructive"})}})},JLt=()=>{const t=Fa();return pt({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})},e8t=()=>{const t=Qt(),s=Fa();return Tt({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"]}),kn({title:"Plan enrollment updated"})}})},aR=(t=7)=>{const s=Fa();return pt({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})},OQe=()=>{const t=Fa();return pt({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})},t8t=(t=90)=>{const{data:s}=nm(),{data:r}=OQe();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=Fa();return Tt({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"]}),kn({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{}}})},RQe="agentos_weekly_touch_goal",qIe=20,lle=()=>{if(typeof window>"u")return qIe;const t=localStorage.getItem(RQe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return qIe},FQe=t=>{localStorage.setItem(RQe,t.toString())},$Ne=()=>{const{data:t}=aR(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=lle();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},s8t=()=>{const t=Fa();return pt({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})},r8t=()=>{const t=Qt();return Fa(),Tt({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&&kn({title:`${s} contact(s) enrolled in plans`})}})},zQe=()=>{const t=Fa(),{data:s}=s8t(),{data:r}=aR(30);return pt({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(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((_=w.plan)!=null&&_.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const j=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-j.getTime())/(30.44*24*60*60*1e3))%12+1,M=w.plan.items.find(I=>I.month_number===S);if(M&&M.action_type){const I=`${w.contact_id}-${M.action_type_id}`;if(!c.has(I)){const{data:P}=await H.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:M.action_type,script:M.default_script||void 0,planName:w.plan.name,relationshipTypeName:(P==null?void 0:P.name)||"",monthNumber:S})}}}const u=5,m=o.getDate(),f=l.sort((w,j)=>w.contact.first_name.localeCompare(j.contact.first_name)),g=(m-1)%Math.max(1,f.length);return[...f.slice(g),...f.slice(0,g)].slice(0,u)},enabled:!!t&&!!s})};function n8t(){const t=ar(),{data:s,isLoading:r}=zQe(),{data:n}=nm(),a=$Ne(),[o,l]=k.useState(lle()),[i,c]=k.useState(""),[u,m]=k.useState(!1);k.useEffect(()=>{l(lle())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){kn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),FQe(O),m(!1),kn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},g=()=>{c(o.toString()),m(!0)},y=Um(new Date),_=Ll(y,7),w=O=>{if(!O)return null;const q=O.split(/[-/T]/);if(q.length<3)return null;const $=parseInt(q[1],10)-1,z=parseInt(q[2],10);return isNaN($)||isNaN(z)?null:new Date(y.getFullYear(),$,z)},j=(n==null?void 0:n.map(O=>{const q=w(O.birthday),$=w(O.home_anniversary),z=[];return q&&q>=y&&q<=_&&z.push({contact:O,type:"birthday",date:q,isToday:Tl(q,y)}),$&&$>=y&&$<=_&&z.push({contact:O,type:"anniversary",date:$,isToday:Tl($,y)}),z}).flat().sort((O,q)=>O.date.getTime()-q.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(O=>{const q=w(O.birthday),$=w(O.home_anniversary);return q&&Tl(q,y)||$&&Tl($,y)}).length)||0,S=(s==null?void 0:s.length)||0,M=N+S,I=(a==null?void 0:a.actionsThisWeek)||0,P=(a==null?void 0:a.streak)||0;return r?e.jsx(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(De,{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(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Et,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:P>0&&e.jsxs(Ye,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(rh,{className:"h-3 w-3"}),P," 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",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(El,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(G,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(G,{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(G,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(aa,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(G,{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(x0,{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(Xh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(fs,{open:u,onOpenChange:m,children:[e.jsx(Oi,{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(el,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{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(ye,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Le,{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(G,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(qi,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),j.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Eh,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:j.map((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:$=>{$.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(Eh,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(xn,{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(Ye,{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"?"🎂":"🏠":ds(O.date,"EEE, MMM d")}),e.jsx(da,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${q}`))})]}),e.jsxs(G,{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(ba,{className:"h-4 w-4"})]})]})]})}function a8t(t){return pt({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 i8t(t,s){return pt({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 o8t(t,s=4){return pt({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 l8t(t){const s=Qt();return Tt({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 c8t(){const t=Qt();return Tt({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 d8t(t){const s=Qt();return Tt({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 u8t(){const t=Qt();return Tt({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 h8t(t){const s=Qt();return Tt({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 m8t={video:sl,pdf:wn,link:pl,event:fn,graphic:$l},p8t={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 f8t(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 x8t(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 g8t({item:t}){const s=ar(),r=m8t[t.content_type]||pl,n=p8t[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"?f8t(t.url):null);k.useEffect(()=>{l||!t.url||t.content_type!=="video"||!x8t(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(Pe,{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(De,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(Ye,{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:ds(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function y8t(){const{brokerageId:t}=Fs(),s=ar(),{data:r=[],isLoading:n}=o8t(t,4);return!t||n||r.length===0?null:e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{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(g8t,{item:a},a.id))})]})}const BQe=()=>pt({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}}),$Qe=t=>{const{user:s,brokerageId:r}=Fs();return pt({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:m}=await u;if(m){const f=new Set(l.map(y=>y.id)),g=m.filter(y=>!f.has(y.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}})},qQe=()=>{const{user:t}=Fs();return pt({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})},UQe=t=>{const{user:s}=Fs();return pt({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})},v8t=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]})}})},b8t=()=>{const t=Qt();return Tt({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"]})}})},_8t=()=>{const t=Qt();return Tt({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]})}})},VQe=()=>{const t=Qt();return Tt({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"]})}})},w8t=()=>{const t=Qt();return Tt({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"]})}})},j8t=()=>{const t=Qt();return Tt({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"]})}})},N8t=()=>{const t=Qt();return Tt({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"]})}})},k8t=()=>{const t=Qt();return Tt({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"]})}})},S8t=()=>{const{user:t}=Fs();return pt({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})},HQe=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]})}})},GQe=t=>{const{user:s}=Fs();return pt({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})},C8t=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]})}})},M8t=t=>{const{user:s}=Fs();return pt({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})},T8t=()=>{const{user:t}=Fs();return Tt({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}})},A8t=()=>{const{user:t}=Fs();return pt({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})},E8t=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]})}})},P8t=()=>pt({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}}}),I8t=()=>{const{user:t,brokerageId:s}=Fs();return pt({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})},WQe=({className:t,variant:s="default"})=>e.jsx(Ye,{variant:"outline",className:Pt("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),L8t={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"},D8t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function O8t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function R8t(){const t=ar(),{data:s,isLoading:r}=BQe(),{data:n,isLoading:a}=$Qe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(m=>m.is_approved&&m.is_public))||[],l=o.filter(m=>m.is_featured),i=o.filter(m=>!m.is_featured),c=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Pe,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(De,{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(WQe,{})]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(xn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(G,{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(m=>{var g,y;const f=((g=m.photos)==null?void 0:g.find(_=>_.is_primary))||((y=m.photos)==null?void 0:y[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${m.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:`${m.city}, ${m.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(xn,{className:"h-8 w-8 text-muted-foreground/50"})}),m.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(Ye,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(ea,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(Ye,{className:`text-[10px] px-1.5 py-0.5 ${L8t[m.status]}`,children:D8t[m.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:O8t(m.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[m.city,", ",m.state]}),(m.bedrooms||m.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[m.bedrooms&&`${m.bedrooms} bed`,m.bedrooms&&m.bathrooms&&" · ",m.bathrooms&&`${m.bathrooms} bath`]})]})]},m.id)})})]})}function KQe(t=10,s){return pt({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(y=>y.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:m}=await H.from("profiles").select("id, name").in("id",u),f=new Map((m==null?void 0:m.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 ZQe(t){return pt({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 YQe(t){return pt({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 QQe(t,s){return pt({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(m=>m.id))||[]);i=i.filter(m=>u.has(m.user_id))}return i.length+1},enabled:!!t})}function F8t(){const{user:t,brokerageId:s,isAdmin:r}=Fs();ar();const n=!!s,[a,o]=k.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=KQe(5,l()),{data:u}=ZQe(t==null?void 0:t.id),{data:m}=QQe(t==null?void 0:t.id,l()),{data:f}=YQe(t==null?void 0:t.id),g=r||n,y=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(_o,{className:"h-4 w-4 text-yellow-500"}),y()]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2",children:[...Array(g?5:3)].map((w,j)=>e.jsx(ws,{className:"h-10 w-full"},j))})})]});const _=w=>w===0?e.jsx(_o,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(g){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Pe,{children:[e.jsxs(Et,{className:"pb-2",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(_o,{className:"h-4 w-4 text-yellow-500"}),y()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(G,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(G,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(De,{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:["#",m||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((j,N)=>{var S,M,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${j.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:_(N)}),e.jsx(Cn,{className:"h-6 w-6",children:e.jsx(Mn,{className:"text-xs",children:((M=(S=j.profile)==null?void 0:S.name)==null?void 0:M.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=j.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:j.total_points})]},j.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(la,{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(bo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(_o,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(De,{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(rh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(rc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(la,{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(bo,{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(ea,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(la,{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(bo,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(da,{className:"h-4 w-4"})]})]})})]})}const _E=()=>pt({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}}),qNe=()=>{const t=Qt(),{user:s}=Fs();return Tt({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)}})},z8t=()=>{const t=Qt();return Tt({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")}})},B8t=()=>{const t=Qt();return Tt({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")}})},UNe=(t,s)=>{const{user:r,isAdmin:n}=Fs(),a=n&&s?s:r==null?void 0:r.id;return pt({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})},VNe=t=>{const{user:s,isAdmin:r}=Fs(),n=r&&t?t:s==null?void 0:s.id;return pt({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})},Rue=()=>{const t=Qt(),{user:s}=Fs();return Tt({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)}})},$8t=()=>{const t=Qt();return Tt({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)}})},q8t=()=>{const t=Qt();return Tt({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)}})},XQe=(t,s)=>{const{user:r,isAdmin:n}=Fs(),a=n&&s?s:r==null?void 0:r.id;return pt({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})},U8t=()=>{const t=Qt(),{user:s}=Fs();return Tt({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)}})},Fue=()=>{const{user:t}=Fs();return pt({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)})},V8t=()=>{const t=Qt(),{user:s}=Fs();return Tt({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)}})},JQe=(t,s)=>{const{data:r,isLoading:n}=UNe(t,s),{data:a,isLoading:o}=VNe(s),{data:l}=Fue(),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 m=u.filter(P=>P.transaction_type==="buyer").length,f=u.filter(P=>P.transaction_type==="seller").length,g=u.reduce((P,O)=>P+Number(O.sale_price),0),y=u.reduce((P,O)=>P+(Number(O.commission_amount)||0),0),_=u.reduce((P,O)=>{const q=Number(O.commission_amount)||0;if(!q)return P;let $=q;return O.brokerage_split_pct&&($-=q*(O.brokerage_split_pct/100)),O.team_split_pct&&($-=q*(O.team_split_pct/100)),O.franchise_fee_pct&&($-=q*(O.franchise_fee_pct/100)),O.referral_fee_pct&&($-=q*(O.referral_fee_pct/100)),O.transaction_fee&&($-=O.transaction_fee),P+Math.max(0,$)},0),w={};u.forEach(P=>{var q;const O=((q=P.lead_source)==null?void 0:q.name)||"Unknown";w[O]=(w[O]||0)+1});const j=Object.entries(w).map(([P,O])=>({name:P,count:O})).sort((P,O)=>O.count-P.count),N=j[0]||null,S={};u.forEach(P=>{const O=Fl(P.close_date).toLocaleString("default",{month:"short"});S[O]=(S[O]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(P=>({month:P,count:S[P]||0}));return{totalTransactions:u.length,buyerCount:m,sellerCount:f,totalVolume:g,averagePrice:u.length>0?g/u.length:0,totalCommission:i?y:0,totalNetToAgent:i?_:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:j}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},H8t=()=>{const{isAdmin:t}=Fs();return pt({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})},s_={recency:40,touchpoints:30,transactions:20},UIe={warm:70,cooling:40};function G8t(t){return t===null?0:t<=14?s_.recency:t<=30?s_.recency*.85:t<=60?s_.recency*.65:t<=90?s_.recency*.4:t<=180?s_.recency*.2:s_.recency*.05}function W8t(t){const s=Math.min(t/12,1);return Math.round(s_.touchpoints*s)}function K8t(t){return t?s_.transactions:0}function Z8t(){return 0}function Y8t(t){return t>=UIe.warm?"warm":t>=UIe.cooling?"cooling":"at-risk"}function zue(){const{data:t,isLoading:s}=nm(),{data:r}=OQe(),{data:n}=aR(365),{data:a}=VNe(),o=k.useMemo(()=>{if(!t)return[];const i=new Date,c=N4(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 m=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,y=g?dy(i,new Date(g)):null,_=u[f.id]||0,w=m.has(f.id),j=G8t(y),N=W8t(_),S=K8t(w),M=Z8t(),I=Math.round(j+N+S+M),P={score:I,status:Y8t(I),breakdown:{recency:Math.round(j),touchpoints:Math.round(N),transactions:Math.round(S),referrals:Math.round(M)},lastTouchDate:g,daysSinceTouch:y,touchCountLast12Months:_,hasTransaction:w};return{...f,relationshipScore:P}})},[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,m=o.length,f=m>0?Math.round(o.reduce((g,y)=>g+y.relationshipScore.score,0)/m):0;return{warm:i,cooling:c,atRisk:u,total:m,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function eXe(){const t=ar(),{stats:s,contactsWithScores:r,isLoading:n}=zue();if(n)return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(ws,{className:"h-5 w-40"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(ws,{className:"h-20 w-full"}),e.jsx(ws,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(G,{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(Pe,{children:[e.jsxs(Et,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Bo,{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(De,{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(qi,{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(qi,{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(qi,{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(CS,{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(G,{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 Q8t=()=>{var ne;const{user:t,isAdmin:s}=Fs(),r=ar(),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState([]),[u,m]=k.useState([]),[f,g]=k.useState([]),[y,_]=k.useState([]),[w,j]=k.useState(new Set),[N,S]=k.useState([]),[M,I]=k.useState([]),[P,O]=k.useState([]),[q,$]=k.useState(null),[z,V]=k.useState(!0);k.useEffect(()=>{X()},[t]);const X=async()=>{var re,oe,he,xe,ue;try{const[ge,_e,Be,Se,Ee,Ae,Me,ke,Oe,qe,ve]=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()]);(re=ve.data)!=null&&re.name&&$(ve.data.name);const dt=((oe=ge.data)==null?void 0:oe.map(Je=>Je.tag))||[],pe=new Set(((he=Be.data)==null?void 0:he.map(Je=>Je.app_id))||[]);j(pe);const Xe=(((xe=_e.data)==null?void 0:xe.filter(Je=>!Je.required_tags||Je.required_tags.length===0?!0:Je.required_tags.some(Ge=>dt.includes(Ge))))||[]).sort((Je,Ge)=>Je.name==="LevelUp Members Portal"?-1:Ge.name==="LevelUp Members Portal"?1:0);a(Xe.slice(0,6));const et=((ue=Se.data)==null?void 0:ue.filter(Je=>fT(Je.event_date)!=="ended"))||[];l(et.slice(0,4)),S(Ee.data||[]),c(Ae.data||[]),m(Me.data||[]),g(ke.data||[]),_(Oe.data||[]);const Ce=qe.data||[];I(Ce.filter(Je=>Je.placement==="top")),O(Ce.filter(Je=>Je.placement==="between"))}catch(ge){console.error("Error loading dashboard:",ge),me.error("Failed to load dashboard data")}finally{V(!1)}},Y=async re=>{var he;const oe=window.open("about:blank","_blank");try{await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:re.app_id,app_name:re.name,user_agent:navigator.userAgent});const{data:xe,error:ue}=await H.functions.invoke("sso-launch",{body:{app_id:re.app_id}});if(ue)throw ue;xe!=null&&xe.redirect_url?oe&&!oe.closed?(oe.location.href=xe.redirect_url,(he=oe.focus)==null||he.call(oe)):window.location.assign(xe.redirect_url):(oe==null||oe.close(),me.error("Launch link unavailable"))}catch(xe){oe==null||oe.close(),console.error("Error launching app:",xe),me.error("Failed to launch app")}},J=re=>N==null?void 0:N.some(oe=>oe.event_id===re),Q=re=>{const oe=N==null?void 0:N.find(he=>he.event_id===re);return oe==null?void 0:oe.zoom_join_url};if(z)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 ce=re=>P.filter(oe=>oe.section_after===re);return e.jsxs(Ms,{title:"Dashboard",children:[e.jsx(PLt,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),M.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(pI,{banners:M})}),e.jsx(ULt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(q||((ne=t==null?void 0:t.user_metadata)==null?void 0:ne.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(n8t,{}),e.jsx(eXe,{}),e.jsx(F8t,{})]}),e.jsx(y8t,{}),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(G,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fn,{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(re=>{const oe=J(re.id),he=Q(re.id)||re.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 ${zIe(re.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[zIe(re.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(y1,{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(re.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(re.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:re.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(re.event_date))," at ",jD(new Date(re.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:oe?e.jsxs(G,{size:"sm",variant:"default",className:"gap-1",onClick:xe=>{xe.stopPropagation(),window.open(he,"_blank")},children:[e.jsx(rn,{className:"h-3.5 w-3.5"}),"Join"]}):e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Register"}),e.jsx(da,{className:"h-4 w-4"})]})})]},re.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(pI,{banners:ce("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(G,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fp,{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(re=>e.jsxs("div",{onClick:()=>r(`/academy/${re.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:[re.thumbnail_url?e.jsx("img",{src:re.thumbnail_url,alt:re.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(fp,{className:"h-8 w-8 text-muted-foreground/50"})}),re.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:re.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:re.title})})]},re.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(pI,{banners:ce("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(G,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Bm,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(re=>e.jsxs("div",{onClick:()=>r(`/toolbox/${re.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:re.featured_image_url?e.jsx("img",{src:re.featured_image_url,alt:re.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(Bm,{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:re.name})})]},re.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(pI,{banners:ce("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(G,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(K_,{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(re=>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:re.preview_image_url?e.jsx("img",{src:re.preview_image_url,alt:re.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(K_,{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:re.name})})]},re.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(pI,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(R8t,{})}),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(G,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ax,{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(re=>{const oe=w.has(re.id);return e.jsxs("div",{onClick:()=>Y(re),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:re.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:re.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:re.description})]}),oe&&e.jsx(Ax,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},re.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(G,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ba,{className:"h-4 w-4"})]})]}),y.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(nn,{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:y.map(re=>e.jsxs("div",{onClick:()=>window.open(re.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:re.preview_image_url?e.jsx("img",{src:re.preview_image_url,alt:re.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(nn,{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:re.name}),re.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:re.description})]})]},re.id))})]})]})};var tXe="AlertDialog",[X8t]=od(tXe,[SGe]),K1=SGe(),sXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=K1(s);return e.jsx(sue,{...n,...r,modal:!0})};sXe.displayName=tXe;var J8t="AlertDialogTrigger",rXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=K1(r);return e.jsx(wje,{...a,...n,ref:s})});rXe.displayName=J8t;var eDt="AlertDialogPortal",nXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=K1(s);return e.jsx(rue,{...n,...r})};nXe.displayName=eDt;var tDt="AlertDialogOverlay",aXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=K1(r);return e.jsx(dE,{...a,...n,ref:s})});aXe.displayName=tDt;var xT="AlertDialogContent",[sDt,rDt]=X8t(xT),nDt=dqe("AlertDialogContent"),iXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=K1(r),l=k.useRef(null),i=Ka(s,l),c=k.useRef(null);return e.jsx(QNt,{contentName:xT,titleName:oXe,docsSlug:"alert-dialog",children:e.jsx(sDt,{scope:r,cancelRef:c,children:e.jsxs(uE,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Or(a.onOpenAutoFocus,u=>{var m;u.preventDefault(),(m=c.current)==null||m.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(nDt,{children:n}),e.jsx(iDt,{contentRef:l})]})})})});iXe.displayName=xT;var oXe="AlertDialogTitle",lXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=K1(r);return e.jsx(WO,{...a,...n,ref:s})});lXe.displayName=oXe;var cXe="AlertDialogDescription",dXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=K1(r);return e.jsx(KO,{...a,...n,ref:s})});dXe.displayName=cXe;var aDt="AlertDialogAction",uXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=K1(r);return e.jsx(ZO,{...a,...n,ref:s})});uXe.displayName=aDt;var hXe="AlertDialogCancel",mXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=rDt(hXe,r),o=K1(r),l=Ka(s,a);return e.jsx(ZO,{...o,...n,ref:l})});mXe.displayName=hXe;var iDt=({contentRef:t})=>{const s=`\`${xT}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${xT}\` by passing a \`${cXe}\` 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 \`${xT}\`. 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},oDt=sXe,lDt=rXe,cDt=nXe,pXe=aXe,fXe=iXe,xXe=uXe,gXe=mXe,yXe=lXe,vXe=dXe;const Tc=oDt,Pm=lDt,dDt=cDt,bXe=k.forwardRef(({className:t,...s},r)=>e.jsx(pXe,{className:Pt("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));bXe.displayName=pXe.displayName;const nc=k.forwardRef(({className:t,...s},r)=>e.jsxs(dDt,{children:[e.jsx(bXe,{}),e.jsx(fXe,{ref:r,className:Pt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));nc.displayName=fXe.displayName;const ac=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});ac.displayName="AlertDialogHeader";const ic=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});ic.displayName="AlertDialogFooter";const oc=k.forwardRef(({className:t,...s},r)=>e.jsx(yXe,{ref:r,className:Pt("text-lg font-semibold",t),...s}));oc.displayName=yXe.displayName;const lc=k.forwardRef(({className:t,...s},r)=>e.jsx(vXe,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));lc.displayName=vXe.displayName;const zl=k.forwardRef(({className:t,...s},r)=>e.jsx(xXe,{ref:r,className:Pt(mD(),t),...s}));zl.displayName=xXe.displayName;const cc=k.forwardRef(({className:t,...s},r)=>e.jsx(gXe,{ref:r,className:Pt(mD({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));cc.displayName=gXe.displayName;const uDt=[{key:"contacts",label:"Contacts",icon:Nn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:hS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Bm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:An,description:"View and upload videos"},{key:"listings",label:"Listings",icon:xn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:W_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:aa,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Px,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Ah,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:sy,description:"Create and manage smart presentations"}];function hDt(){var q;const{user:t}=Fs(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState(null),[f,g]=k.useState({email:"",name:"",password:""}),[y,_]=k.useState("create"),[w,j]=k.useState(!1),[N,S]=k.useState(null);k.useEffect(()=>{t&&M()},[t]);const M=async()=>{if(t){a(!0);try{const{data:$,error:z}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(z)throw z;if($&&$.length>0){const V=$.map(J=>J.assistant_id),{data:X}=await H.from("profiles").select("id, name, email").in("id",V),Y=$.map(J=>{const Q=X==null?void 0:X.find(ce=>ce.id===J.assistant_id);return{...J,permissions:J.permissions,assistant_profile:Q?{name:Q.name||"",email:Q.email||""}:void 0}});r(Y)}else r([])}catch($){console.error("Error loading assistants:",$)}finally{a(!1)}}},I=async()=>{if(t){if(y==="link"){if(!f.email.trim()){me.error("Please enter the assistant's email");return}j(!0);try{const{data:{session:$}}=await H.auth.getSession();if(!$)throw new Error("Not authenticated");const{data:z,error:V}=await H.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!z){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:X}=await H.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",z.id);if(X&&X.length>0){me.error("This assistant is already assigned to you");return}const Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$.access_token}`},body:JSON.stringify({userId:z.id,role:"assistant",action:"add",agentId:t.id})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:z.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`${z.name||z.email} linked as your assistant`),l(!1),g({email:"",name:"",password:""}),M()}catch($){console.error("Error linking assistant:",$),me.error($.message||"Failed to link assistant")}finally{j(!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}j(!0);try{const{data:{session:$}}=await H.auth.getSession();if(!$)throw new Error("Not authenticated");const z=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await z.json();if(!z.ok)throw new Error(V.error||"Failed to create assistant account");const X=V.userId||V.id;if(!X)throw new Error("No user ID returned");const Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$.access_token}`},body:JSON.stringify({userId:X,role:"assistant",action:"add",agentId:t.id})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:X,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),g({email:"",name:"",password:""}),M()}catch($){console.error("Error adding assistant:",$),me.error($.message||"Failed to add assistant")}finally{j(!1)}}},P=async()=>{if(!(!u||!t))try{const{data:{session:$}}=await H.auth.getSession();if(!$)throw new Error("Not authenticated");const{error:z}=await H.from("agent_assistant_assignments").delete().eq("id",u.id);if(z)throw z;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 ${$.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),c(!1),m(null),M()}catch($){console.error("Error removing assistant:",$),me.error($.message||"Failed to remove assistant")}},O=async($,z,V)=>{S($);try{const X=s.find(Q=>Q.id===$);if(!X)return;const Y={...X.permissions,[z]:V},{error:J}=await H.from("agent_assistant_assignments").update({permissions:Y}).eq("id",$);if(J)throw J;r(Q=>Q.map(ce=>ce.id===$?{...ce,permissions:Y}:ce))}catch(X){console.error("Error updating permissions:",X),me.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(vr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(G,{size:"sm",onClick:()=>{_("create"),l(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(De,{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($=>{var z,V,X,Y;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(Cn,{className:"h-10 w-10",children:e.jsx(Mn,{children:((V=(z=$.assistant_profile)==null?void 0:z.name)==null?void 0:V.split(" ").map(J=>J[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=$.assistant_profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Y=$.assistant_profile)==null?void 0:Y.email)||""})]}),e.jsxs(Ye,{variant:"secondary",className:"ml-2",children:[e.jsx(ou,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(G,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{m($),c(!0)},children:e.jsx(kr,{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:uDt.map(J=>{const Q=J.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:J.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:J.description})]})]}),e.jsx(qr,{checked:$.permissions[J.key]||!1,onCheckedChange:ce=>O($.id,J.key,ce),disabled:N===$.id})]},J.key)})})]})]},$.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Add Assistant"}),e.jsx(Gr,{children:y==="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(G,{variant:y==="create"?"default":"outline",size:"sm",onClick:()=>_("create"),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(G,{variant:y==="link"?"default":"outline",size:"sm",onClick:()=>_("link"),children:[e.jsx(Uo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[y==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Le,{id:"assistant-name",value:f.name,onChange:$=>g({...f,name:$.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Le,{id:"assistant-email",type:"email",value:f.email,onChange:$=>g({...f,email:$.target.value}),placeholder:"assistant@email.com"})]}),y==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Le,{id:"assistant-password",type:"password",value:f.password,onChange:$=>g({...f,password:$.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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(G,{onClick:I,disabled:w,children:[w&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),y==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(Tc,{open:i,onOpenChange:c,children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Remove Assistant?"}),e.jsxs(lc,{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(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function _h(t){this.content=t}_h.prototype={constructor:_h,find:function(t){for(var s=0;s>1}};_h.from=function(t){if(t instanceof _h)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new _h(s)};function _Xe(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=_Xe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function wXe(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,m=Math.min(l.text.length,i.text.length);for(;us&&n(c,a+i,o||null,l)!==!1&&c.content.size){let m=i+1;c.nodesBetween(Math.max(0,s-m),Math.min(c.content.size,r-m),n,a+m)}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 Rr(n,a)}cutByIndex(s,r){return s==r?Rr.empty:s==0&&r==this.content.length?this:new Rr(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 Rr(a,o)}addToStart(s){return new Rr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Rr(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?Sz(r+1,o):Sz(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 Rr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Rr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Rr.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}};Ol.none=[];class dle extends Error{}class Sn{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=NXe(this.content,s+this.openStart,r);return n&&new Sn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new Sn(jXe(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 Sn.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 Sn(Rr.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 Sn(s,n,a)}}Sn.empty=new Sn(Rr.empty,0,0);function jXe(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(jXe(o.content,s-a-1,r-a-1)))}function NXe(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=NXe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function mDt(t,s,r){if(r.openStart>t.depth)throw new dle("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new dle("Inconsistent open depths");return kXe(t,s,r,0)}function kXe(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 x8(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&&(PS(t.nodeAfter,n),o++));for(let i=o;ia&&D1e(t,s,a+1),l=n.depth>a&&D1e(r,n,a+1),i=[];return x8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(SXe(o,l),PS(IS(o,CXe(t,s,r,n,a+1)),i)):(o&&PS(IS(o,ule(t,s,a+1)),i),x8(s,r,a,i),l&&PS(IS(l,ule(r,n,a+1)),i)),x8(n,null,a,i),new Rr(i)}function ule(t,s,r){let n=[];if(x8(null,t,r,n),t.depth>r){let a=D1e(t,s,r+1);PS(IS(a,ule(t,s,r+1)),n)}return x8(s,null,r,n),new Rr(n)}function pDt(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(Rr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class ND{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 hle(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 ND(r,n,o)}static resolveCached(s,r){let n=VIe.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()+")"),MXe(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=Rr.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=Rr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};iw.prototype.text=void 0;class mle extends iw{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):MXe(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 mle(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new mle(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 MXe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class a3{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new yDt(s,r);if(n.next==null)return a3.empty;let a=TXe(n);n.next&&n.err("Unexpected trailing text");let o=kDt(NDt(a));return SDt(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(` `)}}a3.empty=new a3(!0);class yDt{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 TXe(t){let s=[];do s.push(vDt(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function vDt(t){let s=[];do s.push(bDt(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function bDt(t){let s=jDt(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=_Dt(t,s);else break;return s}function HIe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function _Dt(t,s){let r=HIe(t),n=r;return t.eat(",")&&(t.next!="}"?n=HIe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function wDt(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 jDt(t){if(t.eat("(")){let s=TXe(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=wDt(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 NDt(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 m=0;m{u||a.push([i,u=[]]),u.indexOf(m)==-1&&u.push(m)})})});let o=s[n.join(",")]=new a3(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:PXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new iw(this,this.computeAttrs(s),Rr.from(r),Ol.setFrom(n))}createChecked(s=null,r,n){return r=Rr.from(r),this.checkContent(r),new iw(this,this.computeAttrs(s),r,Ol.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Rr.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(Rr.empty,!0);return o?new iw(this,s,r.append(o),Ol.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 DXe(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 CDt(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 MDt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?CDt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Bue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=LXe(s,a.attrs),this.excluded=null;let o=EXe(this.attrs);this.instance=o?new Ol(this,o):null}create(s=null){return!s&&this.instance?this.instance:new Ol(this,PXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new Bue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class OXe{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=_h.from(s.nodes),r.marks=_h.from(s.marks||{}),this.nodes=WIe.compile(this.spec.nodes,this),this.marks=Bue.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]=a3.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?KIe(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==""?[]:KIe(this,l.split(" "))}this.nodeFromJSON=a=>iw.fromJSON(this,a),this.markFromJSON=a=>Ol.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 WIe){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 mle(n,n.defaultAttrs,s,Ol.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 KIe(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 TDt(t){return t.tag!=null}function ADt(t){return t.style!=null}let g8=class R1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(TDt(a))this.tags.push(a);else if(ADt(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 YIe(this,r,!1);return n.addAll(s,Ol.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new YIe(this,r,!0);return n.addAll(s,Ol.none,r.from,r.to),Sn.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=QIe(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=QIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new R1e(s,R1e.schemaRules(s)))}};const RXe={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},EDt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},FXe={ol:!0,ul:!0},kD=1,F1e=2,y8=4;function ZIe(t,s,r){return s!=null?(s?kD:0)|(s==="full"?F1e:0):t&&t.whitespace=="pre"?kD|F1e:r&~y8}class Cz{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=Ol.none,this.match=o||(l&y8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Rr.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&kD)){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=Rr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Rr.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&&!RXe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class YIe{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=ZIe(null,r.preserveWhitespace,0)|(n?y8:0);a?o=new Cz(a.type,a.attrs,Ol.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new Cz(null,null,Ol.none,!0,null,l):o=new Cz(s.schema.topNodeType,null,Ol.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&F1e?"full":this.localPreserveWS||(a.options&kD)>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):XIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new Cz(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|=kD)}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 m=c>0||c==0&&a?this.nodes[c].type:n&&c>=o?n.node(c-o).type:null;if(!m||m.name!=u&&!m.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 PDt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&FXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function IDt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function QIe(t){let s={};for(let r in t)s[r]=t[r];return s}function XIe(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&&Oie(mge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Oie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new I3(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=JIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return JIe(s.marks)}}function JIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function mge(t){return t.document||window.document}const eLe=new WeakMap;function LDt(t){let s=eLe.get(t);return s===void 0&&eLe.set(t,s=DDt(t)),s}function DDt(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],m=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){m=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=m;fm)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:y,contentDOM:_}=Oie(t,g,r,n);if(c.appendChild(y),_){if(i)throw new RangeError("Multiple content holes");i=_}}}return{dom:c,contentDOM:i}}const zXe=65535,BXe=Math.pow(2,16);function ODt(t,s){return t+s*BXe}function tLe(t){return t&zXe}function RDt(t){return(t-(t&zXe))/BXe}const $Xe=1,qXe=2,Rie=4,UXe=8;class z1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&UXe)>0}get deletedBefore(){return(this.delInfo&($Xe|Rie))>0}get deletedAfter(){return(this.delInfo&(qXe|Rie))>0}get deletedAcross(){return(this.delInfo&Rie)>0}}class uf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&uf.empty)return uf.empty}recover(s){let r=0,n=tLe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],m=this.ranges[i+l],f=c+u;if(s<=f){let g=u?s==c?-1:s==f?1:r:r,y=c+a+(g<0?0:m);if(n)return y;let _=s==(r<0?c:f)?null:ODt(i/3,s-c),w=s==c?qXe:s==f?$Xe:Rie;return(r<0?s!=c:s!=f)&&(w|=UXe),new z1e(y,w,_)}a+=m-u}return n?s+a:new z1e(s+a,0,null)}touches(s,r){let n=0,a=tLe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],m=c+u;if(s<=m&&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 SD;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 ru.fromReplace(s,this.from,this.to,o)}invert(){return new u0(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 L_(r.pos,n.pos,this.mark)}merge(s){return s instanceof L_&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new L_(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 L_(r.from,r.to,s.markFromJSON(r.mark))}}am.jsonID("addMark",L_);class u0 extends am{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 Sn(HNe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return ru.fromReplace(s,this.from,this.to,n)}invert(){return new L_(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 u0(r.pos,n.pos,this.mark)}merge(s){return s instanceof u0&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new u0(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 u0(r.from,r.to,s.markFromJSON(r.mark))}}am.jsonID("removeMark",u0);class D_ extends am{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return ru.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return ru.fromReplace(s,this.pos,this.pos+1,new Sn(Rr.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 ih(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 ih(r.from,r.to,r.gapFrom,r.gapTo,Sn.fromJSON(s,r.slice),r.insert,!!r.structure)}}am.jsonID("replaceAround",ih);function B1e(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 FDt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(c,u,m)=>{if(!c.isInline)return;let f=c.marks;if(!n.isInSet(f)&&m.type.allowsMarkType(n.type)){let g=Math.max(u,s),y=Math.min(u+c.nodeSize,r),_=n.addToSet(f);for(let w=0;wt.step(c)),o.forEach(c=>t.step(c))}function zDt(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 Bue){let u=l.marks,m;for(;m=n.isInSet(u);)(c||(c=[])).push(m),u=m.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 m=0;mt.step(new u0(l.from,l.to,l.style)))}function GNe(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 BDt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function wE(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;_--)w||n.index(_)>0?(w=!0,m=Rr.from(n.node(_).copy(m)),f++):c--;let g=Rr.empty,y=0;for(let _=o,w=!1;_>r;_--)w||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=Rr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new ih(a,o,a,o,new Sn(n,0,0),r.length,!0))}function HDt(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)&&GDt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let y=n.whitespace=="pre",_=!!n.contentMatch.matchType(n.schema.linebreakReplacement);y&&!_?u=!1:!y&&_&&(u=!0)}u===!1&&HXe(t,l,i,o),GNe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let m=t.mapping.slice(o),f=m.map(i,1),g=m.map(i+l.nodeSize,1);return t.step(new ih(f,g,f+1,g-1,new Sn(Rr.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&VXe(t,l,i,o),!1}})}function VXe(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 HXe(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 GDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function WDt(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 ih(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new Sn(Rr.from(l),0,0),1,!0))}function _1(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,m=r-2;u>o;u--,m--){let f=a.node(u),g=a.index(u);if(f.type.spec.isolating)return!1;let y=f.content.cutByIndex(g,f.childCount),_=n&&n[m+1];_&&(y=y.replaceChild(0,_.type.create(_.attrs)));let w=n&&n[m]||f;if(!f.canReplace(g+1,f.childCount)||!w.type.validContent(y))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 KDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Rr.empty,l=Rr.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Rr.from(a.node(i).copy(o));let m=n&&n[u];l=Rr.from(m?m.type.create(m.attrs,l):a.node(i).copy(l))}t.step(new Xu(s,s,new Sn(o.append(l),r,r),!0))}function $w(t,s){let r=t.resolve(s),n=r.index();return GXe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function ZDt(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&&GXe(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 YDt(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 m=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);m&&!f?n=!1:!m&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let m=t.doc.resolve(s+r);HXe(t,m.node(),m.before(),i)}l.inlineContent&&GNe(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 Xu(u,c.map(s+r,-1),Sn.empty,!0)),n===!0){let m=t.doc.resolve(u);VXe(t,m.node(),m.before(),t.steps.length)}return t}function QDt(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),m=!1;if(o==1)m=u.canReplace(c,c,a);else{let f=u.contentMatchAt(c).findWrapping(a.firstChild.type);m=f&&u.canReplaceWith(c,c,f[0])}if(m)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function que(t,s,r=s,n=Sn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return KXe(a,o,n)?new Xu(s,r,n):new XDt(a,o,n).fit()}function KXe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class XDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Rr.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=Rr.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 Sn(o,l,i);return s>-1?new ih(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Xu(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=fge(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],m,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Rr.from(l),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(m=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:m};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=fge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Sn(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=fge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new Sn(VI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new Sn(VI(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||c==0||w.content.size)&&(f=j,m.push(ZXe(w.mark(g.allowedMarks(w.marks)),u==1?c:0,u==i.childCount?y:-1)))}let _=u==i.childCount;_||(y=-1),this.placed=HI(this.placed,r,Rr.from(m)),this.frontier[r].match=f,_&&y<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=i;w1&&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],m=xge(s,i,u,c,!0);if(!m||m.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=HI(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=HI(this.placed,this.depth,Rr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Rr.empty,!0);r.childCount&&(this.placed=HI(this.placed,this.frontier.length,r))}}function VI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(VI(t.firstChild.content,s-1,r)))}function HI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(HI(t.lastChild.content,s-1,r)))}function fge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,ZXe(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(Rr.empty,!0)))),t.copy(n)}function xge(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&&!JDt(r,o.content,l)?i:null}function JDt(t,s,r){for(let n=r;n0;g--,y--){let _=a.node(g).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(g)>-1?i=g:a.before(g)==y&&l.splice(1,0,-g)}let c=l.indexOf(i),u=[],m=n.openStart;for(let g=n.content,y=0;;y++){let _=g.firstChild;if(u.push(_),y==n.openStart)break;g=_.content}for(let g=m-1;g>=0;g--){let y=u[g],_=eOt(y.type);if(_&&!y.sameMarkup(a.node(Math.abs(i)-1)))m=g;else if(_||!y.type.isTextblock)break}for(let g=n.openStart;g>=0;g--){let y=(g+m+1)%(n.openStart+1),_=u[y];if(_)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>f));g--){let y=l[g];y<0||(s=a.before(y),r=o.after(y))}}function YXe(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(Rr.empty,!0))}return t}function sOt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=QDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new Sn(Rr.from(n),0,0))}function rOt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=QXe(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 QXe(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 gT extends am{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 ru.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 ru.fromReplace(s,this.pos,this.pos+1,new Sn(Rr.from(a),0,r.isLeaf?0:1))}getMap(){return uf.empty}invert(s){return new gT(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 gT(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 gT(r.pos,r.attr,r.value)}}am.jsonID("attr",gT);class CD extends am{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 ru.ok(n)}getMap(){return uf.empty}invert(s){return new CD(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 CD(r.attr,r.value)}}am.jsonID("docAttr",CD);let oA=class extends Error{};oA=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};oA.prototype=Object.create(Error.prototype);oA.prototype.constructor=oA;oA.prototype.name="TransformError";class KNe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new SD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new oA(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=Sn.empty){let a=que(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new Sn(Rr.from(n),0,0))}delete(s,r){return this.replace(s,r,Sn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return tOt(this,s,r,n),this}replaceRangeWith(s,r,n){return sOt(this,s,r,n),this}deleteRange(s,r){return rOt(this,s,r),this}lift(s,r){return $Dt(this,s,r),this}join(s,r=1){return YDt(this,s,r),this}wrap(s,r){return VDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return HDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return WDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new gT(s,r,n)),this}setDocAttribute(s,r){return this.step(new CD(s,r)),this}addNodeMark(s,r){return this.step(new D_(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 Ol)r.isInSet(n.marks)&&this.step(new i3(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new i3(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 KDt(this,s,r,n),this}addMark(s,r,n){return FDt(this,s,r,n),this}removeMark(s,r,n){return zDt(this,s,r,n),this}clearIncompatible(s,r,n){return GNe(this,s,r,n),this}}const gge=Object.create(null);class _i{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new XXe(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?rM(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):rM(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 jf(s.node(0))}static atStart(s){return rM(s,s,0,0,1)||new jf(s)}static atEnd(s){return rM(s,s,s.content.size,s.childCount,-1)||new jf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=gge[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 gge)throw new RangeError("Duplicate use of selection JSON ID "+s);return gge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return ni.between(this.$anchor,this.$head).getBookmark()}}_i.prototype.visible=!0;class XXe{constructor(s,r){this.$from=s,this.$to=r}}let rLe=!1;function nLe(t){!rLe&&!t.parent.inlineContent&&(rLe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ni extends _i{constructor(s,r=s){nLe(s),nLe(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 _i.near(n);let a=s.resolve(r.map(this.anchor));return new ni(a.parent.inlineContent?a:n,n)}replace(s,r=Sn.empty){if(super.replace(s,r),r==Sn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof ni&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new Uue(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 ni(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=_i.findFrom(r,n,!0)||_i.findFrom(r,-n,!0);if(o)r=o.$head;else return _i.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(_i.findFrom(s,-n,!0)||_i.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&&Qa.isSelectable(i))return Qa.create(t,r-(a<0?i.nodeSize:0))}else{let c=rM(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function aLe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=m)}),t.setSelection(_i.near(t.doc.resolve(l),r))}const iLe=1,Mz=2,oLe=4;class aOt extends KNe{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|=Mz,this}ensureMarks(s){return Ol.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&Mz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~Mz,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)||Ol.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(_i.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|=oLe,this}get scrolledIntoView(){return(this.updated&oLe)>0}}function lLe(t,s){return!s||!t?t:t.bind(s)}class GI{constructor(s,r,n){this.name=s,this.init=lLe(r.init,n),this.apply=lLe(r.apply,n)}}const iOt=[new GI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new GI("selection",{init(t,s){return t.selection||_i.atStart(s.doc)},apply(t){return t.selection}}),new GI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new GI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class yge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=iOt.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 GI(n.key,n.spec.state,n))})}}class NM{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 yge(s.schema,s.plugins),o=new NM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=iw.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=_i.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 JXe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=JXe(a,s,{})),r[n]=a}return r}class Ru{constructor(s){this.spec=s,this.props={},s.props&&JXe(s.props,this,this.props),this.key=s.key?s.key.key:eJe("plugin")}getState(s){return s[this.key]}}const vge=Object.create(null);function eJe(t){return t in vge?t+"$"+ ++vge[t]:(vge[t]=0,t+"$")}class im{constructor(s="key"){this.key=eJe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const jh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},lA=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let $1e=null;const Bv=function(t,s,r){let n=$1e||($1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},oOt=function(){$1e=null},o3=function(t,s,r,n){return r&&(cLe(t,s,r,n,-1)||cLe(t,s,r,n,1))},lOt=/^(img|br|input|textarea|hr)$/i;function cLe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:wx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||iR(t)||lOt.test(t.nodeName)||t.contentEditable=="false")return!1;s=jh(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?wx(t):0}else return!1}}function wx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cOt(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=wx(t)}else if(t.parentNode&&!iR(t))s=jh(t),t=t.parentNode;else return null}}function dOt(t,s){for(;;){if(t.nodeType==3&&s2),fx=cA||(R0?/Mac/.test(R0.platform):!1),rJe=R0?/Win/.test(R0.platform):!1,r1=/Android \d/.test(qw),oR=!!dLe&&"webkitFontSmoothing"in dLe.documentElement.style,pOt=oR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fOt(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 Tv(t,s){return typeof t=="number"?t:t[s]}function xOt(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 uLe(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=lA(l);continue}let i=l,c=i==o.body,u=c?fOt(o):xOt(i),m=0,f=0;if(s.topu.bottom-Tv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+Tv(a,"top")-u.top:s.bottom-u.bottom+Tv(a,"bottom")),s.leftu.right-Tv(n,"right")&&(m=s.right-u.right+Tv(a,"right")),m||f)if(c)o.defaultView.scrollBy(m,f);else{let y=i.scrollLeft,_=i.scrollTop;f&&(i.scrollTop+=f),m&&(i.scrollLeft+=m);let w=i.scrollLeft-y,j=i.scrollTop-_;s={left:s.left-w,top:s.top-j,right:s.right-w,bottom:s.bottom-j}}let g=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:lA(l)}}function gOt(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:nJe(t.dom)}}function nJe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=lA(n));return s}function yOt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;aJe(r,n==0?0:n-s)}function aJe(t,s){for(let r=0;r=i){l=Math.max(_.bottom,l),i=Math.min(_.top,i);let w=_.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=m,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?bOt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:iJe(r,a)}function bOt(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 YNe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function _Ot(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 jOt(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 oJe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;oR&&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=jOt(t,n,a,s))}i==null&&(i=wOt(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function hLe(t){return t.top=0&&a==n.nodeValue.length?(c--,m=1):r<0?c--:u++,fI(Qb(Bv(n,c,u),m),m<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==wx(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return bge(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==wx(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Bv(c,wx(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return fI(Qb(u,1),!1)}if(o==null&&a=0)}function fI(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 bge(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 cJe(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 SOt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return cJe(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=lJe(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=Bv(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;um.top+1&&(r=="up"?l.top-m.top>(m.bottom-l.top)*2:m.bottom-l.bottom>(l.bottom-m.top)*2))return!1}}return!0})}const COt=/[\u0590-\u08ac]/;function MOt(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?!COt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:cJe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:m,anchorOffset:f}=t.domSelectionRange(),g=i.caretBidiLevel;i.modify("move",r,"character");let y=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:_,focusOffset:w}=t.domSelectionRange(),j=_&&!y.contains(_.nodeType==1?_:_.parentNode)||c==_&&u==w;try{i.collapse(m,f),c&&(c!=m||u!=f)&&i.extend&&i.extend(c,u)}catch{}return g!=null&&(i.caretBidiLevel=g),j}):n.pos==n.start()||n.pos==n.end()}let mLe=null,pLe=null,fLe=!1;function TOt(t,s,r){return mLe==s&&pLe==r?fLe:(mLe=s,pLe=r,fLe=r=="up"||r=="down"?SOt(t,s,r):MOt(t,s,r))}const Rx=0,xLe=1,M4=2,F0=3;class lR{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Rx,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;rjh(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 uJe){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 dJe&&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?jh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=m&&r<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(s,r,m);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=jh(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 m=i+1;m_&&lr){let _=i;i=c,c=_}let y=document.createRange();y.setEnd(c.node,c.offset),y.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(y)}}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?M4:xLe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=F0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?M4:F0}n=l}this.dirty=M4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?M4:xLe;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==Rx&&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 AOt extends lR{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 l3 extends lR{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=I3.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new l3(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&F0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=F0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Rx){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=G1e(o,0,s,n));for(let i=0;i{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},n,a),m=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!m)m=document.createTextNode(r.text);else if(m.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else m||({dom:m,contentDOM:f}=I3.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&m.nodeName!="BR"&&(m.hasAttribute("contenteditable")||(m.contentEditable="false"),r.type.spec.draggable&&(m.draggable=!0));let g=m;return m=pJe(m,n,r),u?c=new EOt(s,r,n,a,m,f||null,g,u,o,l+1):r.isText?new Hue(s,r,n,a,m,g,o):new lw(s,r,n,a,m,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=()=>Rr.empty)}return s}matchesNode(s,r,n){return this.dirty==Rx&&s.eq(this.node)&&ple(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 IOt(this,l&&l.node,s);OOt(this.node,this.innerDeco,(u,m,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&c.syncToMarks(m==this.node.childCount?Ol.none:this.node.child(m).marks,n,s),c.placeWidget(u,s,a)},(u,m,f,g)=>{c.syncToMarks(u.marks,n,s);let y;c.findNodeMatch(u,m,f,g)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,m,f,y,s)||c.updateNextNode(u,m,f,s,g,a)||c.addNode(u,m,f,s,a),a+=u.nodeSize}),c.syncToMarks([],n,s),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==M4)&&(l&&this.protectLocalComposition(s,l),hJe(this.contentDOM,this.children,s),cA&&ROt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof ni)||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=FOt(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 AOt(this,o,r,a);s.input.compositionNodes.push(l),this.children=G1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==F0||!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=Rx}updateOuterDeco(s){if(ple(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=mJe(this.dom,this.nodeDOM,H1e(this.outerDeco,this.node,r),H1e(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 gLe(t,s,r,n,a){pJe(n,s,t);let o=new lw(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Hue extends lw{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==F0||this.dirty!=Rx&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Rx||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=Rx,!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 Hue(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=F0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class uJe extends lR{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Rx&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class EOt extends lw{constructor(s,r,n,a,o,l,i,c,u,m){super(s,r,n,a,o,l,i,u,m),this.spec=c}update(s,r,n,a){if(this.dirty==F0)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 hJe(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=l3.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 l3)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 DOt(t,s){return t.type.side-s.type.side}function OOt(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 j=_;l!j.inline):i.slice();n(g,w,s.forChild(o,g),y),o=_}}function ROt(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 FOt(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 G1e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||m<=s?o.push(c):(ur&&o.push(c.slice(r-u,c.size,n)))}return o}function QNe(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(Vue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Qa.isSelectable(f)&&a.parent&&!(f.isInline&&uOt(r.focusNode,r.focusOffset,a.dom))){let g=a.posBefore;u=new Qa(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 y=0;y{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!fJe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function BOt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,jh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Ep&&ow<=11&&(r.disabled=!0,r.disabled=!1)}function xJe(t,s){if(s instanceof Qa){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(wLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else wLe(t)}function wLe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function XNe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||ni.between(s,r,n)}function jLe(t){return t.editable&&!t.hasFocus()?!1:gJe(t)}function gJe(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 $Ot(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return o3(s.node,s.offset,r.anchorNode,r.anchorOffset)}function W1e(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&&_i.findFrom(o,s)}function r_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function NLe(t,s,r){let n=t.state.selection;if(n instanceof ni)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 r_(t,new ni(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=W1e(t.state,s);return a&&a instanceof Qa?r_(t,a):!1}else if(!(fx&&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?Qa.isSelectable(o)?r_(t,new Qa(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):oR?r_(t,new ni(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Qa&&n.node.isInline)return r_(t,new ni(s>0?n.$to:n.$from));{let a=W1e(t.state,s);return a?r_(t,a):!1}}}function fle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function b8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function z5(t,s){return s<0?qOt(t):UOt(t)}function qOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Ox&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(b8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(yJe(r))break;{let i=r.previousSibling;for(;i&&b8(i,-1);)a=r.parentNode,o=jh(i),i=i.previousSibling;if(i)r=i,n=fle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?K1e(t,r,n):a&&K1e(t,a,o)}function UOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=fle(r),o,l;for(;;)if(n{t.state==a&&w1(t)},50)}function kLe(t,s){let r=t.state.doc.resolve(s);if(!(eh||rJe)&&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 SLe(t,s,r){let n=t.state.selection;if(n instanceof ni&&!n.empty||r.indexOf("s")>-1||fx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=W1e(t.state,s);if(l&&l instanceof Qa)return r_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof jf?_i.near(l,s):_i.findFrom(l,s);return i?r_(t,i):!1}return!1}function CLe(t,s){if(!(t.state.selection instanceof ni))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 MLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function GOt(t){if(!sm||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;MLe(t,n,"true"),setTimeout(()=>MLe(t,n,"false"),20)}return!1}function WOt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function KOt(t,s){let r=s.keyCode,n=WOt(s);if(r==8||fx&&r==72&&n=="c")return CLe(t,-1)||z5(t,-1);if(r==46&&!s.shiftKey||fx&&r==68&&n=="c")return CLe(t,1)||z5(t,1);if(r==13||r==27)return!0;if(r==37||fx&&r==66&&n=="c"){let a=r==37?kLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return NLe(t,a,n)||z5(t,a)}else if(r==39||fx&&r==70&&n=="c"){let a=r==39?kLe(t,t.state.selection.from)=="ltr"?1:-1:1;return NLe(t,a,n)||z5(t,a)}else{if(r==38||fx&&r==80&&n=="c")return SLe(t,-1,n)||z5(t,-1);if(r==40||fx&&r==78&&n=="c")return GOt(t)||SLe(t,1,n)||z5(t,1);if(n==(fx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function JNe(t,s){t.someProp("transformCopied",y=>{s=y(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 y=n.firstChild;r.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),n=y.content}let l=t.someProp("clipboardSerializer")||I3.fromSchema(t.state.schema),i=NJe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,m,f=0;for(;u&&u.nodeType==1&&(m=jJe[u.nodeName.toLowerCase()]);){for(let y=m.length-1;y>=0;y--){let _=i.createElement(m[y]);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",y=>y(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:g,slice:s}}function vJe(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 Sn(Rr.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:y}=t.state,_=I3.fromSchema(y);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=l.appendChild(document.createElement("p"));w&&j.appendChild(_.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=XOt(r),oR&&JOt(l);let u=l&&l.querySelector("[data-pm-slice]"),m=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(m&&m[3])for(let f=+m[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")||g8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||m),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!ZOt.test(g.parentNode.nodeName)?{ignore:!0}:null}})),m)i=eRt(TLe(i,+m[1],+m[2]),m[4]);else if(i=Sn.maxOpen(YOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,g=0;for(let y=i.content.firstChild;f{i=f(i,t,c)}),i}const ZOt=/^(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 YOt(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&&_Je(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=wJe(l[l.length-1],o.length));let m=bJe(i,c);l.push(m),a=a.matchType(m.type),o=c}}),l)return Rr.from(l)}return t}function bJe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Rr.from(t));return t}function _Je(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(Rr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function TLe(t,s,r){return sr})),wge.createHTML(t)):t}function XOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=NJe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&jJe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=QOt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Rr.from(c.create(n[i+1],a)),o++,l++}return new Sn(a,o,l)}const Vm={},Hm={},tRt={touchstart:!0,touchmove:!0};class sRt{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 rRt(t){for(let s in Vm){let r=Vm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{aRt(t,n)&&!eke(t,n)&&(t.editable||!(n.type in Hm))&&r(t,n)},tRt[s]?{passive:!0}:void 0)}sm&&t.dom.addEventListener("input",()=>null),Y1e(t)}function O_(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function nRt(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 Y1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>eke(t,n))})}function eke(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function aRt(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 iRt(t,s){!eke(t,s)&&Vm[s.type]&&(t.editable||!(s.type in Hm))&&Vm[s.type](t,s)}Hm.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!SJe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(r1&&eh&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),cA&&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,x4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||KOt(t,r)?r.preventDefault():O_(t,"key")};Hm.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Hm.keypress=(t,s)=>{let r=s;if(SJe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||fx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof ni)||!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 Gue(t){return{left:t.clientX,top:t.clientY}}function oRt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function tke(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 yT(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 lRt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Qa.isSelectable(n)?(yT(t,new Qa(r)),!0):!1}function cRt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Qa&&(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(Qa.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?(yT(t,Qa.create(t.state.doc,a)),!0):!1}function dRt(t,s,r,n,a){return tke(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?cRt(t,r):lRt(t,r))}function uRt(t,s,r,n){return tke(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function hRt(t,s,r,n){return tke(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||mRt(t,r,n)}function mRt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(yT(t,ni.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)yT(t,ni.create(n,i+1,i+1+l.content.size));else if(Qa.isSelectable(l))yT(t,Qa.create(n,i));else continue;return!0}}function ske(t){return xle(t)}const kJe=fx?"metaKey":"ctrlKey";Vm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=ske(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&oRt(r,t.input.lastClick)&&!r[kJe]&&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(Gue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new pRt(t,l,r,!!n)):(o=="doubleClick"?uRt:hRt)(t,l.pos,l.inside,r)?r.preventDefault():O_(t,"pointer"))};class pRt{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[kJe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let m=s.state.doc.resolve(r.pos);o=m.parent,l=m.depth?m.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 Qa&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ox&&!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)),O_(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(()=>w1(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(Gue(s))),this.updateAllowDefault(s),this.allowDefault||!r?O_(this.view,"pointer"):dRt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||sm&&this.mightDrag&&!this.mightDrag.node.isAtom||eh&&!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)?(yT(this.view,_i.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):O_(this.view,"pointer")}move(s){this.updateAllowDefault(s),O_(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)}}Vm.touchstart=t=>{t.input.lastTouch=Date.now(),ske(t),O_(t,"pointer")};Vm.touchmove=t=>{t.input.lastTouch=Date.now(),O_(t,"pointer")};Vm.contextmenu=t=>ske(t);function SJe(t,s){return t.composing?!0:sm&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const fRt=r1?5e3:-1;Hm.compositionstart=Hm.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof ni&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||eh&&rJe&&xRt(t)))t.markCursor=t.state.storedMarks||r.marks(),xle(t,!0),t.markCursor=null;else if(xle(t,!s.selection.empty),Ox&&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}CJe(t,fRt)};function xRt(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"}Hm.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++,CJe(t,20))};function CJe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>xle(t),s))}function MJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=yRt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function gRt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=cOt(s.focusNode,s.focusOffset),n=dOt(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 yRt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function xle(t,s=!1){if(!(r1&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),MJe(t),s||t.docView&&t.docView.dirty){let r=QNe(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 vRt(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 MD=Ep&&ow<15||cA&&pOt<604;Vm.copy=Hm.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=MD?null:r.clipboardData,l=n.content(),{dom:i,text:c}=JNe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):vRt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function bRt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function _Rt(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?TD(t,n.value,null,a,s):TD(t,n.textContent,n.innerHTML,a,s)},50)}function TD(t,s,r,n,a){let o=vJe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||Sn.empty)))return!0;if(!o)return!1;let l=bRt(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 TJe(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," "):""}Hm.paste=(t,s)=>{let r=s;if(t.composing&&!r1)return;let n=MD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&TD(t,TJe(n),n.getData("text/html"),a,r)?r.preventDefault():_Rt(t,r)};class AJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const wRt=fx?"altKey":"ctrlKey";function EJe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[wRt]}Vm.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(Gue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Qa?a.to-1:a.to))){if(n&&n.mightDrag)l=Qa.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=Qa.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:m}=JNe(t,i);(!r.dataTransfer.files.length||!eh||sJe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(MD?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",MD||r.dataTransfer.setData("text/plain",u),t.dragging=new AJe(m,EJe(t,r),l)};Vm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Hm.dragover=Hm.dragenter=(t,s)=>s.preventDefault();Hm.drop=(t,s)=>{try{jRt(t,s,t.dragging)}finally{t.dragging=null}};function jRt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Gue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",y=>{o=y(o,t,!1)}):o=vJe(t,TJe(s.dataTransfer),MD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&EJe(t,s));if(t.someProp("handleDrop",y=>y(t,s,o||Sn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?WXe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:y}=r;y?y.replace(c):c.deleteSelection()}let u=c.mapping.map(i),m=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(m?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let g=c.doc.resolve(u);if(m&&Qa.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Qa(g));else{let y=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((_,w,j,N)=>y=N),c.setSelection(XNe(t,g,c.doc.resolve(y)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Vm.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())&&w1(t)},20))};Vm.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)};Vm.beforeinput=(t,s)=>{if(eh&&r1&&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,x4(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 Hm)Vm[t]=Hm[t];function AD(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 gle{constructor(s,r){this.toDOM=s,this.spec=r||LS,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 Im(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof gle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&AD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class cw{constructor(s,r){this.attrs=s,this.spec=r||LS}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 Im(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==Vh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||LS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,m;if(m=IJe(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 cw){let u=Math.max(o,c.from)-o,m=Math.min(l,c.to)-o;ua.map(s,r,LS));return p_.from(n)}forChild(s,r){if(r.isLeaf)return gd.empty;let n=[];for(let a=0;ar instanceof gd)?s:s.reduce((r,n)=>r.concat(n instanceof gd?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let j=w-_-(y-g);for(let N=0;NS+m-f)continue;let M=i[N]+m-f;y>=M?i[N+1]=g<=M?-2:-1:g>=m&&j&&(i[N]+=j,i[N+1]+=j)}f+=j}),m=r.maps[u].map(m,-1)}let c=!1;for(let u=0;u=n.content.size){c=!0;continue}let g=r.map(t[u+1]+o,-1),y=g-a,{index:_,offset:w}=n.content.findIndex(f),j=n.maybeChild(_);if(j&&w==f&&w+j.nodeSize==y){let N=i[u+2].mapInner(r,j,m+1,t[u]+o+1,l);N!=Vh?(i[u]=f,i[u+1]=y,i[u+2]=N):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=kRt(i,t,s,r,a,o,l),m=yle(u,n,0,l);s=m.local;for(let f=0;fr&&l.to{let u=IJe(t,i,c+r);if(u){o=!0;let m=yle(u,i,r+c+1,n);m!=Vh&&a.push(c,c+i.nodeSize,m)}});let l=PJe(o?LJe(t):t,-r).sort(DS);for(let i=0;i0;)s++;t.splice(s,0,r)}function jge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Vh&&s.push(n)}),t.cursorWrapper&&s.push(gd.create(t.state.doc,[t.cursorWrapper.deco])),p_.from(s)}const SRt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CRt=Ep&&ow<=11;class MRt{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 TRt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MRt,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()}),CRt&&(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,SRt)),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(jLe(this.view)){if(this.suppressingSelectionUpdates)return w1(this.view);if(Ep&&ow<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&o3(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=lA(o))r.add(o);for(let o=s.anchorNode;o;o=lA(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)&&jLe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,c=[];if(s.editable)for(let m=0;mf.nodeName=="BR");if(m.length==2){let[f,g]=m;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of m){let y=g.parentNode;y&&y.nodeName=="LI"&&(!f||PRt(s,f)!=y)&&g.remove()}}}else if((eh||sm)&&c.some(m=>m.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let m of c)if(m.nodeName=="BR"&&m.parentNode){let f=m.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&m.parentNode.removeChild(m)}}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),ARt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||w1(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 m=0;ma;j--){let N=n.childNodes[j-1],S=N.pmViewDesc;if(N.nodeName=="BR"&&!S){o=j;break}if(!S||S.size)break}let f=t.state.doc,g=t.someProp("domParser")||g8.fromSchema(t.state.schema),y=f.resolve(l),_=null,w=g.parse(n,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:a,to:o,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:LRt,context:y});if(u&&u[0].pos!=null){let j=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=j),_={anchor:j+l,head:N+l}}return{doc:w,sel:_,from:l,to:i}}function LRt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(sm&&/^(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||sm&&/^(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 DRt=/^(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 ORt(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,$=QNe(t,q);if($&&!t.state.selection.eq($)){if(eh&&r1&&t.input.lastKeyCode===13&&Date.now()-100V(t,x4(13,"Enter"))))return;let z=t.state.tr.setSelection($);q=="pointer"?z.setMeta("pointer",!0):q=="key"&&z.scrollIntoView(),o&&z.setMeta("composition",o),t.dispatch(z)}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=IRt(t,s,r),m=t.state.doc,f=m.slice(u.from,u.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||r1)&&a.some(q=>q.nodeType==1&&!DRt.test(q.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",q=>q(t,x4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(n&&c instanceof ni&&!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=DLe(t,t.state.doc,u.sel);if(q&&!q.eq(t.state.selection)){let $=t.state.tr.setSelection(q);o&&$.setMeta("composition",o),t.dispatch($)}}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)),Ep&&ow<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>u.from&&u.doc.textBetween(_.start-u.from-1,_.start-u.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let w=u.doc.resolveNoCache(_.start-u.from),j=u.doc.resolveNoCache(_.endB-u.from),N=m.resolve(_.start),S=w.sameParent(j)&&w.parent.inlineContent&&N.end()>=_.endA;if((cA&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some(q=>q.nodeName=="DIV"||q.nodeName=="P"))||!S&&w.posq(t,x4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&FRt(m,_.start,_.endA,w,j)&&t.someProp("handleKeyDown",q=>q(t,x4(8,"Backspace")))){r1&&eh&&t.domObserver.suppressSelectionUpdates();return}eh&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),r1&&!S&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==_.endA&&(_.endB-=2,j=u.doc.resolveNoCache(_.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(q){return q(t,x4(13,"Enter"))})},20));let M=_.start,I=_.endA,P=q=>{let $=q||t.state.tr.replace(M,I,u.doc.slice(_.start-u.from,_.endB-u.from));if(u.sel){let z=DLe(t,$.doc,u.sel);z&&!(eh&&t.composing&&z.empty&&(_.start!=_.endB||t.input.lastChromeDeletew1(t),20));let q=P(t.state.tr.delete(M,I)),$=m.resolve(_.start).marksAcross(m.resolve(_.endA));$&&q.ensureMarks($),t.dispatch(q)}else if(_.endA==_.endB&&(O=RRt(w.parent.content.cut(w.parentOffset,j.parentOffset),N.parent.content.cut(N.parentOffset,_.endA-N.start())))){let q=P(t.state.tr);O.type=="add"?q.addMark(M,I,O.mark):q.removeMark(M,I,O.mark),t.dispatch(q)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let q=w.parent.textBetween(w.parentOffset,j.parentOffset),$=()=>P(t.state.tr.insertText(q,M,I));t.someProp("handleTextInput",z=>z(t,M,I,q,$))||t.dispatch($())}else t.dispatch(P());else t.dispatch(P())}function DLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:XNe(t,s.resolve(r.anchor),s.resolve(r.head))}function RRt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,c;for(let m=0;mm.mark(i.addToSet(m.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",c=m=>m.mark(i.removeFromSet(m.marks));else return null;let u=[];for(let m=0;mr||Nge(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 zRt(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 DJe{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 sRt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach($Le),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=zLe(this),FLe(this),this.nodeViews=BLe(this),this.docView=gLe(this.state.doc,RLe(this),jge(this),this.dom,this),this.domObserver=new TRt(this,(n,a,o,l)=>ORt(this,n,a,o,l)),this.domObserver.start(),rRt(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&&Y1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach($Le),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&&(MJe(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 y=BLe(this);$Rt(y,this.nodeViews)&&(this.nodeViews=y,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&Y1e(this),this.editable=zLe(this),FLe(this);let c=jge(this),u=RLe(this),m=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=m=="preserve"&&l&&this.dom.style.overflowAnchor==null&&gOt(this);if(l){this.domObserver.stop();let y=f&&(Ep||eh)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&BRt(a.selection,s.selection);if(f){let _=eh?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gRt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=gLe(s.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$Ot(this))?w1(this,y):(xJe(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),m=="reset"?this.dom.scrollTop=0:m=="to selection"?this.scrollToSelection():g&&yOt(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 Qa){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&uLe(this,r.getBoundingClientRect(),s)}else uLe(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 AJe(s.slice,s.move,a<0?void 0:Qa.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 NOt(this,s)}coordsAtPos(s,r=1){return lJe(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 TOt(this,r||this.state,s)}pasteHTML(s,r){return TD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return TD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return JNe(this,s)}destroy(){this.docView&&(nRt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,oOt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return iRt(this,s)}domSelectionRange(){let s=this.domSelection();return s?sm&&this.root.nodeType===11&&hOt(this.dom.ownerDocument)==this.dom&&ERt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}DJe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function RLe(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"),[Im.node(0,t.state.doc.content.size,s)]}function FLe(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:Im.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function zLe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function BRt(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 BLe(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 $Rt(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 $Le(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 kw={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:"'"},vle={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},qRt=typeof navigator<"u"&&/Mac/.test(navigator.platform),URt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Nh=0;Nh<10;Nh++)kw[48+Nh]=kw[96+Nh]=String(Nh);for(var Nh=1;Nh<=24;Nh++)kw[Nh+111]="F"+Nh;for(var Nh=65;Nh<=90;Nh++)kw[Nh]=String.fromCharCode(Nh+32),vle[Nh]=String.fromCharCode(Nh);for(var kge in kw)vle.hasOwnProperty(kge)||(vle[kge]=kw[kge]);function VRt(t){var s=qRt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||URt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?vle:kw)[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 HRt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),GRt=typeof navigator<"u"&&/Win/.test(navigator.platform);function WRt(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 OJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const RJe=(t,s,r)=>{let n=OJe(t,r);if(!n)return!1;let a=oke(n);if(!a){let l=n.blockRange(),i=l&&wE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(GJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(dA(o,"end")||Qa.isSelectable(o)))for(let l=n.depth;;l--){let i=que(t.doc,n.before(l),n.after(l),Sn.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},YRt=(t,s,r)=>{let n=OJe(t,r);if(!n)return!1;let a=oke(n);return a?FJe(t,a,s):!1},QRt=(t,s,r)=>{let n=BJe(t,r);if(!n)return!1;let a=lke(n);return a?FJe(t,a,s):!1};function FJe(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 m=a.lastChild;if(!m)return!1;a=m}let l=s.nodeAfter,i=l,c=s.pos+1;for(;!i.isTextblock;c++){if(i.type.spec.isolating)return!1;let m=i.firstChild;if(!m)return!1;i=m}let u=que(t.doc,o,c,Sn.empty);if(!u||u.from!=o||u instanceof Xu&&u.slice.size>=c-o)return!1;if(r){let m=t.tr.step(u);m.setSelection(ni.create(m.doc,o)),r(m.scrollIntoView())}return!0}function dA(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 zJe=(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=oke(n)}let l=o&&o.nodeBefore;return!l||!Qa.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Qa.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function oke(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 BJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=BJe(t,r);if(!n)return!1;let a=lke(n);if(!a)return!1;let o=a.nodeAfter;if(GJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(dA(o,"start")||Qa.isSelectable(o))){let l=que(t.doc,n.before(),n.after(),Sn.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 Qa,a;if(n){if(r.node.isTextblock||!$w(t.doc,r.from))return!1;a=r.from}else if(a=$ue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Qa.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},JRt=(t,s)=>{let r=t.selection,n;if(r instanceof Qa){if(r.node.isTextblock||!$w(t.doc,r.to))return!1;n=r.to}else if(n=$ue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},eFt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&wE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},UJe=(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 cke(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=cke(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(_i.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},VJe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof jf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=cke(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(_1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&wE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function sFt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Qa&&s.selection.node.isBlock)return!n.parentOffset||!_1(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 y=n.depth;;y--)if(n.node(y).isBlock){c=n.end(y)==n.pos+(n.depth-y),u=n.start(y)==n.pos-(n.depth-y),i=cke(n.node(y-1).contentMatchAt(n.indexAfter(y-1))),o.unshift(c&&i?{type:i}:null),l=y;break}else{if(y==1)return!1;o.unshift(null)}let m=s.tr;(s.selection instanceof ni||s.selection instanceof jf)&&m.deleteSelection();let f=m.mapping.map(n.pos),g=_1(m.doc,f,o.length,o);if(g||(o[0]=i?{type:i}:null,g=_1(m.doc,f,o.length,o)),!g)return!1;if(m.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let y=m.mapping.map(n.before(l)),_=m.doc.resolve(y);i&&n.node(l-1).canReplaceWith(_.index(),_.index()+1,i)&&m.setNodeMarkup(m.mapping.map(n.before(l)),i)}return r&&r(m.scrollIntoView()),!0}}const rFt=sFt(),nFt=(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(Qa.create(t.doc,a))),!0)};function aFt(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||$w(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function GJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&aFt(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 y=s.pos+o.nodeSize,_=Rr.empty;for(let N=l.length-1;N>=0;N--)_=Rr.from(l[N].create(null,_));_=Rr.from(a.copy(_));let w=t.tr.step(new ih(s.pos-1,y,s.pos,y,new Sn(_,1,0),l.length,!0)),j=w.doc.resolve(y+2*l.length);j.nodeAfter&&j.nodeAfter.type==a.type&&$w(w.doc,j.pos)&&w.join(j.pos),r(w.scrollIntoView())}return!0}let m=o.type.spec.isolating||n>0&&c?null:_i.findFrom(s,1),f=m&&m.$from.blockRange(m.$to),g=f&&wE(f);if(g!=null&&g>=s.depth)return r&&r(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&dA(o,"start",!0)&&dA(a,"end")){let y=a,_=[];for(;_.push(y),!y.isTextblock;)y=y.lastChild;let w=o,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(r){let N=Rr.empty;for(let M=_.length-1;M>=0;M--)N=Rr.from(_[M].copy(N));let S=t.tr.step(new ih(s.pos-_.length,s.pos+o.nodeSize,s.pos+j,s.pos+o.nodeSize-j,new Sn(N,_.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function WJe(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(ni.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const iFt=WJe(-1),oFt=WJe(1);function lFt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&WNe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function qLe(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 m=r.doc.resolve(u),f=m.index();a=m.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 hle(c,c,s.depth),s.endIndex=0;m--)o=Rr.from(r[m].type.create(r[m].attrs,o));t.step(new ih(s.start-(n?2:0),s.end,s.start,s.end,new Sn(o,0,0),r.length,!0));let l=0;for(let m=0;ml.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?mFt(s,r,t,o):pFt(s,r,o):!0:!1}}function mFt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;_--)y-=a.child(_).nodeSize,n.delete(y-1,y+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),m=o.index(-1);if(!u.canReplace(m+(i?0:1),m+1,l.content.append(c?Rr.empty:Rr.from(a))))return!1;let f=o.pos,g=f+l.nodeSize;return n.step(new ih(f-(i?1:0),g+(c?1:0),f+1,g-1,new Sn((i?Rr.empty:Rr.from(a.copy(Rr.empty))).append(c?Rr.empty:Rr.from(a.copy(Rr.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function fFt(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,m=Rr.from(u?t.create():null),f=new Sn(Rr.from(t.create(null,Rr.from(i.type.create(null,m)))),u?3:1,0),g=o.start,y=o.end;r(s.tr.step(new ih(g-(u?3:1),y,g,y,f,1,!0)).scrollIntoView())}return!0}}function Wue(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 Kue{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,(...m)=>{const f=c(...m)(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,m=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(g=>g===!0)),f={...Object.fromEntries(Object.entries(n).map(([g,y])=>[g,(...w)=>{const j=this.buildProps(u,r),N=y(...w)(j);return i.push(N),f}])),run:m};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,(...m)=>u(...m)({...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:Wue({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,(...m)=>u(...m)(i)]))}};return i}}let xFt=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 ma(t,s,r){return t.config[s]===void 0&&t.parent?ma(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?ma(t.parent,s,r):null}):t.config[s]}function Zue(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 KJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Zue(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=ma(l,"addGlobalAttributes",i);if(!c)return;c().forEach(m=>{m.types.forEach(f=>{Object.entries(m.attributes).forEach(([g,y])=>{s.push({type:f,name:g,attribute:{...o,...y}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=ma(l,"addAttributes",i);if(!c)return;const u=c();Object.entries(u).forEach(([m,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:m,attribute:g})})}),s}function ch(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 Gc(...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(m=>!c.includes(m));n[a]=[...c,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(m=>m.trim()).filter(Boolean):[],c=n[a]?n[a].split(";").map(m=>m.trim()).filter(Boolean):[],u=new Map;c.forEach(m=>{const[f,g]=m.split(":").map(y=>y.trim());u.set(f,g)}),i.forEach(m=>{const[f,g]=m.split(":").map(y=>y.trim());u.set(f,g)}),n[a]=Array.from(u.entries()).map(([m,f])=>`${m}: ${f}`).join("; ")}else n[a]=o}),n},{})}function Q1e(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)=>Gc(r,n),{})}function ZJe(t){return typeof t=="function"}function ro(t,s=void 0,...r){return ZJe(t)?s?t.bind(s)(...r):t(...r):t}function gFt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function yFt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ULe(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):yFt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function VLe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&gFt(r)?!1:r!=null))}function vFt(t,s){var r;const n=KJe(t),{nodeExtensions:a,markExtensions:o}=Zue(t),l=(r=a.find(u=>ma(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const m=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=ma(S,"extendNodeSchema",f);return{...N,...M?M(u):{}}},{}),y=VLe({...g,content:ro(ma(u,"content",f)),marks:ro(ma(u,"marks",f)),group:ro(ma(u,"group",f)),inline:ro(ma(u,"inline",f)),atom:ro(ma(u,"atom",f)),selectable:ro(ma(u,"selectable",f)),draggable:ro(ma(u,"draggable",f)),code:ro(ma(u,"code",f)),whitespace:ro(ma(u,"whitespace",f)),linebreakReplacement:ro(ma(u,"linebreakReplacement",f)),defining:ro(ma(u,"defining",f)),isolating:ro(ma(u,"isolating",f)),attrs:Object.fromEntries(m.map(N=>{var S;return[N.name,{default:(S=N==null?void 0:N.attribute)===null||S===void 0?void 0:S.default}]}))}),_=ro(ma(u,"parseHTML",f));_&&(y.parseDOM=_.map(N=>ULe(N,m)));const w=ma(u,"renderHTML",f);w&&(y.toDOM=N=>w({node:N,HTMLAttributes:Q1e(N,m)}));const j=ma(u,"renderText",f);return j&&(y.toText=j),[u.name,y]})),c=Object.fromEntries(o.map(u=>{const m=n.filter(j=>j.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((j,N)=>{const S=ma(N,"extendMarkSchema",f);return{...j,...S?S(u):{}}},{}),y=VLe({...g,inclusive:ro(ma(u,"inclusive",f)),excludes:ro(ma(u,"excludes",f)),group:ro(ma(u,"group",f)),spanning:ro(ma(u,"spanning",f)),code:ro(ma(u,"code",f)),attrs:Object.fromEntries(m.map(j=>{var N;return[j.name,{default:(N=j==null?void 0:j.attribute)===null||N===void 0?void 0:N.default}]}))}),_=ro(ma(u,"parseHTML",f));_&&(y.parseDOM=_.map(j=>ULe(j,m)));const w=ma(u,"renderHTML",f);return w&&(y.toDOM=j=>w({mark:j,HTMLAttributes:Q1e(j,m)})),[u.name,y]}));return new OXe({topNode:l,nodes:i,marks:c})}function Cge(t,s){return s.nodes[t]||s.marks[t]||null}function HLe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function uke(t,s){const r=I3.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const bFt=(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 m=((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?m:m.slice(0,Math.max(0,n-o))}),r};function hke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Yue{constructor(s){this.find=s.find,this.handler=s.handler}}const _Ft=(t,s)=>{if(hke(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 Tz(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 m=!1;const f=bFt(u)+o;return l.forEach(g=>{if(m)return;const y=_Ft(f,g.find);if(!y)return;const _=c.state.tr,w=Wue({state:c.state,transaction:_}),j={from:n-(y[0].length-o.length),to:a},{commands:N,chain:S,can:M}=new Kue({editor:r,state:w});g.handler({state:w,range:j,match:y,commands:N,chain:S,can:M})===null||!_.steps.length||(_.setMeta(i,{transform:_,from:n,to:a,text:o}),c.dispatch(_),m=!0)}),m}function wFt(t){const{editor:s,rules:r}=t,n=new Ru({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:m}=c;typeof m=="string"?m=m:m=uke(Rr.from(m),l.schema);const{from:f}=c,g=f+m.length;Tz({editor:s,from:f,to:g,text:m,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return Tz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&Tz({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?Tz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function jFt(t){return Object.prototype.toString.call(t).slice(8,-1)}function Az(t){return jFt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Que(t,s){const r={...t};return Az(t)&&Az(s)&&Object.keys(s).forEach(n=>{Az(s[n])&&Az(t[n])?r[n]=Que(t[n],s[n]):r[n]=s[n]}),r}class uy{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=ro(ma(this,"addOptions",{name:this.name}))),this.storage=ro(ma(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new uy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Que(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new uy(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=ro(ma(r,"addOptions",{name:r.name})),r.storage=ro(ma(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 NFt(t){return typeof t=="number"}class kFt{constructor(s){this.find=s.find,this.handler=s.handler}}const SFt=(t,s,r)=>{if(hke(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 CFt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:m}=new Kue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(y,_)=>{if(!y.isTextblock||y.type.spec.code)return;const w=Math.max(n,_),j=Math.min(a,_+y.content.size),N=y.textBetween(w-_,j-_,void 0,"");SFt(N,o.find,l).forEach(M=>{if(M.index===void 0)return;const I=w+M.index+1,P=I+M[0].length,O={from:r.tr.mapping.map(I),to:r.tr.mapping.map(P)},q=o.handler({state:r,range:O,match:M,commands:c,chain:u,can:m,pasteEvent:l,dropEvent:i});f.push(q)})}),f.every(y=>y!==null)}let Ez=null;const MFt=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 TFt(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:m,from:f,to:g,rule:y,pasteEvt:_})=>{const w=m.tr,j=Wue({state:m,transaction:w});if(!(!CFt({editor:s,state:j,from:Math.max(f-1,0),to:g.b-1,rule:y,pasteEvent:_,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(m=>new Ru({view(f){const g=_=>{var w;n=!((w=f.dom.parentElement)===null||w===void 0)&&w.contains(_.target)?f.dom.parentElement:null,n&&(Ez=s)},y=()=>{Ez&&(Ez=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(o=n===f.dom.parentElement,i=g,!o){const y=Ez;y!=null&&y.isEditable&&setTimeout(()=>{const _=y.state.selection;_&&y.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,g)=>{var y;const _=(y=g.clipboardData)===null||y===void 0?void 0:y.getData("text/html");return l=g,a=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(f,g,y)=>{const _=f[0],w=_.getMeta("uiEvent")==="paste"&&!a,j=_.getMeta("uiEvent")==="drop"&&!o,N=_.getMeta("applyPasteRules"),S=!!N;if(!w&&!j&&!S)return;if(S){let{text:P}=N;typeof P=="string"?P=P:P=uke(Rr.from(P),y.schema);const{from:O}=N,q=O+P.length,$=MFt(P);return c({rule:m,state:y,from:O,to:{b:q},pasteEvt:$})}const M=g.doc.content.findDiffStart(y.doc.content),I=g.doc.content.findDiffEnd(y.doc.content);if(!(!NFt(M)||!I||M===I.b))return c({rule:m,state:y,from:M,to:I,pasteEvt:l})}}))}function AFt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class kM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=kM.resolve(s),this.schema=vFt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=kM.sort(kM.flatten(s)),n=AFt(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=ma(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=ma(n,"priority")||100,l=ma(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:Cge(r.name,this.schema)},a=ma(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=kM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:Cge(l.name,this.schema)},c=[],u=ma(l,"addKeyboardShortcuts",i);let m={};if(l.type==="mark"&&ma(l,"exitable",i)&&(m.ArrowRight=()=>uy.handleExit({editor:s,mark:l})),u){const w=Object.fromEntries(Object.entries(u()).map(([j,N])=>[j,()=>N({editor:s})]));m={...m,...w}}const f=ZRt(m);c.push(f);const g=ma(l,"addInputRules",i);HLe(l,s.options.enableInputRules)&&g&&n.push(...g());const y=ma(l,"addPasteRules",i);HLe(l,s.options.enablePasteRules)&&y&&a.push(...y());const _=ma(l,"addProseMirrorPlugins",i);if(_){const w=_();c.push(...w)}return c}).flat();return[wFt({editor:s,rules:n}),...TFt({editor:s,rules:a}),...o]}get attributes(){return KJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Zue(this.extensions);return Object.fromEntries(r.filter(n=>!!ma(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:ch(n.name,this.schema)},l=ma(n,"addNodeView",o);if(!l)return[];const i=(c,u,m,f,g)=>{const y=Q1e(c,a);return l()({node:c,view:u,getPos:m,decorations:f,innerDecorations:g,editor:s,extension:n,HTMLAttributes:y})};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:Cge(s.name,this.schema)};s.type==="mark"&&(!((r=ro(ma(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=ma(s,"onBeforeCreate",n),o=ma(s,"onCreate",n),l=ma(s,"onUpdate",n),i=ma(s,"onSelectionUpdate",n),c=ma(s,"onTransaction",n),u=ma(s,"onFocus",n),m=ma(s,"onBlur",n),f=ma(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),m&&this.editor.on("blur",m),f&&this.editor.on("destroy",f)})}}class Rh{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=ro(ma(this,"addOptions",{name:this.name}))),this.storage=ro(ma(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Rh(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Que(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Rh({...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=ro(ma(r,"addOptions",{name:r.name})),r.storage=ro(ma(r,"addStorage",{name:r.name,options:r.options})),r}}function YJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(c,u,m,f)=>{var g;c.isBlock&&u>n&&(i+=o);const y=l==null?void 0:l[c.type.name];if(y)return m&&(i+=y({node:c,pos:u,parent:m,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 QJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const EFt=Rh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ru({key:new im("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(m=>m.$from.pos)),i=Math.max(...o.map(m=>m.$to.pos)),c=QJe(r);return YJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),PFt=()=>({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),IFt=(t=!1)=>({commands:s})=>s.setContent("",t),LFt=()=>({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:m}=s,f=u.resolve(m.map(c)),g=u.resolve(m.map(c+i.nodeSize)),y=f.blockRange(g);if(!y)return;const _=wE(y);if(i.type.isTextblock){const{defaultType:w}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(y.start,w)}(_||_===0)&&s.lift(y,_)})}),!0},DFt=t=>s=>t(s),OFt=()=>({state:t,dispatch:s})=>VJe(t,s),RFt=(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 ni(n.doc.resolve(Math.max(l-1,0)))),!0},FFt=()=>({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},zFt=t=>({tr:s,state:r,dispatch:n})=>{const a=ch(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},BFt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},$Ft=()=>({state:t,dispatch:s})=>ike(t,s),qFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),UFt=()=>({state:t,dispatch:s})=>tFt(t,s);function ble(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:hke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function XJe(t,s,r={}){return t.find(n=>n.type===s&&ble(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function GLe(t,s,r={}){return!!XJe(t,s,r)}function mke(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(m=>m.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(m=>m.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!XJe([...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&&GLe([...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=Uw(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:m}=i;if(a){const f=mke(c,o,s);if(f&&f.from<=u&&f.to>=m){const g=ni.create(l,f.from,f.to);r.setSelection(g)}}return!0},HFt=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=()=>{(pke()||GFt())&&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&&!JJe(r.state.selection))return l(),!0;const i=eet(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},KFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),ZFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),tet=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&&tet(n)}return t};function Pz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return tet(r)}function ED(t,s,r){if(t instanceof iw||t instanceof Rr)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 Rr.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),ED("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new OXe({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?g8.fromSchema(c).parseSlice(Pz(t),r.parseOptions):g8.fromSchema(c).parse(Pz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=g8.fromSchema(s);return r.slice?o.parseSlice(Pz(t),r.parseOptions).content:o.parse(Pz(t),r.parseOptions)}return ED("",s,r)}function YFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=m)}),t.setSelection(_i.near(t.doc.resolve(l),r))}const QFt=t=>!("type"in t),XFt=(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=j=>{o.emit("contentError",{editor:o,error:j,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{ED(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(j){c(j)}try{i=ED(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(j){return c(j),!1}let{from:m,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((QFt(i)?i:[i]).forEach(j=>{j.check(),g=g?j.isText&&j.marks.length===0:!1,y=y?j.isBlock:!1}),m===f&&y){const{parent:j}=n.doc.resolve(m);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(m-=1,f+=1)}let w;if(g){if(Array.isArray(s))w=s.map(j=>j.text||"").join("");else if(s instanceof Rr){let j="";s.forEach(N=>{N.text&&(j+=N.text)}),w=j}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,m,f)}else w=i,n.replaceWith(m,f,w);r.updateSelection&&YFt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:m,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:m,text:w})}return!0},JFt=()=>({state:t,dispatch:s})=>XRt(t,s),e7t=()=>({state:t,dispatch:s})=>JRt(t,s),t7t=()=>({state:t,dispatch:s})=>RJe(t,s),s7t=()=>({state:t,dispatch:s})=>$Je(t,s),r7t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=$ue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},n7t=()=>({state:t,dispatch:s,tr:r})=>{try{const n=$ue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},a7t=()=>({state:t,dispatch:s})=>YRt(t,s),i7t=()=>({state:t,dispatch:s})=>QRt(t,s);function set(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function o7t(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=o7t(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 m=u.map(n.mapping);m&&a&&n.maybeStep(m)}),!0};function PD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?ch(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,g)=>{if(f.isText)return;const y=Math.max(n,g),_=Math.min(a,g+f.nodeSize);i.push({node:f,from:y,to:_})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>ble(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}const c7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ch(t,r.schema);return PD(r,a,s)?eFt(r,n):!1},d7t=()=>({state:t,dispatch:s})=>HJe(t,s),u7t=t=>({state:s,dispatch:r})=>{const n=ch(t,s.schema);return hFt(n)(s,r)},h7t=()=>({state:t,dispatch:s})=>UJe(t,s);function Xue(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function WLe(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 m7t=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Xue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ch(t,n.schema)),i==="mark"&&(l=Uw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,m)=>{o&&o===u.type&&r.setNodeMarkup(m,void 0,WLe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(m,m+u.nodeSize,l.create(WLe(f.attrs,s)))})})}),!0):!1},p7t=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),f7t=()=>({tr:t,dispatch:s})=>{if(s){const r=new jf(t.doc);t.setSelection(r)}return!0},x7t=()=>({state:t,dispatch:s})=>zJe(t,s),g7t=()=>({state:t,dispatch:s})=>qJe(t,s),y7t=()=>({state:t,dispatch:s})=>nFt(t,s),v7t=()=>({state:t,dispatch:s})=>oFt(t,s),b7t=()=>({state:t,dispatch:s})=>iFt(t,s);function X1e(t,s,r={},n={}){return ED(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const _7t=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var c,u;const{doc:m}=o;if(r.preserveWhitespace!=="full"){const f=X1e(t,a.schema,r,{errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:a.options.enableContentCheck});return l&&o.replaceWith(0,m.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:m.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function ret(t,s){const r=Uw(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 w7t(t,s){const r=new KNe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function j7t(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function net(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 fke(t){return s=>net(s.$from,t)}function k7t(t,s){const r={from:0,to:t.content.size};return YJe(t,r,s)}function S7t(t,s){const r=ch(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 aet(t,s){const r=Xue(typeof s=="string"?s:s.name,t.schema);return r==="node"?S7t(t,s):r==="mark"?ret(t,s):{}}function C7t(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 M7t(t){const s=C7t(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 T7t(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),m=s.slice(o).map(c),f=s.invert().map(u,-1),g=s.invert().map(m);n.push({oldRange:{from:f,to:g},newRange:{from:u,to:m}})})}),M7t(n)}function xke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=mke(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 Fie(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 J1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?Uw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>ble(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:g})=>{const y=f.pos,_=g.pos;t.doc.nodesBetween(y,_,(w,j)=>{if(!w.isText&&!w.marks.length)return;const N=Math.max(y,j),S=Math.min(_,j+w.nodeSize),M=S-N;l+=M,i.push(...w.marks.map(I=>({mark:I,from:N,to:S})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>ble(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 A7t(t,s,r={}){if(!s)return PD(t,null,r)||J1e(t,null,r);const n=Xue(s,t.schema);return n==="node"?PD(t,s,r):n==="mark"?J1e(t,s,r):!1}function KLe(t,s){const{nodeExtensions:r}=Zue(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=ro(ma(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function gke(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&&(gke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function E7t(t){return t instanceof Qa}function P7t(t,s,r){var n;const{selection:a}=s;let o=null;if(JJe(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,(m,f,g)=>{if(u)return!1;if(m.isInline){const y=!g||g.type.allowsMarkType(r),_=!!r.isInSet(m.marks)||!m.marks.some(w=>w.type.excludes(r));u=y&&_}return!u}),u})}const I7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=Uw(t,n.schema);if(a)if(l){const u=ret(n,c);r.addStoredMark(c.create({...u,...s}))}else i.forEach(u=>{const m=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(m,f,(g,y)=>{const _=Math.max(y,m),w=Math.min(y+g.nodeSize,f);g.marks.find(N=>N.type===c)?g.marks.forEach(N=>{c===N.type&&r.addMark(_,w,c.create({...N.attrs,...s}))}):r.addMark(_,w,c.create(s))})});return P7t(n,r,c)},L7t=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),D7t=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=ch(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})=>qLe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>qLe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},O7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=A4(t,0,n.content.size),o=Qa.create(n,a);s.setSelection(o)}return!0},R7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ni.atStart(n).from,i=ni.atEnd(n).to,c=A4(a,l,i),u=A4(o,l,i),m=ni.create(n,c,u);s.setSelection(m)}return!0},F7t=t=>({state:s,dispatch:r})=>{const n=ch(t,s.schema);return fFt(n)(s,r)};function ZLe(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 z7t=({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,m=Fie(u,i.node().type.name,i.node().attrs);if(o instanceof Qa&&o.node.isBlock)return!i.parentOffset||!_1(l,i.pos)?!1:(n&&(t&&ZLe(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:j7t(i.node(-1).contentMatchAt(i.indexAfter(-1)));let y=f&&g?[{type:g,attrs:m}]:void 0,_=_1(s.doc,s.mapping.map(i.pos),1,y);if(!y&&!_&&_1(s.doc,s.mapping.map(i.pos),1,g?[{type:g}]:void 0)&&(_=!0,y=g?[{type:g,attrs:m}]:void 0),n){if(_&&(o instanceof ni&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,y),g&&!f&&!i.parentOffset&&i.parent.type!==g)){const w=s.mapping.map(i.before()),j=s.doc.resolve(w);i.node(-1).canReplaceWith(j.index(),j.index()+1,g)&&s.setNodeMarkup(s.mapping.map(i.before()),g)}t&&ZLe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return _},B7t=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=ch(t,n.schema),{$from:c,$to:u}=n.selection,m=n.selection.node;if(m&&m.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=Rr.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let $=c.depth-S;$>=c.depth-3;$-=1)N=Rr.from(c.node($).copy(N));const M=c.indexAfter(-1){if(q>-1)return!1;$.isTextblock&&$.content.size===0&&(q=z+1)}),q>-1&&r.setSelection(ni.near(r.doc.resolve(q))),r.scrollIntoView()}return!0}const y=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,_={...Fie(g,f.type.name,f.attrs),...s},w={...Fie(g,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const j=y?[{type:i,attrs:_},{type:y,attrs:w}]:[{type:i,attrs:_}];if(!_1(r.doc,c.pos,2))return!1;if(a){const{selection:N,storedMarks:S}=n,{splittableMarks:M}=o.extensionManager,I=S||N.$to.parentOffset&&N.$from.marks();if(r.split(c.pos,2,j).scrollIntoView(),!I||!a)return!0;const P=I.filter(O=>M.includes(O.type.name));r.ensureMarks(P)}return!0},Mge=(t,s)=>{const r=fke(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)&&$w(t.doc,r.pos)&&t.join(r.pos),!0},Tge=(t,s)=>{const r=fke(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)&&$w(t.doc,n)&&t.join(n),!0},$7t=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:c,commands:u,can:m})=>{const{extensions:f,splittableMarks:g}=a.extensionManager,y=ch(t,l.schema),_=ch(s,l.schema),{selection:w,storedMarks:j}=l,{$from:N,$to:S}=w,M=N.blockRange(S),I=j||w.$to.parentOffset&&w.$from.marks();if(!M)return!1;const P=fke(O=>KLe(O.type.name,f))(w);if(M.depth>=1&&P&&M.depth-P.depth<=1){if(P.node.type===y)return u.liftListItem(_);if(KLe(P.node.type.name,f)&&y.validContent(P.node.content)&&i)return c().command(()=>(o.setNodeMarkup(P.pos,y),!0)).command(()=>Mge(o,y)).command(()=>Tge(o,y)).run()}return!r||!I||!i?c().command(()=>m().wrapInList(y,n)?!0:u.clearNodes()).wrapInList(y,n).command(()=>Mge(o,y)).command(()=>Tge(o,y)).run():c().command(()=>{const O=m().wrapInList(y,n),q=I.filter($=>g.includes($.type.name));return o.ensureMarks(q),O?!0:u.clearNodes()}).wrapInList(y,n).command(()=>Mge(o,y)).command(()=>Tge(o,y)).run()},q7t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Uw(t,n.schema);return J1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},U7t=(t,s,r={})=>({state:n,commands:a})=>{const o=ch(t,n.schema),l=ch(s,n.schema),i=PD(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})},V7t=(t,s={})=>({state:r,commands:n})=>{const a=ch(t,r.schema);return PD(r,a,s)?n.lift(a):n.wrapIn(a,s)},H7t=()=>({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},G7t=()=>({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},W7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=Uw(t,n.schema),{$from:u,empty:m,ranges:f}=i;if(!a)return!0;if(m&&l){let{from:g,to:y}=i;const _=(o=u.marks().find(j=>j.type===c))===null||o===void 0?void 0:o.attrs,w=mke(u,c,_);w&&(g=w.from,y=w.to),r.removeMark(g,y,c)}else f.forEach(g=>{r.removeMark(g.$from.pos,g.$to.pos,c)});return r.removeStoredMark(c),!0},K7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Xue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=ch(t,n.schema)),i==="mark"&&(l=Uw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,m=c.$to.pos;let f,g,y,_;r.selection.empty?n.doc.nodesBetween(u,m,(w,j)=>{o&&o===w.type&&(y=Math.max(j,u),_=Math.min(j+w.nodeSize,m),f=j,g=w)}):n.doc.nodesBetween(u,m,(w,j)=>{j=u&&j<=m&&(o&&o===w.type&&r.setNodeMarkup(j,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(N=>{if(l===N.type){const S=Math.max(j,u),M=Math.min(j+w.nodeSize,m);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(w=>{l===w.type&&r.addMark(y,_,l.create({...w.attrs,...s}))}))}),!0):!1},Z7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ch(t,r.schema);return lFt(a,s)(r,n)},Y7t=(t,s={})=>({state:r,dispatch:n})=>{const a=ch(t,r.schema);return cFt(a,s)(r,n)};var Q7t=Object.freeze({__proto__:null,blur:PFt,clearContent:IFt,clearNodes:LFt,command:DFt,createParagraphNear:OFt,cut:RFt,deleteCurrentNode:FFt,deleteNode:zFt,deleteRange:BFt,deleteSelection:$Ft,enter:qFt,exitCode:UFt,extendMarkRange:VFt,first:HFt,focus:WFt,forEach:KFt,insertContent:ZFt,insertContentAt:XFt,joinBackward:t7t,joinDown:e7t,joinForward:s7t,joinItemBackward:r7t,joinItemForward:n7t,joinTextblockBackward:a7t,joinTextblockForward:i7t,joinUp:JFt,keyboardShortcut:l7t,lift:c7t,liftEmptyBlock:d7t,liftListItem:u7t,newlineInCode:h7t,resetAttributes:m7t,scrollIntoView:p7t,selectAll:f7t,selectNodeBackward:x7t,selectNodeForward:g7t,selectParentNode:y7t,selectTextblockEnd:v7t,selectTextblockStart:b7t,setContent:_7t,setMark:I7t,setMeta:L7t,setNode:D7t,setNodeSelection:O7t,setTextSelection:R7t,sinkListItem:F7t,splitBlock:z7t,splitListItem:B7t,toggleList:$7t,toggleMark:q7t,toggleNode:U7t,toggleWrap:V7t,undoInputRule:H7t,unsetAllMarks:G7t,unsetMark:W7t,updateAttributes:K7t,wrapIn:Z7t,wrapInList:Y7t});const X7t=Rh.create({name:"commands",addCommands(){return{...Q7t}}}),J7t=Rh.create({name:"drop",addProseMirrorPlugins(){return[new Ru({key:new im("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),ezt=Rh.create({name:"editable",addProseMirrorPlugins(){return[new Ru({key:new im("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tzt=new im("focusEvents"),szt=Rh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ru({key:tzt,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}}}})]}}),rzt=Rh.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:m,$anchor:f}=c,{pos:g,parent:y}=f,_=f.parent.isTextblock&&g>0?i.doc.resolve(g-1):f,w=_.parent.type.spec.isolating,j=f.pos-f.parentOffset,N=w&&_.parent.childCount===1?j===f.pos:_i.atStart(u).from===g;return!m||!y.type.isTextblock||y.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 pke()||set()?o:a},addProseMirrorPlugins(){return[new Ru({key:new im("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=_i.atStart(s.doc).from,u=_i.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!gke(r.doc))return;const g=r.tr,y=Wue({state:r,transaction:g}),{commands:_}=new Kue({editor:this.editor,state:y});if(_.clearNodes(),!!g.steps.length)return g}})]}}),nzt=Rh.create({name:"paste",addProseMirrorPlugins(){return[new Ru({key:new im("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),azt=Rh.create({name:"tabindex",addProseMirrorPlugins(){return[new Ru({key:new im("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class g4{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 g4(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 g4(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 g4(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 g4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new g4(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 izt=`.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 ozt(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 lzt extends xFt{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=ozt(izt,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=ZJe(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?[ezt,EFt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),X7t,szt,rzt,azt,J7t,nzt].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 kM(a,this)}createCommandManager(){this.commandManager=new Kue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=X1e(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=X1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=eet(r,this.options.autofocus);this.view=new DJe(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:NM.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 aet(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return A7t(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return k7t(this.state.doc,{blockSeparator:r,textSerializers:{...QJe(this.schema),...n}})}get isEmpty(){return gke(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 g4(r,this)}get $doc(){return this.$pos(0)}}function uA(t){return new Yue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=ro(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),m=u+l.length;if(xke(r.from,r.to,s.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>u).length)return null;mr.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 iet(t){return new Yue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=ro(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 m=l+u;m>i?m=i:i=m+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(m,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 ebe(t){return new Yue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=ro(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 ID(t){return new Yue({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=ro(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&WNe(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=s,{splittableMarks:y}=t.editor.extensionManager,_=g||f.$to.parentOffset&&f.$from.marks();if(_){const w=_.filter(j=>y.includes(j.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const m=l.doc.resolve(r.from-1).nodeBefore;m&&m.type===t.type&&$w(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,m))&&l.join(r.from-1)}})}let om=class tbe{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=ro(ma(this,"addOptions",{name:this.name}))),this.storage=ro(ma(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new tbe(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Que(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new tbe(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=ro(ma(r,"addOptions",{name:r.name})),r.storage=ro(ma(r,"addStorage",{name:r.name,options:r.options})),r}};function c3(t){return new kFt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=ro(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 m=c.search(/\S/),f=r.from+c.indexOf(i),g=f+i.length;if(xke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(j=>j===t.type&&j!==_.mark.type)).filter(_=>_.to>f).length)return null;gr.from&&l.delete(r.from+m,f),u=r.from+m+i.length,l.addMark(r.from+m,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function czt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Qa){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 dzt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oet={exports:{}},Age={};/** * @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 YLe;function uzt(){if(YLe)return Age;YLe=1;var t=mt;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 y=g(),_=n({inst:{value:y,getSnapshot:g}}),w=_[0].inst,j=_[1];return o(function(){w.value=y,w.getSnapshot=g,c(w)&&j({inst:w})},[f,y,g]),a(function(){return c(w)&&j({inst:w}),f(function(){c(w)&&j({inst:w})})},[f]),l(y),y}function c(f){var g=f.getSnapshot;f=f.value;try{var y=g();return!r(f,y)}catch{return!0}}function u(f,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return Age.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Age}oet.exports=uzt();var yke=oet.exports;const hzt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},mzt=({contentComponent:t})=>{const s=yke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return mt.createElement(mt.Fragment,null,Object.values(s))};function pzt(){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]:k2e.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 fzt extends mt.Component{constructor(s){var r;super(s),this.editorContentRef=mt.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=pzt(),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 mt.createElement(mt.Fragment,null,mt.createElement("div",{ref:hzt(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&mt.createElement(mzt,{contentComponent:s.contentComponent}))}}const xzt=k.forwardRef((t,s)=>{const r=mt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mt.createElement(fzt,{key:r,innerRef:s,...t})}),vke=mt.memo(xzt);var gzt=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},yzt=dzt(gzt),cet={exports:{}},Ege={};/** * @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 QLe;function vzt(){if(QLe)return Ege;QLe=1;var t=mt,s=yke;function r(u,m){return u===m&&(u!==0||1/u===1/m)||u!==u&&m!==m}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 Ege.useSyncExternalStoreWithSelector=function(u,m,f,g,y){var _=o(null);if(_.current===null){var w={hasValue:!1,value:null};_.current=w}else w=_.current;_=i(function(){function N(O){if(!S){if(S=!0,M=O,O=g(O),y!==void 0&&w.hasValue){var q=w.value;if(y(q,O))return I=q}return I=O}if(q=I,n(M,O))return q;var $=g(O);return y!==void 0&&y(q,$)?q:(M=O,I=$)}var S=!1,M,I,P=f===void 0?null:f;return[function(){return N(m())},P===null?void 0:function(){return N(P())}]},[m,f,g,y]);var j=a(u,_[0],_[1]);return l(function(){w.hasValue=!0,w.value=j},[j]),c(j),j},Ege}cet.exports=vzt();var bzt=cet.exports;const _zt=typeof window<"u"?k.useLayoutEffect:k.useEffect;class wzt{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 jzt(t){var s;const[r]=k.useState(()=>new wzt(t.editor)),n=bzt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:yzt);return _zt(()=>r.watch(t.editor),[t.editor,r]),k.useDebugValue(n),n}const Nzt=!1,sbe=typeof window>"u",kzt=sbe||!!(typeof window<"u"&&window.next);class bke{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?sbe||kzt?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 lzt(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?bke.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 _ke(t={},s=[]){const r=k.useRef(t);r.current=t;const[n]=k.useState(()=>new bke(r)),a=yke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return k.useDebugValue(a),k.useEffect(n.onRender(s)),jzt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const Szt=k.createContext({editor:null});Szt.Consumer;const Czt=k.createContext({onDragStart:void 0}),Mzt=()=>k.useContext(Czt);mt.forwardRef((t,s)=>{const{onDragStart:r}=Mzt(),n=t.as||"div";return mt.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const Tzt=/^\s*>\s$/,Azt=om.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Gc(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[ID({find:Tzt,type:this.type})]}}),Ezt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Pzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Izt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Lzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Dzt=uy.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",Gc(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[uA({find:Ezt,type:this.type}),uA({find:Izt,type:this.type})]},addPasteRules(){return[c3({find:Pzt,type:this.type}),c3({find:Lzt,type:this.type})]}}),Ozt="listItem",XLe="textStyle",JLe=/^\s*([-+*])\s$/,Rzt=om.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",Gc(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(Ozt,this.editor.getAttributes(XLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ID({find:JLe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ID({find:JLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(XLe),editor:this.editor})),[t]}}),Fzt=/(^|[^`])`([^`]+)`(?!`)/,zzt=/(^|[^`])`([^`]+)`(?!`)/g,Bzt=uy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Gc(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[uA({find:Fzt,type:this.type})]},addPasteRules(){return[c3({find:zzt,type:this.type})]}}),$zt=/^```([a-z]+)?[\s\n]$/,qzt=/^~~~([a-z]+)?[\s\n]$/,Uzt=om.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",Gc(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(_i.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[ebe({find:$zt,type:this.type,getAttributes:t=>({language:t[1]})}),ebe({find:qzt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ru({key:new im("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(ni.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),Vzt=om.create({name:"doc",topNode:!0,content:"block+"});function Hzt(t={}){return new Ru({view(s){return new Gzt(s,t)}})}class Gzt{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 y=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(y){let _=y.getBoundingClientRect(),w=f?_.bottom:_.top;f&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*i;n={left:_.left,right:_.right,top:w-j,bottom:w+j}}}}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,m;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,m=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,y=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,m=f.top-c.scrollTop*y}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-m)/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=WXe(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 Wzt=Rh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Hzt(this.options)]}});class yd extends _i{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return yd.valid(n)?new yd(n):_i.near(n)}content(){return Sn.empty}eq(s){return s instanceof yd&&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 yd(s.resolve(r.pos))}getBookmark(){return new wke(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!Kzt(s)||!Zzt(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&&yd.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(yd.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Qa.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(yd.valid(i))return i}return null}}}yd.prototype.visible=!1;yd.findFrom=yd.findGapCursorFrom;_i.jsonID("gapcursor",yd);class wke{constructor(s){this.pos=s}map(s){return new wke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return yd.valid(r)?new yd(r):_i.near(r)}}function det(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Kzt(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||det(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Zzt(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||det(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Yzt(){return new Ru({props:{decorations:e9t,createSelectionBetween(t,s,r){return s.pos==r.pos&&yd.valid(r)?new yd(r):null},handleClick:Xzt,handleKeyDown:Qzt,handleDOMEvents:{beforeinput:Jzt}}})}const Qzt=ake({ArrowLeft:Iz("horiz",-1),ArrowRight:Iz("horiz",1),ArrowUp:Iz("vert",-1),ArrowDown:Iz("vert",1)});function Iz(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 ni){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=yd.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new yd(u))),!0):!1}}function Xzt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!yd.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Qa.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new yd(n))),!0)}function Jzt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof yd))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=Rr.empty;for(let l=n.length-1;l>=0;l--)a=Rr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new Sn(a,0,0));return o.setSelection(ni.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function e9t(t){if(!(t.selection instanceof yd))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",gd.create(t.doc,[Im.widget(t.selection.head,s,{key:"gapcursor"})])}const t9t=Rh.create({name:"gapCursor",addProseMirrorPlugins(){return[Yzt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=ro(ma(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),s9t=om.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",Gc(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:m})=>{if(m&&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()}}}),r9t=om.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]}`,Gc(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=>ebe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var _le=200,oh=function(){};oh.prototype.append=function(s){return s.length?(s=oh.from(s),!this.length&&s||s.length<_le&&this.leafAppend(s)||this.length<_le&&s.leafPrepend(this)||this.appendInner(s)):this};oh.prototype.prepend=function(s){return s.length?oh.from(s).append(this):this};oh.prototype.appendInner=function(s){return new n9t(this,s)};oh.prototype.slice=function(s,r){return s===void 0&&(s=0),r===void 0&&(r=this.length),s>=r?oh.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};oh.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};oh.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)};oh.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};oh.from=function(s){return s instanceof oh?s:s&&s.length?new uet(s):oh.empty};var uet=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<=_le)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=_le)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}(oh);oh.empty=new uet([]);var n9t=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}(oh);const a9t=500;class Wg{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=[],m=[];return this.items.forEach((f,g)=>{if(!f.step){a||(a=this.remapping(n,g+1),o=a.maps.length),o--,m.push(f);return}if(a){m.push(new Yy(f.map));let y=f.step.map(a.slice(o)),_;y&&l.maybeStep(y).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],u.push(new Yy(_,void 0,void 0,u.length+m.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 Wg(this.items.slice(0,n).append(m.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 m=0;mo9t&&(i=i9t(i,u),l-=u),new Wg(i.append(o),l)}remapping(s,r){let n=new SD;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 Wg(this.items.append(s.map(r=>new Yy(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 y=o.getMirror(--c);if(y==null)return;l=Math.min(l,y);let _=o.maps[y];if(g.step){let w=s.steps[y].invert(s.docs[y]),j=g.selection&&g.selection.map(o.slice(c+1,y));j&&i++,n.push(new Yy(_,w,j))}else n.push(new Yy(_))},a);let u=[];for(let g=r;ga9t&&(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 m=l.selection&&l.selection.map(r.slice(n));m&&o++;let f=new Yy(u.invert(),c,m),g,y=a.length-1;(g=a.length&&a[y].merge(f))?a[y]=g:a.push(f)}}else l.map&&n--},this.items.length,0),new Wg(oh.from(a.reverse()),o)}}Wg.empty=new Wg(oh.empty,0);function i9t(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Yy{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 Yy(r.getMap().invert(),r,this.selection)}}}class n_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const o9t=20;function l9t(t,s,r,n){let a=r.getMeta(OS),o;if(a)return a.historyState;r.getMeta(u9t)&&(t=new n_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(OS))return l.getMeta(OS).redo?new n_(t.done.addTransform(r,void 0,n,zie(s)),t.undone,e8e(r.mapping.maps),t.prevTime,t.prevComposition):new n_(t.done,t.undone.addTransform(r,void 0,n,zie(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||!c9t(r,t.prevRanges)),u=l?Pge(t.prevRanges,r.mapping):e8e(r.mapping.maps);return new n_(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,zie(s)),Wg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new n_(t.done.rebased(r,o),t.undone.rebased(r,o),Pge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new n_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Pge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function c9t(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 e8e(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 Pge(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=OS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=d9t(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const met=het(!1,!0),pet=het(!0,!0),m9t=Rh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>met(t,s),redo:()=>({state:t,dispatch:s})=>pet(t,s)}},addProseMirrorPlugins(){return[h9t(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()}}}),p9t=om.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Gc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!czt(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}):E7t(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,m=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(ni.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Qa.create(l.doc,u.pos)):l.setSelection(ni.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(m,f),l.setSelection(ni.create(l.doc,m+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[iet({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),f9t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,x9t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,g9t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,y9t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,v9t=uy.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",Gc(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[uA({find:f9t,type:this.type}),uA({find:g9t,type:this.type})]},addPasteRules(){return[c3({find:x9t,type:this.type}),c3({find:y9t,type:this.type})]}}),b9t=om.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Gc(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)}}}),_9t="listItem",s8e="textStyle",r8e=/^(\d+)\.\s$/,w9t=om.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",Gc(this.options.HTMLAttributes,r),0]:["ol",Gc(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(_9t,this.editor.getAttributes(s8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ID({find:r8e,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=ID({find:r8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(s8e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),j9t=om.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),N9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,k9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,S9t=uy.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",Gc(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[uA({find:N9t,type:this.type})]},addPasteRules(){return[c3({find:k9t,type:this.type})]}}),C9t=om.create({name:"text",group:"inline"}),jke=Rh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(Dzt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(Azt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(Rzt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Bzt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(Uzt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Vzt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Wzt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(t9t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(s9t.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(r9t.configure(this.options.heading)),this.options.history!==!1&&t.push(m9t.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(p9t.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(v9t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(b9t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(w9t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(j9t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(S9t.configure(this.options.strike)),this.options.text!==!1&&t.push(C9t.configure(this.options.text)),t}}),M9t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",T9t="ελ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",rbe="numeric",nbe="ascii",abe="alpha",_8="asciinumeric",WI="alphanumeric",ibe="domain",fet="emoji",A9t="scheme",E9t="slashscheme",Lge="whitespace";function P9t(t,s){return t in s||(s[t]=[]),s[t]}function E4(t,s,r){s[rbe]&&(s[_8]=!0,s[WI]=!0),s[nbe]&&(s[_8]=!0,s[abe]=!0),s[_8]&&(s[WI]=!0),s[abe]&&(s[WI]=!0),s[WI]&&(s[ibe]=!0),s[fet]&&(s[ibe]=!0);for(const n in s){const a=P9t(n,r);a.indexOf(t)<0&&a.push(t)}}function I9t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function gp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}gp.groups={};gp.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),cd=(t,s,r,n,a)=>t.tr(s,r,n,a),n8e=(t,s,r,n,a)=>t.ts(s,r,n,a),Jr=(t,s,r,n,a)=>t.tt(s,r,n,a),Ov="WORD",obe="UWORD",xet="ASCIINUMERICAL",get="ALPHANUMERICAL",LD="LOCALHOST",lbe="TLD",cbe="UTLD",Bie="SCHEME",aM="SLASH_SCHEME",Nke="NUM",dbe="WS",kke="NL",w8="OPENBRACE",j8="CLOSEBRACE",wle="OPENBRACKET",jle="CLOSEBRACKET",Nle="OPENPAREN",kle="CLOSEPAREN",Sle="OPENANGLEBRACKET",Cle="CLOSEANGLEBRACKET",Mle="FULLWIDTHLEFTPAREN",Tle="FULLWIDTHRIGHTPAREN",Ale="LEFTCORNERBRACKET",Ele="RIGHTCORNERBRACKET",Ple="LEFTWHITECORNERBRACKET",Ile="RIGHTWHITECORNERBRACKET",Lle="FULLWIDTHLESSTHAN",Dle="FULLWIDTHGREATERTHAN",Ole="AMPERSAND",Rle="APOSTROPHE",Fle="ASTERISK",a_="AT",zle="BACKSLASH",Ble="BACKTICK",$le="CARET",f_="COLON",Ske="COMMA",qle="DOLLAR",Qy="DOT",Ule="EQUALS",Cke="EXCLAMATION",cx="HYPHEN",N8="PERCENT",Vle="PIPE",Hle="PLUS",Gle="POUND",k8="QUERY",Mke="QUOTE",yet="FULLWIDTHMIDDLEDOT",Tke="SEMI",Xy="SLASH",S8="TILDE",Wle="UNDERSCORE",vet="EMOJI",Kle="SYM";var bet=Object.freeze({__proto__:null,ALPHANUMERICAL:get,AMPERSAND:Ole,APOSTROPHE:Rle,ASCIINUMERICAL:xet,ASTERISK:Fle,AT:a_,BACKSLASH:zle,BACKTICK:Ble,CARET:$le,CLOSEANGLEBRACKET:Cle,CLOSEBRACE:j8,CLOSEBRACKET:jle,CLOSEPAREN:kle,COLON:f_,COMMA:Ske,DOLLAR:qle,DOT:Qy,EMOJI:vet,EQUALS:Ule,EXCLAMATION:Cke,FULLWIDTHGREATERTHAN:Dle,FULLWIDTHLEFTPAREN:Mle,FULLWIDTHLESSTHAN:Lle,FULLWIDTHMIDDLEDOT:yet,FULLWIDTHRIGHTPAREN:Tle,HYPHEN:cx,LEFTCORNERBRACKET:Ale,LEFTWHITECORNERBRACKET:Ple,LOCALHOST:LD,NL:kke,NUM:Nke,OPENANGLEBRACKET:Sle,OPENBRACE:w8,OPENBRACKET:wle,OPENPAREN:Nle,PERCENT:N8,PIPE:Vle,PLUS:Hle,POUND:Gle,QUERY:k8,QUOTE:Mke,RIGHTCORNERBRACKET:Ele,RIGHTWHITECORNERBRACKET:Ile,SCHEME:Bie,SEMI:Tke,SLASH:Xy,SLASH_SCHEME:aM,SYM:Kle,TILDE:S8,TLD:lbe,UNDERSCORE:Wle,UTLD:cbe,UWORD:obe,WORD:Ov,WS:dbe});const Av=/[a-z]/,xI=new RegExp("\\p{L}","u"),Dge=new RegExp("\\p{Emoji}","u"),Ev=/\d/,Oge=/\s/,a8e="\r",Rge=` `,L9t="️",D9t="‍",Fge="";let Lz=null,Dz=null;function O9t(t=[]){const s={};gp.groups=s;const r=new gp;Lz==null&&(Lz=i8e(M9t)),Dz==null&&(Dz=i8e(T9t)),Jr(r,"'",Rle),Jr(r,"{",w8),Jr(r,"}",j8),Jr(r,"[",wle),Jr(r,"]",jle),Jr(r,"(",Nle),Jr(r,")",kle),Jr(r,"<",Sle),Jr(r,">",Cle),Jr(r,"(",Mle),Jr(r,")",Tle),Jr(r,"「",Ale),Jr(r,"」",Ele),Jr(r,"『",Ple),Jr(r,"』",Ile),Jr(r,"<",Lle),Jr(r,">",Dle),Jr(r,"&",Ole),Jr(r,"*",Fle),Jr(r,"@",a_),Jr(r,"`",Ble),Jr(r,"^",$le),Jr(r,":",f_),Jr(r,",",Ske),Jr(r,"$",qle),Jr(r,".",Qy),Jr(r,"=",Ule),Jr(r,"!",Cke),Jr(r,"-",cx),Jr(r,"%",N8),Jr(r,"|",Vle),Jr(r,"+",Hle),Jr(r,"#",Gle),Jr(r,"?",k8),Jr(r,'"',Mke),Jr(r,"/",Xy),Jr(r,";",Tke),Jr(r,"~",S8),Jr(r,"_",Wle),Jr(r,"\\",zle),Jr(r,"・",yet);const n=cd(r,Ev,Nke,{[rbe]:!0});cd(n,Ev,n);const a=cd(n,Av,xet,{[_8]:!0}),o=cd(n,xI,get,{[WI]:!0}),l=cd(r,Av,Ov,{[nbe]:!0});cd(l,Ev,a),cd(l,Av,l),cd(a,Ev,a),cd(a,Av,a);const i=cd(r,xI,obe,{[abe]:!0});cd(i,Av),cd(i,Ev,o),cd(i,xI,i),cd(o,Ev,o),cd(o,Av),cd(o,xI,o);const c=Jr(r,Rge,kke,{[Lge]:!0}),u=Jr(r,a8e,dbe,{[Lge]:!0}),m=cd(r,Oge,dbe,{[Lge]:!0});Jr(r,Fge,m),Jr(u,Rge,c),Jr(u,Fge,m),cd(u,Oge,m),Jr(m,a8e),Jr(m,Rge),cd(m,Oge,m),Jr(m,Fge,m);const f=cd(r,Dge,vet,{[fet]:!0});Jr(f,"#"),cd(f,Dge,f),Jr(f,L9t,f);const g=Jr(f,D9t);Jr(g,"#"),cd(g,Dge,f);const y=[[Av,l],[Ev,a]],_=[[Av,null],[xI,i],[Ev,o]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?S[ibe]=!0:Av.test(j)?Ev.test(j)?S[_8]=!0:S[nbe]=!0:S[rbe]=!0,n8e(r,j,j,S)}return n8e(r,"localhost",LD,{ascii:!0}),r.jd=new gp(Kle),{start:r,tokens:Object.assign({groups:s},bet)}}function _et(t,s){const r=R9t(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:m.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function R9t(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 Ub(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 DD={defaultProtocol:"http",events:null,format:o8e,formatHref:o8e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ake(t,s=null){let r=Object.assign({},DD);t&&(r=Object.assign(r,t instanceof Ake?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=DD.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),m=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),m&&Object.assign(l,m),{tagName:a,attributes:l,content:o,eventListeners:f}}};function Jue(t,s){class r extends wet{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 l8e=Jue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),c8e=Jue("text"),F9t=Jue("nl"),Oz=Jue("url",{isLink:!0,toHref(t=DD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==LD&&t[1].t===f_}}),sx=t=>new gp(t);function z9t({groups:t}){const s=t.domain.concat([Ole,Fle,a_,zle,Ble,$le,qle,Ule,cx,Nke,N8,Vle,Hle,Gle,Xy,Kle,S8,Wle]),r=[Rle,f_,Ske,Qy,Cke,N8,k8,Mke,Tke,Sle,Cle,w8,j8,jle,wle,Nle,kle,Mle,Tle,Ale,Ele,Ple,Ile,Lle,Dle],n=[Ole,Rle,Fle,zle,Ble,$le,qle,Ule,cx,w8,j8,N8,Vle,Hle,Gle,k8,Xy,Kle,S8,Wle],a=sx(),o=Jr(a,S8);so(o,n,o),so(o,t.domain,o);const l=sx(),i=sx(),c=sx();so(a,t.domain,l),so(a,t.scheme,i),so(a,t.slashscheme,c),so(l,n,o),so(l,t.domain,l);const u=Jr(l,a_);Jr(o,a_,u),Jr(i,a_,u),Jr(c,a_,u);const m=Jr(o,Qy);so(m,n,o),so(m,t.domain,o);const f=sx();so(u,t.domain,f),so(f,t.domain,f);const g=Jr(f,Qy);so(g,t.domain,f);const y=sx(l8e);so(g,t.tld,y),so(g,t.utld,y),Jr(u,LD,y);const _=Jr(f,cx);Jr(_,cx,_),so(_,t.domain,f),so(y,t.domain,f),Jr(y,Qy,g),Jr(y,cx,_);const w=Jr(y,f_);so(w,t.numeric,l8e);const j=Jr(l,cx),N=Jr(l,Qy);Jr(j,cx,j),so(j,t.domain,l),so(N,n,o),so(N,t.domain,l);const S=sx(Oz);so(N,t.tld,S),so(N,t.utld,S),so(S,t.domain,l),so(S,n,o),Jr(S,Qy,N),Jr(S,cx,j),Jr(S,a_,u);const M=Jr(S,f_),I=sx(Oz);so(M,t.numeric,I);const P=sx(Oz),O=sx();so(P,s,P),so(P,r,O),so(O,s,P),so(O,r,O),Jr(S,Xy,P),Jr(I,Xy,P);const q=Jr(i,f_),$=Jr(c,f_),z=Jr($,Xy),V=Jr(z,Xy);so(i,t.domain,l),Jr(i,Qy,N),Jr(i,cx,j),so(c,t.domain,l),Jr(c,Qy,N),Jr(c,cx,j),so(q,t.domain,P),Jr(q,Xy,P),Jr(q,k8,P),so(V,t.domain,P),so(V,s,P),Jr(V,Xy,P);const X=[[w8,j8],[wle,jle],[Nle,kle],[Sle,Cle],[Mle,Tle],[Ale,Ele],[Ple,Ile],[Lle,Dle]];for(let Y=0;Y=0&&g++,a++,m++;if(g<0)a-=m,a0&&(o.push(zge(c8e,s,l)),l=[]),a-=g,m-=g;const y=f.t,_=r.slice(a-m,a);o.push(zge(y,s,_))}}return l.length>0&&o.push(zge(c8e,s,l)),o}function zge(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 $9t=typeof console<"u"&&console&&console.warn||(()=>{}),q9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",_c={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function U9t(){return gp.groups={},_c.scanner=null,_c.parser=null,_c.tokenQueue=[],_c.pluginQueue=[],_c.customSchemes=[],_c.initialized=!1,_c}function d8e(t,s=!1){if(_c.initialized&&$9t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${q9t}`),!/^[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`);_c.customSchemes.push([t,s])}function V9t(){_c.scanner=O9t(_c.customSchemes);for(let t=0;t<_c.tokenQueue.length;t++)_c.tokenQueue[t][1]({scanner:_c.scanner});_c.parser=z9t(_c.scanner.tokens);for(let t=0;t<_c.pluginQueue.length;t++)_c.pluginQueue[t][1]({scanner:_c.scanner,parser:_c.parser});return _c.initialized=!0,_c}function Eke(t){return _c.initialized||V9t(),B9t(_c.parser.start,t,_et(_c.scanner.start,t))}Eke.scan=_et;function jet(t,s=null,r=null){if(s&&typeof s=="object"){if(r)throw Error(`linkifyjs: Invalid link type ${s}; must be a string`);r=s,s=null}const n=new Ake(r),a=Eke(t),o=[];for(let l=0;l{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=w7t(r.doc,[...s]);if(T7t(i).forEach(({newRange:u})=>{const m=N7t(n.doc,u,y=>y.isTextblock);let f,g;if(m.length>1)f=m[0],g=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(m.length){const y=n.doc.textBetween(u.from,u.to," "," ");if(!G9t.test(y))return;f=m[0],g=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const y=g.split(H9t).filter(Boolean);if(y.length<=0)return!1;const _=y[y.length-1],w=f.pos+g.lastIndexOf(_);if(!_)return!1;const j=Eke(_).map(N=>N.toObject(t.defaultProtocol));if(!K9t(j))return!1;j.filter(N=>N.isLink).map(N=>({...N,from:w+N.start+1,to:w+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=>{xke(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 Y9t(t){return new Ru({key:new im("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=aet(s.state,t.type.name),u=n.target,m=(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&&m?(window.open(m,f),!0):!1}}})}function Q9t(t){return new Ru({key:new im("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=jet(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 H2(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(W9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ike=uy.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"){d8e(t);return}d8e(t.scheme,t.optionalSlashes)})},onDestroy(){U9t()},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)=>!!H2(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=>!!H2(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=>!!H2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Gc(this.options.HTMLAttributes,t),0]:["a",Gc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!H2(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=>!!H2(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[c3({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=jet(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!H2(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(Z9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!H2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Y9t({type:this.type})),this.options.linkOnPaste&&t.push(Q9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Lke=Rh.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")}}}),X9t=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}`)})},Dke=uy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&X9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Gc(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}}}}),J9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,eBt=om.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",Gc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[iet({find:J9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let ube,hbe;if(typeof WeakMap<"u"){let t=new WeakMap;ube=s=>t.get(s),hbe=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;ube=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var bd=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:m,n:N-M});break}const I=a+M*s;for(let P=0;Pn&&(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 rBt(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 aBt(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 fy(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 ehe(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=jE(s.$head)||iBt(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function iBt(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 mbe(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function oBt(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Oke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function Net(t,s,r){const n=t.node(-1),a=bd.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 d3(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 ket(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;am!=r.pos-o);c.unshift(r.pos-o);const u=c.map(m=>{const f=n.nodeAt(m);if(!f)throw new RangeError(`No cell with offset ${m} found`);const g=o+m+1;return new XXe(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(mbe(n)&&mbe(a)&&Oke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Rv.rowSelection(n,a):o&&this.isColSelection()?Rv.colSelection(n,a):new Rv(n,a)}return ni.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=bd.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||j>0){let N=_.attrs;if(w>0&&(N=d3(N,0,w)),j>0&&(N=d3(N,N.colspan-j,j)),y.lefta.bottom){const N={..._.attrs,rowspan:Math.min(y.bottom,a.bottom)-Math.max(y.top,a.top)};y.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=bd.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 Rv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=bd.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(Im.node(n,n+r.nodeSize,{class:"selectedCell"}))}),gd.create(t.doc,s)}function uBt({$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 hBt({$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 mBt(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Qa&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=uc.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=uc.rowSelection(i,i)}else if(!r){const i=bd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=uc.create(a,c+1,u)}}else n instanceof ni&&uBt(n)?o=ni.create(a,n.from):n instanceof ni&&hBt(n)&&(o=ni.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const pBt=new im("fix-tables");function Met(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=fBt(t,a,o,r))};return s?s.doc!=t.doc&&Met(s.doc,t.doc,0,n):t.doc.descendants(n),r}function fBt(t,s,r,n){const a=bd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let y="cell";m.firstChild&&(y=m.firstChild.type.spec.tableRole);const _=[];for(let j=0;j0?-1:0;lBt(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;bBt(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,m=s.width*a;u0&&a0&&f==s.map[m-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 m=c+1+u.content.size,f=u8e(u)?c+1:m;o.replaceWith(f+n.tableStart,m+n.tableStart,i)}o.setSelection(new uc(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function m8e(t,s){const r=rm(t.schema);return SBt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function SBt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof uc){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=aBt(n.$from),!a)return!1;o=(l=jE(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 m=W0(s),f=s.tr;for(let y=0;y{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 MBt(t){return function(s,r){if(!fy(s))return!1;if(r){const n=rm(s.schema),a=W0(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 y=g+o.tableStart,_=l.doc.nodeAt(y);_&&l.setNodeMarkup(y,f,_.attrs)}),n(l)}return!0}}OD("row",{useDeprecatedLogic:!0});OD("column",{useDeprecatedLogic:!0});const TBt=OD("cell",{useDeprecatedLogic:!0});function ABt(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 Rz(t,s){const r=t.selection;if(!(r instanceof uc))return!1;if(s){const n=t.tr,a=rm(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 Sn(a,0,0))}),n.docChanged&&s(n)}return!0}function PBt(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(Rr.empty),r[a]n&&(g=g.type.createChecked(d3(g.attrs,g.attrs.colspan,m+g.attrs.colspan-n),g.content)),u.push(g),m+=g.attrs.colspan;for(let y=1;ya&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Rr.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function DBt(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=rm(i);let u,m;if(a>s.width)for(let f=0,g=0;fs.height){const f=[];for(let _=0,w=(s.height-1)*s.width;_=s.width?!1:r.nodeAt(s.map[w+_]).type==c.header_cell;f.push(j?m||(m=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const g=c.row.create(null,Rr.from(f)),y=[];for(let _=s.height;_{if(!a)return!1;const o=r.selection;if(o instanceof uc)return $ie(r,n,_i.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=Pet(a,t,s);if(l==null)return!1;if(t=="horiz")return $ie(r,n,_i.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=Net(i,t,s);let u;return c?u=_i.near(c,1):s<0?u=_i.near(r.doc.resolve(i.before(-1)),-1):u=_i.near(r.doc.resolve(i.after(-1)),1),$ie(r,n,u)}}}function zz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof uc)l=o;else{const c=Pet(a,t,s);if(c==null)return!1;l=new uc(r.doc.resolve(c))}const i=Net(l.$headCell,t,s);return i?$ie(r,n,new uc(l.$anchorCell,i)):!1}}function RBt(t,s){const r=t.state.doc,n=jE(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new uc(n))),!0):!1}function FBt(t,s,r){if(!fy(t.state))return!1;let n=PBt(r);const a=t.state.selection;if(a instanceof uc){n||(n={width:1,height:1,rows:[Rr.from(pbe(rm(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=bd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=LBt(n,i.right-i.left,i.bottom-i.top),y8e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=ehe(t.state),l=o.start(-1);return y8e(t.state,t.dispatch,l,bd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function zBt(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=v8e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof uc)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=jE(t.state.selection.$anchor))!=null&&((r=Bge(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 m=Bge(t,u);const f=x_.getState(t.state)==null;if(!m||!Oke(c,m))if(f)m=c;else return;const g=new uc(c,m);if(f||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);f&&y.setMeta(x_,c.pos),t.dispatch(y)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),x_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(x_,-1))}function i(c){const u=c,m=x_.getState(t.state);let f;if(m!=null)f=t.state.doc.resolve(m);else if(v8e(t,u.target)!=n&&(f=Bge(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 Pet(t,s,r){if(!(t.state.selection instanceof ni))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 v8e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function Bge(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 jE(t.state.doc.resolve(n))}var BBt=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")),fbe(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,fbe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function fbe(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 qBt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=hf.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{UBt(l,i,t,a)},mouseleave:l=>{VBt(l)},mousedown:(l,i)=>{HBt(l,i,s,r)}},decorations:l=>{const i=hf.getState(l);if(i&&i.activeHandle>-1)return YBt(l,i.activeHandle)},nodeViews:{}}});return o}var qBt=class qie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(hf);if(n&&n.setHandle!=null)return new qie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new qie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return mbe(s.doc.resolve(a))||(a=-1),new qie(a,r.dragging)}return r}};function UBt(t,s,r,n){if(!t.editable)return;const a=hf.getState(t.state);if(a&&!a.dragging){const o=WBt(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=b8e(t,s,"left",r):c-s.clientX<=r&&(l=b8e(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=bd.get(c),m=i.start(-1);if(u.colCount(i.pos-m)+i.nodeAfter.attrs.colspan-1==u.width-1)return}Iet(t,l)}}}function VBt(t){if(!t.editable)return;const s=hf.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&Iet(t,-1)}function HBt(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=hf.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=GBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(hf,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",m);const g=hf.getState(t.state);g!=null&&g.dragging&&(KBt(t,g.activeHandle,_8e(g.dragging,f,r)),t.dispatch(t.state.tr.setMeta(hf,{setDragging:null})))}function m(f){if(!f.which)return u(f);const g=hf.getState(t.state);if(g&&g.dragging){const y=_8e(g.dragging,f,r);w8e(t,g.activeHandle,y,n)}}return w8e(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",m),s.preventDefault(),!0}function GBt(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 t$t(t,s,r,n,a){const o=e$t(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!s$t(s))return!1;let r=0;const n=net(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},r$t=om.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:XBt,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}=JBt(t,this.options.cellMinWidth),o=["table",Gc(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=t$t(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(ni.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>xBt(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>gBt(t,s),deleteColumn:()=>({state:t,dispatch:s})=>vBt(t,s),addRowBefore:()=>({state:t,dispatch:s})=>_Bt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>wBt(t,s),deleteRow:()=>({state:t,dispatch:s})=>NBt(t,s),deleteTable:()=>({state:t,dispatch:s})=>EBt(t,s),mergeCells:()=>({state:t,dispatch:s})=>h8e(t,s),splitCell:()=>({state:t,dispatch:s})=>m8e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>OD("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>OD("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>TBt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>h8e(t,s)?!0:m8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>CBt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>f8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>f8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&Tet(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=uc.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:Bz,"Mod-Backspace":Bz,Delete:Bz,"Mod-Delete":Bz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$Bt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],QBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:ro(ma(t,"tableRole",s))}}}),n$t=om.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Gc(this.options.HTMLAttributes,t),0]}}),a$t=om.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",Gc(this.options.HTMLAttributes,t),0]}}),i$t=om.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",Gc(this.options.HTMLAttributes,t),0]}});function xy({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,m]=k.useState(!0),f=_ke({extensions:[jke,Ike.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Lke.configure({types:["heading","paragraph"]}),Dke,eBt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),r$t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),n$t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),a$t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),i$t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,j)=>{var S;const N=(S=j.clipboardData)==null?void 0:S.items;if(!N)return!1;for(const M of Array.from(N))if(M.type.startsWith("image/")){j.preventDefault();const I=M.getAsFile();if(!I)continue;const P=new FileReader;return P.onload=O=>{var $;const q=($=O.target)==null?void 0:$.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:q})))},P.readAsDataURL(I),!0}return!1}}});k.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const g=()=>{if(!f)return;const w=f.getAttributes("link").href||"",j=f.getAttributes("link").target;c(w),m(j==="_blank"),l(!0)},y=()=>{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(G,{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(GM,{className:"h-4 w-4"})}),e.jsx(G,{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(WM,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(tS,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(dS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(nh,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(g0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{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(X4,{className:"h-4 w-4"})}),e.jsx(G,{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(Q4,{className:"h-4 w-4"})}),e.jsx(G,{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(J4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:g,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Uo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:_,title:"Remove Link",children:e.jsx(Uo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(MS,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(wS,{className:"h-4 w-4"})})]}),e.jsx(vke,{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(js,{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(ye,{htmlFor:"link-url",children:"URL"}),e.jsx(Le,{id:"link-url",value:i,onChange:w=>c(w.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:m}),e.jsx(ye,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{type:"button",onClick:y,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var o$t=Object.defineProperty,l$t=(t,s,r)=>s in t?o$t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Dc=(t,s,r)=>l$t(t,typeof s!="symbol"?s+"":s,r);const Zle={x:0,y:0,width:0,height:0,unit:"px"},B5=(t,s,r)=>Math.min(Math.max(t,s),r),c$t=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),k8e=(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 d$t(t,s,r,n){const a=Jy(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==="%"?i_(a,r,n):a}function u$t(t,s,r){const n=Jy(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?i_(n,s,r):n}function i_(t,s,r){return t.unit==="%"?{...Zle,...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 Jy(t,s,r){return t.unit?t.unit==="px"?{...Zle,...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}:{...Zle,...t,unit:"px"}}function S8e(t,s,r,n,a,o=0,l=0,i=n,c=a){const u={...t};let m=Math.min(o,n),f=Math.min(l,a),g=Math.min(i,n),y=Math.min(c,a);s&&(s>1?(m=l?l*s:m,f=m/s,g=i*s):(f=o?o/s:f,m=f*s,y=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,m),u.x=0);const _=n-(u.x+u.width);_<0&&(u.x=Math.min(u.x,n-m),u.width+=_);const w=a-(u.y+u.height);if(w<0&&(u.y=Math.min(u.y,a-f),u.height+=w),u.widthg&&((r==="sw"||r=="nw")&&(u.x-=g-u.width),u.width=g),u.height>y&&((r==="nw"||r=="ne")&&(u.y-=y-u.height),u.height=y),s){const j=u.width/u.height;if(js){const N=Math.max(u.height*s,m);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function h$t(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 $5={capture:!0,passive:!1};let m$t=0;const Xb=class Pg extends k.PureComponent{constructor(){super(...arguments),Dc(this,"docMoveBound",!1),Dc(this,"mouseDownOnCrop",!1),Dc(this,"dragStarted",!1),Dc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Dc(this,"componentRef",k.createRef()),Dc(this,"mediaRef",k.createRef()),Dc(this,"resizeObserver"),Dc(this,"initChangeCalled",!1),Dc(this,"instanceId",`rc-${m$t++}`),Dc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Dc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Jy(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,m=o.x,f=o.y;if(l){const g=s.clientX-a.x,y=s.clientY-a.y;let _=0,w=0;l==="ne"||l=="e"?(_=g-(o.x+o.width),w=y-o.y,m=o.x,f=o.y+o.height):l==="se"||l==="s"?(_=g-(o.x+o.width),w=y-(o.y+o.height),m=o.x,f=o.y):l==="sw"||l=="w"?(_=g-o.x,w=y-(o.y+o.height),m=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(_=g-o.x,w=y-o.y,m=o.x+o.width,f=o.y+o.height),c=m+a.x+_,u=f+a.y+w}this.evData={startClientX:c,startClientY:u,startCropX:m,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),Dc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=s.clientX-i.x,u=s.clientY-i.y,m={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(Jy(m,i.width,i.height),i_(m,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Dc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let c;i.isResize?c=this.resizeCrop():c=this.dragCrop(),k8e(r,c)||a(Jy(c,l.width,l.height),i_(c,l.width,l.height))}),Dc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const c=this.getBox(),u=this.makePixelCrop(c),m=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Pg.nudgeStepLarge:s.shiftKey?Pg.nudgeStepMedium:Pg.nudgeStep;if(l==="ArrowLeft"?(u.x-=m,i=!0):l==="ArrowRight"?(u.x+=m,i=!0):l==="ArrowUp"?(u.y-=m,i=!0):l==="ArrowDown"&&(u.y+=m,i=!0),i){s.cancelable&&s.preventDefault(),u.x=B5(u.x,0,c.width-u.width),u.y=B5(u.y,0,c.height-u.height);const f=Jy(u,c.width,c.height),g=i_(u,c.width,c.height);a(f,g),o&&o(f,g)}}),Dc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:c,maxHeight:u,onChange:m,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 y=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Pg.nudgeStepLarge:s.shiftKey?Pg.nudgeStepMedium:Pg.nudgeStep,_=Jy(a,g.width,g.height),w=h$t(_,s.key,y,r),j=S8e(w,n,r,g.width,g.height,l,i,c,u);if(!k8e(a,j)){const N=i_(j,g.width,g.height);m(j,N),f&&f(j,N)}}),Dc(this,"onDocPointerDone",s=>{const{crop:r,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!r)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(s),a&&a(Jy(r,l.width,l.height),i_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Dc(this,"onDragFocus",()=>{var s;(s=this.componentRef.current)==null||s.scrollTo(0,0)})}get document(){return document}getBox(){const s=this.mediaRef.current;if(!s)return{x:0,y:0,width:0,height:0};const{x:r,y:n,width:a,height:o}=s.getBoundingClientRect();return{x:r,y:n,width:a,height:o}}componentDidUpdate(s){const{crop:r,onComplete:n}=this.props;if(n&&!s.crop&&r){const{width:a,height:o}=this.getBox();a&&o&&n(Jy(r,a,o),i_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,$5),this.document.addEventListener("pointerup",this.onDocPointerDone,$5),this.document.addEventListener("pointercancel",this.onDocPointerDone,$5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,$5),this.document.removeEventListener("pointerup",this.onDocPointerDone,$5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,$5),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=B5(s.startCropX+a,0,r.width-n.width),n.y=B5(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),m=s.ord||u;let f=s.clientX-s.startClientX,g=s.clientY-s.startClientY;(l&&m==="nw"||m==="w"||m==="sw")&&(f=Math.min(f,-l)),(i&&m==="nw"||m==="n"||m==="ne")&&(g=Math.min(g,-i));const y={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(y.x=s.startCropX,y.width=f,r?(y.height=y.width/r,y.y=s.startCropY-y.height):(y.height=Math.abs(g),y.y=s.startCropY-y.height)):u==="se"?(y.x=s.startCropX,y.y=s.startCropY,y.width=f,r?y.height=y.width/r:y.height=g):u==="sw"?(y.x=s.startCropX+f,y.y=s.startCropY,y.width=Math.abs(f),r?y.height=y.width/r:y.height=g):u==="nw"&&(y.x=s.startCropX+f,y.width=Math.abs(f),r?(y.height=y.width/r,y.y=s.startCropY-y.height):(y.height=Math.abs(g),y.y=s.startCropY+g));const _=S8e(y,r,u,o.width,o.height,l,i,n,a);return r||Pg.xyOrds.indexOf(m)>-1?c=_:Pg.xOrds.indexOf(m)>-1?(c.x=_.x,c.width=_.width):Pg.yOrds.indexOf(m)>-1&&(c.y=_.y,c.height=_.height),c.x=B5(c.x,0,o.width-c.width),c.y=B5(c.y,0,o.height-c.height),c}renderCropSelection(){const{ariaLabels:s=Pg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return mt.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&mt.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},mt.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),mt.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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"}),mt.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&&mt.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:c=>c.stopPropagation()},a(this.state)),o&&mt.createElement(mt.Fragment,null,mt.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),mt.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Zle,...this.props.crop||{}};return Jy(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:m,newCropIsBeingDrawn:f}=this.state,g=o?this.renderCropSelection():null,y=c$t("ReactCrop",a,m&&"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 mt.createElement("div",{ref:this.componentRef,className:y,style:c},mt.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?mt.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},mt.createElement("defs",null,mt.createElement("mask",{id:`hole-${this.instanceId}`},mt.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?mt.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"}):mt.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),mt.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,g)}};Dc(Xb,"xOrds",["e","w"]),Dc(Xb,"yOrds",["n","s"]),Dc(Xb,"xyOrds",["nw","ne","se","sw"]),Dc(Xb,"nudgeStep",1),Dc(Xb,"nudgeStepMedium",10),Dc(Xb,"nudgeStepLarge",100),Dc(Xb,"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 p$t=Xb;var Let=["PageUp","PageDown"],Det=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Oet={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},NE="Slider",[gbe,f$t,x$t]=LO(NE),[Ret]=od(NE,[x$t]),[g$t,the]=Ret(NE),Fet=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:m,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:_,...w}=t,j=k.useRef(new Set),N=k.useRef(0),M=l==="horizontal"?y$t:v$t,[I=[],P]=lh({prop:m,defaultProp:u,onChange:X=>{var J;(J=[...j.current][N.current])==null||J.focus(),f(X)}}),O=k.useRef(I);function q(X){const Y=N$t(I,X);V(X,Y)}function $(X){V(X,N.current)}function z(){const X=O.current[N.current];I[N.current]!==X&&g(I)}function V(X,Y,{commit:J}={commit:!1}){const Q=M$t(o),ce=T$t(Math.round((X-n)/o)*o+n,Q),ne=xD(ce,[n,a]);P((re=[])=>{const oe=w$t(re,ne,Y);if(C$t(oe,c*o)){N.current=oe.indexOf(ne);const he=String(oe)!==String(re);return he&&J&&g(oe),he?oe:re}else return re})}return e.jsx(g$t,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:j.current,values:I,orientation:l,form:_,children:e.jsx(gbe.Provider,{scope:t.__scopeSlider,children:e.jsx(gbe.Slot,{scope:t.__scopeSlider,children:e.jsx(M,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:Or(w.onPointerDown,()=>{i||(O.current=I)}),min:n,max:a,inverted:y,onSlideStart:i?void 0:q,onSlideMove:i?void 0:$,onSlideEnd:i?void 0:z,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:Y})=>{if(!i){const ce=Let.includes(X.key)||X.shiftKey&&Det.includes(X.key)?10:1,ne=N.current,re=I[ne],oe=o*ce*Y;V(re+oe,ne,{commit:!0})}}})})})})});Fet.displayName=NE;var[zet,Bet]=Ret(NE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),y$t=k.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...m}=t,[f,g]=k.useState(null),y=Ka(s,M=>g(M)),_=k.useRef(void 0),w=Dw(a),j=w==="ltr",N=j&&!o||!j&&o;function S(M){const I=_.current||f.getBoundingClientRect(),P=[0,I.width],q=Rke(P,N?[r,n]:[n,r]);return _.current=I,q(M-I.left)}return e.jsx(zet,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx($et,{dir:w,"data-orientation":"horizontal",...m,ref:y,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const I=S(M.clientX);l==null||l(I)},onSlideMove:M=>{const I=S(M.clientX);i==null||i(I)},onSlideEnd:()=>{_.current=void 0,c==null||c()},onStepKeyDown:M=>{const P=Oet[N?"from-left":"from-right"].includes(M.key);u==null||u({event:M,direction:P?-1:1})}})})}),v$t=k.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,m=k.useRef(null),f=Ka(s,m),g=k.useRef(void 0),y=!a;function _(w){const j=g.current||m.current.getBoundingClientRect(),N=[0,j.height],M=Rke(N,y?[n,r]:[r,n]);return g.current=j,M(w-j.top)}return e.jsx(zet,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:e.jsx($et,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=_(w.clientY);o==null||o(j)},onSlideMove:w=>{const j=_(w.clientY);l==null||l(j)},onSlideEnd:()=>{g.current=void 0,i==null||i()},onStepKeyDown:w=>{const N=Oet[y?"from-bottom":"from-top"].includes(w.key);c==null||c({event:w,direction:N?-1:1})}})})}),$et=k.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,m=the(NE,r);return e.jsx(cn.span,{...u,ref:s,onKeyDown:Or(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):Let.concat(Det).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Or(t.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),m.thumbs.has(g)?g.focus():n(f)}),onPointerMove:Or(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Or(t.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),o(f))})})}),qet="SliderTrack",Uet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=the(qet,r);return e.jsx(cn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});Uet.displayName=qet;var ybe="SliderRange",Vet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=the(ybe,r),o=Bet(ybe,r),l=k.useRef(null),i=Ka(s,l),c=a.values.length,u=a.values.map(g=>Wet(g,a.min,a.max)),m=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(cn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:m+"%",[o.endEdge]:f+"%"}})});Vet.displayName=ybe;var vbe="SliderThumb",Het=k.forwardRef((t,s)=>{const r=f$t(t.__scopeSlider),[n,a]=k.useState(null),o=Ka(s,i=>a(i)),l=k.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(b$t,{...t,ref:o,index:l})}),b$t=k.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=the(vbe,r),i=Bet(vbe,r),[c,u]=k.useState(null),m=Ka(s,S=>u(S)),f=c?l.form||!!c.closest("form"):!0,g=RO(c),y=l.values[n],_=y===void 0?0:Wet(y,l.min,l.max),w=j$t(n,l.values.length),j=g==null?void 0:g[i.size],N=j?k$t(j,_,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(gbe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(cn.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":y,"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:m,style:y===void 0?{display:"none"}:t.style,onFocus:Or(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(Get,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:y},n)]})});Het.displayName=vbe;var _$t="RadioBubbleInput",Get=k.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ka(a,n),l=YO(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&m){const f=new Event("input",{bubbles:!0});m.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(cn.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});Get.displayName=_$t;function w$t(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function Wet(t,s,r){const o=100/(r-s)*(t-s);return xD(o,[0,100])}function j$t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function N$t(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 k$t(t,s,r){const n=t/2,o=Rke([0,50],[0,n]);return(n-o(s)*r)*r}function S$t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function C$t(t,s){if(s>0){const r=S$t(t);return Math.min(...r)>=s}return!0}function Rke(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 M$t(t){return(String(t).split(".")[1]||"").length}function T$t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var Ket=Fet,A$t=Uet,E$t=Vet,P$t=Het;const Qg=k.forwardRef(({className:t,...s},r)=>e.jsxs(Ket,{ref:r,className:Pt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(A$t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(E$t,{className:"absolute h-full bg-primary"})}),e.jsx(P$t,{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"})]}));Qg.displayName=Ket.displayName;function I$t(t,s,r){return u$t(d$t({unit:"%",width:90},r,t,s),t,s)}const Fke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=k.useRef(null),[l,i]=k.useState(),[c,u]=k.useState(),[m,f]=k.useState(1),[g,y]=k.useState(0),_=k.useCallback(N=>{const{width:S,height:M}=N.currentTarget;i(I$t(S,M,a))},[a]),w=k.useCallback(async()=>{const N=o.current;if(!N||!c)return;const S=document.createElement("canvas"),M=S.getContext("2d");if(!M)return;const I=N.naturalWidth/N.width,P=N.naturalHeight/N.height,O=400;S.width=O,S.height=O,M.imageSmoothingQuality="high";const q=c.x*I,$=c.y*P,z=c.width*I,V=c.height*P,X=g*Math.PI/180,Y=S.width/2,J=S.height/2;return M.save(),M.translate(Y,J),M.rotate(X),M.scale(m,m),M.translate(-Y,-J),M.drawImage(N,q,$,z,V,0,0,O,O),M.restore(),new Promise((Q,ce)=>{S.toBlob(ne=>{ne?Q(ne):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,m,g]),j=async()=>{try{const N=await w();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(js,{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(p$t,{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(${m}) 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(oT,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Qg,{value:[m],min:.5,max:3,step:.1,onValueChange:([N])=>f(N),className:"flex-1"}),e.jsx(tw,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(UL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Qg,{value:[g],min:-180,max:180,step:1,onValueChange:([N])=>y(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[g,"°"]})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(G,{onClick:j,children:"Save Photo"})]})]})})},L$t=()=>{const{user:t}=Fs(),{toast:s}=Ra(),[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:y}=await H.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(y)throw y;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)}},m=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(Ye,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(Ye,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(Ye,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(Ye,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(Ye,{variant:"secondary",children:"Canceled"});default:return e.jsx(Ye,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Px,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Px,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(vr,{children:"Manage your subscription and billing"})]}),e.jsxs(De,{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:m()})]}),(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(G,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(rn,{className:"mr-2 h-4 w-4"}),"Manage Billing"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription."})]})]})},D$t=()=>{const{user:t}=Fs(),s=ar(),{toast:r}=Ra(),[n]=Ul(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:m}=hQe(),[f,g]=k.useState(!1),[y,_]=k.useState(""),[w,j]=k.useState(!1),[N,S]=k.useState(!1),[M,I]=k.useState(""),[P,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,$]=k.useState(!1),[z,V]=k.useState(!1),[X,Y]=k.useState({newPassword:"",confirmPassword:""});k.useEffect(()=>{t&&J()},[t]),k.useEffect(()=>{o&&t&&setTimeout(()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const J=async()=>{var oe,he,xe;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:ge}=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(ge)throw console.error("Profile query error:",ge),ge;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:((oe=ue.years_experience)==null?void 0:oe.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}),$(ue.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((he=t.user_metadata)==null?void 0:he.name)||((xe=t.email)==null?void 0:xe.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:Be}=H.storage.from("avatars").getPublicUrl(`${t.id}/${_e[0].name}`);_(Be.publicUrl)}}catch(ue){console.error("Error loading profile:",ue),r({title:"Error",description:ue.message||"Failed to load profile",variant:"destructive"})}},Q=oe=>{var ue;const he=(ue=oe.target.files)==null?void 0:ue[0];if(!he)return;const xe=new FileReader;xe.onloadend=()=>{I(xe.result),S(!0)},xe.readAsDataURL(he),oe.target.value=""},ce=async oe=>{if(t){j(!0);try{const{data:he}=await H.storage.from("avatars").list(`${t.id}`);he&&he.length>0&&await H.storage.from("avatars").remove(he.map(Se=>`${t.id}/${Se.name}`));const ue=`${t.id}/avatar.jpg`,{error:ge}=await H.storage.from("avatars").upload(ue,oe,{upsert:!0,contentType:"image/jpeg"});if(ge)throw ge;const{data:_e}=H.storage.from("avatars").getPublicUrl(ue),Be=_e.publicUrl;_(`${Be}?t=${Date.now()}`),await H.from("profiles").update({avatar_url:Be}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(he){console.error("Error uploading avatar:",he),r({title:"Error",description:he.message||"Failed to upload photo",variant:"destructive"})}finally{j(!1)}}},ne=async()=>{if(!P.name.trim()||!P.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}g(!0);try{const{error:oe}=await H.from("profiles").update({name:P.name.trim(),email:P.email.trim(),phone:P.phone.trim()||null,title:P.title.trim()||null,bio:P.bio.trim()||null,areas_served:P.areas_served.trim()||null,years_experience:P.years_experience?parseInt(P.years_experience):null,instagram_url:P.instagram_url.trim()||null,facebook_url:P.facebook_url.trim()||null,linkedin_url:P.linkedin_url.trim()||null,email_signature:P.email_signature||"",use_email_signature:P.use_email_signature}).eq("id",t==null?void 0:t.id);if(oe)throw oe;r({title:"Success",description:"Profile updated successfully"})}catch(oe){console.error("Error updating profile:",oe),r({title:"Error",description:oe.message||"Failed to update profile",variant:"destructive"})}finally{g(!1)}},re=async()=>{if(!X.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(X.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(X.newPassword!==X.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}g(!0);try{const{error:oe}=await H.auth.updateUser({password:X.newPassword});if(oe)throw oe;r({title:"Success",description:"Password updated successfully"}),Y({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(oe){console.error("Error updating password:",oe),r({title:"Error",description:oe.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(G,{variant:"outline",onClick:()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(uS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Profile Photo"}),e.jsx(vr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(De,{className:"flex items-center gap-6",children:[e.jsxs(Cn,{className:"h-24 w-24",children:[e.jsx(Wa,{src:y}),e.jsx(Mn,{className:"text-2xl",children:P.name.split(" ").map(oe=>oe[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Q,disabled:w}),e.jsxs(G,{variant:"outline",onClick:()=>{var oe;return(oe=document.getElementById("avatar-upload"))==null?void 0:oe.click()},disabled:w,children:[e.jsx(ci,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Personal Information"}),e.jsx(vr,{children:"Update your profile details"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",value:P.name,onChange:oe=>O({...P,name:oe.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",value:P.email,onChange:oe=>O({...P,email:oe.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Le,{id:"phone",type:"tel",value:P.phone,onChange:oe=>O({...P,phone:oe.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(ye,{htmlFor:"title",children:"Job Title"}),e.jsx(Le,{id:"title",value:P.title,onChange:oe=>O({...P,title:oe.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"bio",children:"Bio"}),e.jsx(Tr,{id:"bio",value:P.bio,onChange:oe=>O({...P,bio:oe.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(ye,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Le,{id:"areas_served",value:P.areas_served,onChange:oe=>O({...P,areas_served:oe.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Le,{id:"years_experience",type:"number",min:"0",value:P.years_experience,onChange:oe=>O({...P,years_experience:oe.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Le,{value:P.linkedin_url,onChange:oe=>O({...P,linkedin_url:oe.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Le,{value:P.instagram_url,onChange:oe=>O({...P,instagram_url:oe.target.value}),placeholder:"Instagram URL"}),e.jsx(Le,{value:P.facebook_url,onChange:oe=>O({...P,facebook_url:oe.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(G,{onClick:ne,disabled:f,children:[e.jsx(Vc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Gv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(vr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(De,{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:P.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(qr,{checked:P.use_email_signature,onCheckedChange:oe=>O({...P,use_email_signature:oe})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Signature"}),e.jsx(xy,{content:P.email_signature,onChange:oe=>O({...P,email_signature:oe}),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(G,{onClick:ne,disabled:f,children:[e.jsx(Vc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Pe,{id:"change-password-section",children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:a?"Set Your Password":"Change Password"}),e.jsx(vr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Le,{id:"newPassword",type:"password",value:X.newPassword,onChange:oe=>Y({...X,newPassword:oe.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Le,{id:"confirmPassword",type:"password",value:X.confirmPassword,onChange:oe=>Y({...X,confirmPassword:oe.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(G,{onClick:re,disabled:f,children:[e.jsx(Vc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(G,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[i?e.jsx(Fm,{className:"h-5 w-5"}):e.jsx(c1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(vr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(De,{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:oe=>{oe?u():m()},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(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[q?e.jsx(AL,{className:"h-5 w-5"}):e.jsx(rr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(vr,{children:"Manage your email subscription settings"})]}),e.jsx(De,{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 oe=>{V(!0);try{const{error:he}=await H.from("profiles").update({digest_opt_out:!oe}).eq("id",t==null?void 0:t.id);if(he)throw he;$(!oe),r({title:oe?"Subscribed":"Unsubscribed",description:oe?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(he){r({title:"Error",description:he.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:z})]})})]}),e.jsx(hDt,{}),e.jsx(L$t,{})]}),e.jsx(Fke,{open:N,onClose:()=>S(!1),imageSrc:M,onCropComplete:ce,aspectRatio:1})]})})};var O$t="AspectRatio",Zet=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(cn.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});Zet.displayName=O$t;var R$t=Zet;const F$t=R$t;function z$t(){const{user:t}=Fs(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),{data:l,isLoading:i}=pt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:_,error:w}=await H.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return _},enabled:!!t&&a}),c=Tt({mutationFn:async()=>{const _=new Uint8Array(12);crypto.getRandomValues(_);const w=btoa(String.fromCharCode(..._)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:j}=await H.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(j)throw j;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),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,m=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://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(_)}`;window.open(w,"_blank")}},y=()=>{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(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(fn,{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(ys,{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(Le,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(G,{variant:"outline",size:"icon",onClick:m,children:r?e.jsx(ua,{className:"h-4 w-4 text-green-500"}):e.jsx(yi,{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(G,{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(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(G,{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(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(G,{variant:"outline",className:"w-full justify-start gap-2",onClick:y,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(rn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(G,{onClick:()=>c.mutate(),disabled:c.isPending,className:"w-full",children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}const B$t={first_timer:ea,regular:f1,dedicated:rc,veteran:_o,streak_master:rh,century:_o},$$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 C8e(t){return t===1?e.jsx(_o,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(f1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(rc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function Yet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Fs(),{data:o,isLoading:l}=KQe(s?5:10,r),{data:i}=ZQe(a==null?void 0:a.id),{data:c}=QQe(a==null?void 0:a.id),{data:u}=YQe(a==null?void 0:a.id);return l?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((m,f)=>e.jsx(ws,{className:"h-12 w-full"},f))})})]}):e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(De,{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(Ye,{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(rh,{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(m=>{const f=B$t[m.badge_type]||ea;return e.jsxs(Ye,{variant:"outline",className:`text-xs ${$$t[m.badge_type]||""}`,title:m.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),m.badge_name]},m.id)}),u.length>4&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ga,{defaultValue:"points",className:"w-full",children:[e.jsxs(fa,{className:"w-full mb-3",children:[e.jsx(ss,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ss,{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((m,f)=>{var g,y,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${m.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:C8e(f+1)}),e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{className:"text-xs",children:((y=(g=m.profile)==null?void 0:g.name)==null?void 0:y.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=m.profile)==null?void 0:_.name)||"Unknown",m.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:[m.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:m.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},m.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((m,f)=>f.total_events_attended-m.total_events_attended).map((m,f)=>{var g,y,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${m.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:C8e(f+1)}),e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{className:"text-xs",children:((y=(g=m.profile)==null?void 0:g.name)==null?void 0:y.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=m.profile)==null?void 0:_.name)||"Unknown",m.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:[m.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:m.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},m.user_id)})})})]})]})]})}function q$t(){const t=ar(),{user:s,isAdmin:r}=Fs(),n=Qt(),{data:a,isLoading:o}=pt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:j}=await H.from("events").select("*").order("event_date",{ascending:!0});if(j)throw j;return w}}),{data:l}=pt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:j}=await H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(j)throw j;return w},enabled:!!s}),{data:i}=pt({queryKey:["event-registration-counts"],queryFn:async()=>{let w=[],j=0;const N=1e3;for(;;){const{data:M,error:I}=await H.from("event_registrations").select("event_id").range(j,j+N-1);if(I)throw I;if(!M||M.length===0||(w=w.concat(M),M.length{S[M.event_id]=(S[M.event_id]||0)+1}),S}}),c=Tt({mutationFn:async w=>{await H.auth.refreshSession();const{data:j,error:N}=await H.functions.invoke("zoom-register",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:w=>{me.error("Failed to register: "+w.message)}}),u=Tt({mutationFn:async w=>{const{data:j,error:N}=await H.functions.invoke("zoom-unregister",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:w=>{me.error("Failed to cancel: "+w.message)}}),m=w=>l==null?void 0:l.some(j=>j.event_id===w),f=w=>{const j=l==null?void 0:l.find(N=>N.event_id===w);return j==null?void 0:j.zoom_join_url},g=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,y=(a==null?void 0:a.filter(w=>fT(w.event_date)!=="ended"))||[],_=(a==null?void 0:a.filter(w=>fT(w.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(z$t,{}),r&&e.jsx(G,{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..."}):y.length===0?e.jsx(Pe,{className:"text-center py-12",children:e.jsx(De,{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:y.map(w=>{const j=fT(w.event_date),N=DNe(w.event_date),S=j==="live",M=j==="starting_soon";return e.jsxs(Pe,{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/${w.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(y1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(F$t,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Et,{children:[e.jsx(Lt,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(vr,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(De,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(fn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mn,{className:"h-4 w-4"}),jD(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ur,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(i8,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:m(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(w.id),disabled:u.isPending,children:[e.jsx(Er,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(G,{className:"flex-1",onClick:()=>window.open(f(w.id)||w.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(G,{className:"w-full",onClick:()=>c.mutate(w.id),disabled:c.isPending||g(w),children:g(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.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(w=>e.jsx(Pe,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs(Et,{children:[e.jsx(Lt,{className:"text-base line-clamp-1",children:w.title}),e.jsx(vr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Yet,{showUserStats:!0})})]})]})})}const $ge=[{value:"all",label:"All Roles",icon:ur},{value:"newest",label:"Newest Members",icon:mn},{value:"brokerage_manager",label:"Brokerage Managers",icon:JL},{value:"admin",label:"Admins",icon:ou}];function U$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Oe,qe;const{user:o,isAdmin:l,isBrokerageManager:i}=Fs(),[c,u]=k.useState([]),[m,f]=k.useState([]),[g,y]=k.useState([]),[_,w]=k.useState([]),[j,N]=k.useState(""),[S,M]=k.useState(""),[I,P]=k.useState(""),[O,q]=k.useState(!1),[$,z]=k.useState(!1),[V,X]=k.useState("agents"),[Y,J]=k.useState("all"),[Q,ce]=k.useState({}),ne=l||i;k.useEffect(()=>{t&&o&&(l?re():oe())},[t,o,l]),k.useEffect(()=>{t||(y([]),w([]),N(""),M(""),P(""),X("agents"),J("all"))},[t]);const re=async()=>{if(o){q(!0);try{const{data:ve,error:dt}=await H.from("brokerages").select("id, name").order("name");if(dt)throw dt;const pe=1e3,Ue={};let Xe=0,et=!0;for(;et;){const{data:Ge,error:lt}=await H.from("profiles").select("brokerage_id").range(Xe*pe,(Xe+1)*pe-1);if(lt)throw lt;Ge==null||Ge.forEach(He=>{He.brokerage_id&&(Ue[He.brokerage_id]=(Ue[He.brokerage_id]||0)+1)}),et=(Ge==null?void 0:Ge.length)===pe,Xe++}f((ve==null?void 0:ve.map(Ge=>({...Ge,agent_count:Ue[Ge.id]||0})))||[]);const Ce=[];for(Xe=0,et=!0;et;){const{data:Ge,error:lt}=await H.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(Xe*pe,(Xe+1)*pe-1);if(lt)throw lt;Ge&&Ce.push(...Ge),et=(Ge==null?void 0:Ge.length)===pe,Xe++}const Je={};for(Xe=0,et=!0;et;){const{data:Ge,error:lt}=await H.from("user_roles").select("user_id, role").range(Xe*pe,(Xe+1)*pe-1);if(lt)throw lt;Ge==null||Ge.forEach(He=>{Je[He.user_id]||(Je[He.user_id]=[]),Je[He.user_id].push(He.role)}),et=(Ge==null?void 0:Ge.length)===pe,Xe++}ce(Je),u(Ce.map(Ge=>{var lt;return{id:Ge.id,name:Ge.name,email:Ge.email,brokerage_name:((lt=Ge.brokerages)==null?void 0:lt.name)||"No Brokerage",roles:Je[Ge.id]||[],created_at:Ge.created_at}}))}catch(ve){console.error("Error loading data:",ve),me.error("Failed to load agents and brokerages")}finally{q(!1)}}},oe=async()=>{if(o){q(!0);try{const{data:ve}=await H.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(ve!=null&&ve.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:dt,error:pe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",ve.brokerage_id).neq("id",o.id).order("name");if(pe)throw pe;u(dt||[])}catch(ve){console.error("Error loading agents:",ve),me.error("Failed to load agents")}finally{q(!1)}}},he=c.filter(ve=>{var pe;const dt=ve.name.toLowerCase().includes(j.toLowerCase())||ve.email.toLowerCase().includes(j.toLowerCase())||((pe=ve.brokerage_name)==null?void 0:pe.toLowerCase().includes(j.toLowerCase()));if(l&&Y!=="all"&&Y!=="newest"){const Ue=Q[ve.id]||[];return dt&&Ue.includes(Y)}return dt}).sort((ve,dt)=>Y==="newest"?(dt.created_at||"").localeCompare(ve.created_at||""):0),xe=m.filter(ve=>ve.name.toLowerCase().includes(S.toLowerCase())),ue=()=>{g.length===he.length?y([]):y(he.map(ve=>ve.id))},ge=()=>{_.length===xe.length?w([]):w(xe.map(ve=>ve.id))},_e=ve=>{if(!ne){y([ve]);return}y(dt=>dt.includes(ve)?dt.filter(pe=>pe!==ve):[...dt,ve])},Be=ve=>{w(dt=>dt.includes(ve)?dt.filter(pe=>pe!==ve):[...dt,ve])},Se=async()=>{if(!(g.length>0||_.length>0)){me.error("Please select at least one agent or brokerage to share with");return}z(!0);try{const{data:dt,error:pe}=await H.functions.invoke("send-share-notification",{body:{recipientIds:g,brokerageIds:_,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(pe)throw pe;const Ue=(dt==null?void 0:dt.sharesCreated)||g.length;me.success(`Shared with ${Ue} agent${Ue!==1?"s":""}`),s(!1)}catch(dt){console.error("Error sharing resource:",dt),me.error("Failed to share resource")}finally{z(!1)}},Ee=ve=>ve.split(" ").map(dt=>dt[0]).join("").toUpperCase().slice(0,2),Ae=ve=>{const dt=Q[ve]||[];return dt.includes("admin")?e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):dt.includes("brokerage_manager")?e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Me=g.length+_.length,ke=Y!=="all"&&Y!=="newest"?he.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(js,{className:"flex-shrink-0",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Fn,{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(ga,{value:V,onValueChange:X,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ss,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),g.length>0&&e.jsx(Ye,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:g.length})]}),e.jsxs(ss,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),_.length>0&&e.jsx(Ye,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or brokerage...",value:j,onChange:ve=>N(ve.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:Y,onValueChange:J,children:[e.jsxs(Ls,{className:"w-[180px]",children:[e.jsx(ty,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx($s,{placeholder:"Filter by role"})]}),e.jsx(Ds,{children:$ge.map(ve=>e.jsx(ft,{value:ve.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve.icon,{className:"h-4 w-4"}),e.jsx("span",{children:ve.label})]})},ve.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(ur,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[ke!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[ke," ",(Oe=$ge.find(ve=>ve.value===Y))==null?void 0:Oe.label]}),e.jsxs("span",{className:"font-medium",children:[g.length," selected"]})]})]}),e.jsx(Li,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(ur,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Y!=="all"?`No ${(qe=$ge.find(ve=>ve.value===Y))==null?void 0:qe.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(ve.id)?"bg-accent":""}`,onClick:()=>_e(ve.id),children:[e.jsx(Mo,{checked:g.includes(ve.id),onCheckedChange:()=>_e(ve.id),className:"flex-shrink-0"}),e.jsx(Cn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(Mn,{className:"text-xs bg-primary/10 text-primary",children:Ee(ve.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:ve.name}),Ae(ve.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ve.email,ve.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",ve.brokerage_name]})]})]})]},ve.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:S,onChange:ve=>M(ve.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:ge,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(Ta,{className:"h-3.5 w-3.5 mr-1.5"}),_.length===xe.length&&xe.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(Li,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):xe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(Ta,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:xe.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${_.includes(ve.id)?"bg-accent":""}`,onClick:()=>Be(ve.id),children:[e.jsx(Mo,{checked:_.includes(ve.id),onCheckedChange:()=>Be(ve.id),className:"flex-shrink-0"}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ta,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ve.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ve.agent_count," agent",ve.agent_count!==1?"s":""]})]})]},ve.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:j,onChange:ve=>N(ve.target.value),className:"pl-9"})]}),ne&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(ur,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[g.length," selected"]})]}),e.jsx(Li,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(ur,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(ve.id)?"bg-accent":""}`,onClick:()=>_e(ve.id),children:[e.jsx(Mo,{checked:g.includes(ve.id),onCheckedChange:()=>_e(ve.id),className:"flex-shrink-0"}),e.jsx(Cn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(Mn,{className:"text-xs bg-primary/10 text-primary",children:Ee(ve.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ve.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ve.email})]})]},ve.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(ye,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Tr,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:ve=>P(ve.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:Se,disabled:Me===0||$,children:$?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function kE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=k.useState(!1),{user:c}=Fs();return c?e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(U$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function V$t(){const{eventId:t}=ao(),s=ar(),{user:r}=Fs(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(0),[u,m]=k.useState(!0),[f,g]=k.useState(!1);k.useEffect(()=>{t&&y()},[t,r]);const y=async()=>{try{const{data:M,error:I}=await H.from("events").select("*").eq("id",t).single();if(I)throw I;a(M);const{count:P}=await H.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(P||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{m(!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:I}=await H.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;me.success("Successfully cancelled registration"),l(null),c(P=>P-1)}else{const{data:I,error:P}=await H.functions.invoke("zoom-register",{body:{event_id:n.id}});if(P)throw P;me.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.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)}}},w=M=>{var I,P,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")?(I=M.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(P=M.split("v=")[1])==null?void 0:P.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(G,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const j=M0(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(G,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),j&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Ye,{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(kE,{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(fp,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Pe,{children:e.jsxs(De,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fn,{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:jD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ur,{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(wi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!j&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(G,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(G,{variant:"outline",className:"w-full",onClick:_,disabled:f,children:[f?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(G,{className:"w-full gap-2",onClick:_,disabled:f||(N??!1),children:f?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),j&&o&&e.jsxs(G,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const H$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(Px,{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(sy,{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(wn,{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(Ah,{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(nn,{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(rr,{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(_u,{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(Fn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],G$t=()=>{const{user:t,isAdmin:s}=Fs(),r=ar(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,m]=k.useState("all"),[f,g]=k.useState(new Set),[y,_]=k.useState(new Set);k.useEffect(()=>{w()},[t]);const w=async()=>{try{const{data:z}=await H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),V=(z==null?void 0:z.map(he=>he.tag))||[],{data:X,error:Y}=await H.from("app_tiles").select("*").order("name");if(Y)throw Y;const[{data:J},{data:Q}]=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)]),ce=new Set((J==null?void 0:J.map(he=>he.app_id))||[]);g(ce);const ne=new Set((Q||[]).map(he=>he.tool_id));_(ne);const oe=((X==null?void 0:X.filter(he=>!he.required_tags||he.required_tags.length===0?!0:he.required_tags.some(xe=>V.includes(xe))))||[]).sort((he,xe)=>he.name==="LevelUp Members Portal"?-1:xe.name==="LevelUp Members Portal"?1:0);a(oe)}catch(z){console.error("Error loading apps:",z),me.error("Failed to load apps")}finally{l(!1)}},j=async z=>{var X;const V=window.open("about:blank","_blank");try{const{data:Y,error:J}=await H.auth.getSession();if(J||!Y.session){V==null||V.close(),me.error("Session expired. Please refresh the page and try again.");return}const Q=Y.session.access_token;await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:z.app_id,app_name:z.name,user_agent:navigator.userAgent});const{data:ce,error:ne}=await H.functions.invoke("sso-launch",{body:{app_id:z.app_id},headers:{Authorization:`Bearer ${Q}`}});if(ne)throw ne;ce!=null&&ce.redirect_url?V&&!V.closed?(V.location.href=ce.redirect_url,(X=V.focus)==null||X.call(V)):window.location.assign(ce.redirect_url):(V==null||V.close(),me.error("Launch link unavailable"))}catch(Y){V==null||V.close(),console.error("Error launching app:",Y),me.error("Failed to launch app. Please try again.")}},N=async(z,V)=>{z.stopPropagation();const X=f.has(V);try{if(X){const{error:Y}=await H.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(Y)throw Y;g(J=>{const Q=new Set(J);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:Y}=await H.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(Y)throw Y;g(J=>new Set(J).add(V)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling favorite:",Y),me.error("Failed to update favorites")}},S=async(z,V)=>{z.stopPropagation();const X=y.has(V);try{if(X){const{error:Y}=await H.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(Y)throw Y;_(J=>{const Q=new Set(J);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:Y}=await H.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(Y)throw Y;_(J=>new Set(J).add(V)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling tool favorite:",Y),me.error("Failed to update favorites")}},M=n.filter(z=>{var X;const V=z.name.toLowerCase().includes(i.toLowerCase())||((X=z.description)==null?void 0:X.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has(z.id):V}),I=H$t.filter(z=>{if(z.adminOnly&&!s)return!1;const V=z.name.toLowerCase().includes(i.toLowerCase())||z.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?V&&y.has(z.id):V}),P=I.reduce((z,V)=>(z[V.category]||(z[V.category]=[]),z[V.category].push(V),z),{}),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==="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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:z=>c(z.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map(z=>e.jsxs("button",{onClick:()=>m(z.id),className:Pt("pb-3 text-sm font-medium transition-colors relative",u===z.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[z.label,u===z.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},z.id))}),q&&Object.keys(P).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(ry,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(P).map(([z,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:z})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:V.map(X=>{const Y=y.has(X.id);return e.jsxs("div",{onClick:()=>r(X.path),className:Pt("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",X.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[X.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:Pt("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",X.color||"bg-primary/10 text-primary"),children:X.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:[X.name,X.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:X.description})]}),e.jsx("button",{className:Pt("flex-shrink-0 p-1 transition-colors",Y?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:J=>S(J,X.id),children:e.jsx(Ax,{className:Pt("h-5 w-5",Y&&"fill-current")})})]},X.id)})})]},z))]}),$&&e.jsxs("div",{children:[u==="all"&&M.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(rn,{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"&&I.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(Ax,{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(zd,{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(G,{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(z=>{const V=f.has(z.id),X=z.name.toLowerCase().includes("agent review")||z.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>j(z),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:z.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:z.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:z.description})]}),e.jsx("button",{className:Pt("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Y=>N(Y,z.id),children:e.jsx(Ax,{className:Pt("h-5 w-5",V&&"fill-current")})})]}),X&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:Y=>Y.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},z.id)})})]}),q&&$&&M.length===0&&I.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(sn,{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"})]})]})},W$t=()=>{const t=ar(),[s,r]=k.useState(""),[n,a]=k.useState("all"),[o,l]=k.useState("all"),[i,c]=k.useState("grid"),{data:u=[]}=pt({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:m=[]}=pt({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}=pt({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:I}=await H.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:P}=await H.from("template_likes").select("template_id"),{data:O}=await H.from("template_comments").select("template_id"),q=new Map;P==null||P.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)});const $=new Map;return O==null||O.forEach(V=>{$.set(V.template_id,($.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(M||[]).filter(X=>X.template_id===V.id)||[],likesCount:q.get(V.id)||0,commentsCount:$.get(V.id)||0}))}}),y=f.filter(N=>{var P;const S=N.name.toLowerCase().includes(s.toLowerCase())||((P=N.description)==null?void 0:P.toLowerCase().includes(s.toLowerCase())),M=n==="all"||N.category_id===n,I=o==="all"||N.type_id===o;return S&&M&&I}),_=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",j=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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search templates...",value:s,onChange:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:n,onValueChange:a,children:[e.jsx(Ls,{className:"w-full sm:w-48",children:e.jsx($s,{placeholder:"All Categories"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(ft,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(Rs,{value:o,onValueChange:l,children:[e.jsx(Ls,{className:"w-full sm:w-48",children:e.jsx($s,{placeholder:"All Types"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),m.map(N=>e.jsx(ft,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(G,{variant:"outline",size:"sm",onClick:_,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>c("grid"),className:"rounded-full",children:e.jsx(Tp,{className:"h-4 w-4"})}),e.jsx(G,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>c("list"),className:"rounded-full",children:e.jsx(nh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[y.length," template",y.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(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ws,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ws,{className:"h-5 w-3/4 mb-2"}),e.jsx(ws,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ws,{className:"h-5 w-16"}),e.jsx(ws,{className:"h-5 w-20"})]})]})},S))}),!g&&y.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(G,{variant:"outline",onClick:_,children:"Clear Filters"})]}),!g&&y.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:y.map(N=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>j(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(Ye,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Uo,{className:"h-3 w-3"}),N.links.length]})})]}),e.jsxs(De,{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:Ode(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(Ye,{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(ah,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(G,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),j(N.id)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var K$t="Separator",M8e="horizontal",Z$t=["horizontal","vertical"],Qet=k.forwardRef((t,s)=>{const{decorative:r,orientation:n=M8e,...a}=t,o=Y$t(n)?n:M8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(cn.div,{"data-orientation":o,...i,...a,ref:s})});Qet.displayName=K$t;function Y$t(t){return Z$t.includes(t)}var Xet=Qet;const Qo=k.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(Xet,{ref:a,decorative:r,orientation:s,className:Pt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Qo.displayName=Xet.displayName;const Q$t=()=>{const{templateId:t}=ao(),s=ar(),{user:r,isAdmin:n}=Fs(),{toast:a}=Ra(),o=Qt(),{trackEngagement:l}=bE(),[i,c]=k.useState(""),{data:u,isLoading:m}=pt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:P}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(P)throw P;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{...I,links:O||[],guides:q||[]}},enabled:!!t}),{data:f=[]}=pt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:P}=await H.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(P)throw P;return(I||[]).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=[]}=pt({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:P}=await H.from("template_likes").select("*").eq("template_id",t);if(P)throw P;return I},enabled:!!t}),{data:y=[]}=pt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:P}=await H.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(P)throw P;const O=[...new Set(I.map(z=>z.user_id))],{data:q}=await H.from("profiles").select("id, name").in("id",O),$=new Map((q==null?void 0:q.map(z=>[z.id,z.name]))||[]);return I.map(z=>({...z,user_name:$.get(z.user_id)||"Unknown User"}))},enabled:!!t}),_=Tt({mutationFn:async I=>{const{error:P}=await H.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(P)throw P},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),w=Tt({mutationFn:async I=>{const{error:P}=await H.from("template_comments").delete().eq("id",I);if(P)throw P},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),j=Tt({mutationFn:async()=>{const I=g.find(P=>P.user_id===(r==null?void 0:r.id));if(I){const{error:P}=await H.from("template_likes").delete().eq("id",I.id);if(P)throw P}else{const{error:P}=await H.from("template_likes").insert({template_id:t,user_id:r.id});if(P)throw P}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),N=g.some(I=>I.user_id===(r==null?void 0:r.id)),S=I=>I.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),M=I=>{I.preventDefault(),!(!i.trim()||!r)&&_.mutate(i.trim())};return m?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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/templates",children:[e.jsx(Ga,{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(Ye,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(Ye,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(G,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(la,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(G,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!r||j.isPending,children:[e.jsx(ah,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Uo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(I=>e.jsxs(G,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(G,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:I.name}),I.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Al,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(G,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Al,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(Qo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Uc,{className:"h-5 w-5"}),"Comments (",y.length,")"]}),r?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:i,onChange:I=>c(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(G,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||_.isPending,children:e.jsx(Fn,{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:y.length===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):y.map(I=>e.jsx(Pe,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Cn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Mn,{className:"text-sm",children:S(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:ql(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>w.mutate(I.id),children:e.jsx(kr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Ms,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Uo,{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(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/templates",children:"Back to Templates"})})]})})},X$t=()=>{const{user:t}=Fs(),[s,r]=k.useState(""),[n,a]=k.useState("all"),{data:o=[]}=pt({queryKey:["academy-categories"],queryFn:async()=>{const{data:g,error:y}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(y)throw y;return g}}),{data:l=[],isLoading:i}=pt({queryKey:["academy-videos"],queryFn:async()=>{const{data:g,error:y}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(y)throw y;const{data:_,error:w}=await H.from("academy_resources").select("*").order("sort_order");if(w)throw w;return g.map(N=>({...N,resources:(_==null?void 0:_.filter(S=>S.video_id===N.id))||[]}))}}),{data:c=[]}=pt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:g,error:y}=await H.from("academy_video_likes").select("video_id, user_id");if(y)throw y;return g}}),u=l.filter(g=>{var w;const y=s===""||g.title.toLowerCase().includes(s.toLowerCase())||((w=g.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),_=n==="all"||g.category_id===n;return y&&_}),m=g=>c.filter(y=>y.video_id===g).length,f=g=>c.some(y=>y.video_id===g&&y.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value:s,onChange:g=>r(g.target.value),className:"pl-10"})]})}),e.jsx(ga,{value:n,onValueChange:a,children:e.jsxs(fa,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ss,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(g=>e.jsx(ss,{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(Pe,{children:e.jsxs(De,{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(la,{to:`/academy/${g.id}`,children:e.jsxs(Pe,{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(sl,{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(mn,{className:"h-3 w-3"}),g.duration]})]}),e.jsxs(Et,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Lt,{className:"text-lg line-clamp-2",children:g.title})}),g.category&&e.jsx(Ye,{variant:"secondary",className:"w-fit",children:g.category.name})]}),e.jsxs(De,{className:"pt-0",children:[g.description&&e.jsx(vr,{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(ah,{className:`h-4 w-4 ${f(g.id)?"fill-primary text-primary":""}`}),m(g.id)]}),g.resources&&g.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),g.resources.length]})]})]})]})},g.id))})]})})};function Jet({resourceType:t,resourceId:s}){const{data:r=[]}=pt({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($l,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(la,{to:`/templates/${n.id}`,children:e.jsxs(Ye,{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($l,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const J$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},eqt=()=>{const{videoId:t}=ao();ar();const{user:s,isAdmin:r}=Fs(),{toast:n}=Ra(),a=Qt(),{trackEngagement:o}=bE(),[l,i]=k.useState(""),{data:c,isLoading:u}=pt({queryKey:["academy-video",t],queryFn:async()=>{const{data:M,error:I}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:P}=await H.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...M,resources:P||[]}},enabled:!!t});k.useEffect(()=>{c&&o("academy_video",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:m=[]}=pt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:M,error:I}=await H.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return M},enabled:!!t}),{data:f=[]}=pt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:M,error:I}=await H.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const P=[...new Set(M.map($=>$.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",P),q=new Map((O==null?void 0:O.map($=>[$.id,$.name]))||[]);return M.map($=>({...$,user_name:q.get($.user_id)||"Unknown User"}))},enabled:!!t}),g=Tt({mutationFn:async M=>{const{error:I}=await H.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:M});if(I)throw I},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"})}}),y=Tt({mutationFn:async M=>{const{error:I}=await H.from("academy_video_comments").delete().eq("id",M);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),_=Tt({mutationFn:async()=>{const M=m.find(I=>I.user_id===(s==null?void 0:s.id));if(M){const{error:I}=await H.from("academy_video_likes").delete().eq("id",M.id);if(I)throw I}else{const{error:I}=await H.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=m.some(M=>M.user_id===(s==null?void 0:s.id)),j=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(I=>I[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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/academy",children:[e.jsx(Ga,{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:J$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(G,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:c.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.title}),c.category&&e.jsx(Ye,{variant:"secondary",children:c.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(G,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(la,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kE,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(G,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(ah,{className:`h-4 w-4 ${w?"fill-current":""}`}),m.length," ",m.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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"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:j(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(vi,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx(Jet,{resourceType:"academy_video",resourceId:c.id}),e.jsx(Qo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Uc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(G,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Fn,{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(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Cn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Mn,{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:ql(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(M.id),children:e.jsx(kr,{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(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/academy",children:"Back to Academy"})})]})})};function tqt(){const t=ar(),[s,r]=k.useState(""),{data:n,isLoading:a}=pt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:y,error:_}=await H.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;return y}}),{data:o}=pt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:y,error:_}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(_)throw _;return y}}),{data:l}=pt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:y,error:_}=await H.from("resource_kit_likes").select("kit_id");if(_)throw _;return y}}),{data:i}=pt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:y,error:_}=await H.from("resource_kit_comments").select("kit_id");if(_)throw _;return y}}),c=n==null?void 0:n.filter(y=>{var _;return y.name.toLowerCase().includes(s.toLowerCase())||((_=y.description)==null?void 0:_.toLowerCase().includes(s.toLowerCase()))}),u=y=>(o==null?void 0:o.filter(_=>_.kit_id===y))||[],m=y=>(l==null?void 0:l.filter(_=>_.kit_id===y).length)||0,f=y=>(i==null?void 0:i.filter(_=>_.kit_id===y).length)||0,g=y=>{t(`/toolbox/${y}`)};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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search resource kits...",value:s,onChange:y=>r(y.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((y,_)=>e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ws,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ws,{className:"h-5 w-3/4 mb-2"}),e.jsx(ws,{className:"h-4 w-full mb-4"}),e.jsx(ws,{className:"h-4 w-2/3"})]})},_))}):(c==null?void 0:c.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(Al,{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(y=>{const _=u(y.id).length,w=m(y.id),j=f(y.id);return e.jsxs(Pe,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>g(y.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:y.featured_image_url?e.jsx("img",{src:y.featured_image_url,alt:y.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(Al,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(De,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:y.name}),y.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:Ode(y.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(wn,{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(ah,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3.5 w-3.5"}),j]})]})]})]})]},y.id)})})]})})}const sqt=()=>{const{kitId:t}=ao(),{user:s,isAdmin:r}=Fs(),{toast:n}=Ra(),a=Qt(),{trackEngagement:o}=bE(),[l,i]=k.useState(""),{data:c,isLoading:u}=pt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:M,error:I}=await H.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:P}=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:P||[],links:O||[]}},enabled:!!t});k.useEffect(()=>{c&&o("toolbox",c.id,c.name,"view")},[c==null?void 0:c.id]);const{data:m=[]}=pt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:M,error:I}=await H.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return M},enabled:!!t}),{data:f=[]}=pt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:M,error:I}=await H.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const P=[...new Set(M.map($=>$.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",P),q=new Map((O==null?void 0:O.map($=>[$.id,$.name]))||[]);return M.map($=>({...$,user_name:q.get($.user_id)||"Unknown User"}))},enabled:!!t}),g=Tt({mutationFn:async M=>{const{error:I}=await H.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:M});if(I)throw I},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"})}}),y=Tt({mutationFn:async M=>{const{error:I}=await H.from("resource_kit_comments").delete().eq("id",M);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),_=Tt({mutationFn:async()=>{const M=m.find(I=>I.user_id===(s==null?void 0:s.id));if(M){const{error:I}=await H.from("resource_kit_likes").delete().eq("id",M.id);if(I)throw I}else{const{error:I}=await H.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=m.some(M=>M.user_id===(s==null?void 0:s.id)),j=M=>M.split(" ").map(I=>I[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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/toolbox",children:[e.jsx(Ga,{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(G,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(la,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(kE,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(G,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(ah,{className:`h-4 w-4 ${w?"fill-current":""}`}),m.length," ",m.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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"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(wn,{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(vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},M.id))})]})}),c.links&&c.links.length>0&&e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(rn,{className:"h-4 w-4"}),"Canva Templates (",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(rn,{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(Jet,{resourceType:"resource_kit",resourceId:c.id}),e.jsx(Qo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Uc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(G,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx(Fn,{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(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Cn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Mn,{className:"text-sm",children:j(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:ql(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(M.id),children:e.jsx(kr,{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(Al,{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(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/toolbox",children:"Back to Toolbox"})})]})})},rqt=()=>{const t=ar(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o=[],isLoading:l}=pt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:m}=await H.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(m)throw m;const{data:f,error:g}=await H.from("social_swag_links").select("*").order("sort_order");if(g)throw g;const{data:y}=await H.from("social_swag_likes").select("swag_id"),{data:_}=await H.from("social_swag_comments").select("swag_id"),w=new Map;y==null||y.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const j=new Map;return _==null||_.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(M=>M.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:j.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(G,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Tp,{className:"h-4 w-4"})}),e.jsx(G,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(nh,{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,m)=>e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ws,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ws,{className:"h-5 w-3/4 mb-2"}),e.jsx(ws,{className:"h-4 w-full mb-4"})]})},m))}),!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(G,{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(Pe,{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(Ye,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Uo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(De,{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(ah,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(G,{size:"sm",className:"w-full gap-2",onClick:m=>{m.stopPropagation(),c(u.id)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var Ci=function(){return Ci=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)},y=function(){a&&o(a)};return e.jsx(Oqt,{displayMonth:t.displayMonth,hideNext:m,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:y})}function Rqt(t){var s,r=mc(),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:stt,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(T8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(T8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(A8e,{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(A8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function Fqt(t){var s=mc(),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 zqt(t,s,r){for(var n=r?O1(new Date):tm(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=Ll(n,o);a.push(l)}return a}function Bqt(){var t=mc(),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=zqt(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(m,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(m,{locale:a}),children:i(m,{locale:a})},f)})]})}function $qt(){var t,s=mc(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:Bqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function qqt(t){var s=mc(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var zke=k.createContext(void 0);function Uqt(t){if(!cR(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(zke.Provider,{value:s,children:t.children})}return e.jsx(Vqt,{initialProps:t.initialProps,children:t.children})}function Vqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,m,f){var g,y;(g=s.onDayClick)===null||g===void 0||g.call(s,u,m,f);var _=!!(m.selected&&a&&(n==null?void 0:n.length)===a);if(!_){var w=!!(!m.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var j=n?ett([],n):[];if(m.selected){var N=j.findIndex(function(S){return Tl(u,S)});j.splice(N,1)}else j.push(u);(y=s.onSelect)===null||y===void 0||y.call(s,j,u,m,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var m=o&&n.length>o-1,f=n.some(function(g){return Tl(g,u)});return!!(m&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(zke.Provider,{value:c,children:r})}function Bke(){var t=k.useContext(zke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Hqt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?Tl(a,t)&&Tl(n,t)?void 0:Tl(a,t)?{from:a,to:void 0}:Tl(n,t)?void 0:t3(n,t)?{from:t,to:a}:{from:n,to:t}:a?t3(t,a)?{from:a,to:t}:{from:t,to:a}:n?s3(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var $ke=k.createContext(void 0);function Gqt(t){if(!dR(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx($ke.Provider,{value:s,children:t.children})}return e.jsx(Wqt,{initialProps:t.initialProps,children:t.children})}function Wqt(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(y,_,w){var j,N;(j=s.onDayClick)===null||j===void 0||j.call(s,y,_,w);var S=Hqt(y,n);(N=s.onSelect)===null||N===void 0||N.call(s,S,y,_,w)},m={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(m.range_start=[o],l?(m.range_end=[l],Tl(o,l)||(m.range_middle=[{after:o,before:l}])):m.range_end=[o]):l&&(m.range_start=[l],m.range_end=[l]),i&&(o&&!l&&m.disabled.push({after:kie(o,i-1),before:Ll(o,i-1)}),o&&l&&m.disabled.push({after:o,before:Ll(o,i-1)}),!o&&l&&m.disabled.push({after:kie(l,i-1),before:Ll(l,i-1)})),c){if(o&&!l&&(m.disabled.push({before:Ll(o,-c+1)}),m.disabled.push({after:Ll(o,c-1)})),o&&l){var f=ff(l,o)+1,g=c-f;m.disabled.push({before:kie(o,g)}),m.disabled.push({after:Ll(l,g)})}!o&&l&&(m.disabled.push({before:Ll(l,-c+1)}),m.disabled.push({after:Ll(l,c-1)}))}return e.jsx($ke.Provider,{value:{selected:n,onDayClick:u,modifiers:m},children:r})}function qke(){var t=k.useContext($ke);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Uie(t){return Array.isArray(t)?ett([],t):t!==void 0?[t]:[]}function Kqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Uie(a)}),s}var hy;(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"})(hy||(hy={}));var Zqt=hy.Selected,Pv=hy.Disabled,Yqt=hy.Hidden,Qqt=hy.Today,qge=hy.RangeEnd,Uge=hy.RangeMiddle,Vge=hy.RangeStart,Xqt=hy.Outside;function Jqt(t,s,r){var n,a=(n={},n[Zqt]=Uie(t.selected),n[Pv]=Uie(t.disabled),n[Yqt]=Uie(t.hidden),n[Qqt]=[t.today],n[qge]=[],n[Uge]=[],n[Vge]=[],n[Xqt]=[],n);return t.fromDate&&a[Pv].push({before:t.fromDate}),t.toDate&&a[Pv].push({after:t.toDate}),cR(t)?a[Pv]=a[Pv].concat(s.modifiers[Pv]):dR(t)&&(a[Pv]=a[Pv].concat(r.modifiers[Pv]),a[Vge]=r.modifiers[Vge],a[Uge]=r.modifiers[Uge],a[qge]=r.modifiers[qge]),a}var att=k.createContext(void 0);function eUt(t){var s=mc(),r=Bke(),n=qke(),a=Jqt(s,r,n),o=Kqt(s.modifiers),l=Ci(Ci({},a),o);return e.jsx(att.Provider,{value:l,children:t.children})}function itt(){var t=k.useContext(att);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function tUt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function sUt(t){return!!(t&&typeof t=="object"&&"from"in t)}function rUt(t){return!!(t&&typeof t=="object"&&"after"in t)}function nUt(t){return!!(t&&typeof t=="object"&&"before"in t)}function aUt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function iUt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=ff(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=ff(t,n)>=0&&ff(a,t)>=0;return l}return a?Tl(a,t):n?Tl(n,t):!1}function oUt(t){return Mje(t)}function lUt(t){return Array.isArray(t)&&t.every(Mje)}function cUt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(oUt(r))return Tl(t,r);if(lUt(r))return r.includes(t);if(sUt(r))return iUt(t,r);if(aUt(r))return r.dayOfWeek.includes(t.getDay());if(tUt(r)){var n=ff(r.before,t),a=ff(r.after,t),o=n>0,l=a<0,i=t3(r.before,r.after);return i?l&&o:o||l}return rUt(r)?ff(t,r.after)>0:nUt(r)?ff(r.before,t)>0:typeof r=="function"?r(t):!1})}function Uke(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return cUt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!fue(t,r)&&(a.outside=!0),a}function dUt(t,s){for(var r=Bc(t[0]),n=px(t[t.length-1]),a,o,l=r;l<=n;){var i=Uke(l,s),c=!i.disabled&&!i.hidden;if(!c){l=Ll(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=Ll(l,1)}return o||a}var uUt=365;function ott(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,m=a.toDate,f=a.locale,g={day:Ll,week:j4,month:qm,year:Q4t,startOfWeek:function(j){return a.ISOWeek?O1(j):tm(j,{locale:f,weekStartsOn:c})},endOfWeek:function(j){return a.ISOWeek?XWe(j):mue(j,{locale:f,weekStartsOn:c})}},y=g[r](t,n==="after"?1:-1);n==="before"&&u?y=X4t([u,y]):n==="after"&&m&&(y=J4t([m,y]));var _=!0;if(o){var w=Uke(y,o);_=!w.disabled&&!w.hidden}return _?y:i.count>uUt?i.lastFocused:ott(y,{moveBy:r,direction:n,context:a,modifiers:o,retry:Ci(Ci({},i),{count:i.count+1})})}var ltt=k.createContext(void 0);function hUt(t){var s=uR(),r=itt(),n=k.useState(),a=n[0],o=n[1],l=k.useState(),i=l[0],c=l[1],u=dUt(s.displayMonths,r),m=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},g=function(j){o(j)},y=mc(),_=function(j,N){if(a){var S=ott(a,{moveBy:j,direction:N,context:y,modifiers:r});Tl(a,S)||(s.goToDate(S,a),g(S))}},w={focusedDay:a,focusTarget:m,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(ltt.Provider,{value:w,children:t.children})}function Vke(){var t=k.useContext(ltt);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function mUt(t,s){var r=itt(),n=Uke(t,r,s);return n}var Hke=k.createContext(void 0);function pUt(t){if(!she(t.initialProps)){var s={selected:void 0};return e.jsx(Hke.Provider,{value:s,children:t.children})}return e.jsx(fUt,{initialProps:t.initialProps,children:t.children})}function fUt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var c,u,m;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}(m=s.onSelect)===null||m===void 0||m.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(Hke.Provider,{value:a,children:r})}function ctt(){var t=k.useContext(Hke);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function xUt(t,s){var r=mc(),n=ctt(),a=Bke(),o=qke(),l=Vke(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,m=l.focusWeekBefore,f=l.blur,g=l.focus,y=l.focusMonthBefore,_=l.focusMonthAfter,w=l.focusYearBefore,j=l.focusYearAfter,N=l.focusStartOfWeek,S=l.focusEndOfWeek,M=function(re){var oe,he,xe,ue;she(r)?(oe=n.onDayClick)===null||oe===void 0||oe.call(n,t,s,re):cR(r)?(he=a.onDayClick)===null||he===void 0||he.call(a,t,s,re):dR(r)?(xe=o.onDayClick)===null||xe===void 0||xe.call(o,t,s,re):(ue=r.onDayClick)===null||ue===void 0||ue.call(r,t,s,re)},I=function(re){var oe;g(t),(oe=r.onDayFocus)===null||oe===void 0||oe.call(r,t,s,re)},P=function(re){var oe;f(),(oe=r.onDayBlur)===null||oe===void 0||oe.call(r,t,s,re)},O=function(re){var oe;(oe=r.onDayMouseEnter)===null||oe===void 0||oe.call(r,t,s,re)},q=function(re){var oe;(oe=r.onDayMouseLeave)===null||oe===void 0||oe.call(r,t,s,re)},$=function(re){var oe;(oe=r.onDayPointerEnter)===null||oe===void 0||oe.call(r,t,s,re)},z=function(re){var oe;(oe=r.onDayPointerLeave)===null||oe===void 0||oe.call(r,t,s,re)},V=function(re){var oe;(oe=r.onDayTouchCancel)===null||oe===void 0||oe.call(r,t,s,re)},X=function(re){var oe;(oe=r.onDayTouchEnd)===null||oe===void 0||oe.call(r,t,s,re)},Y=function(re){var oe;(oe=r.onDayTouchMove)===null||oe===void 0||oe.call(r,t,s,re)},J=function(re){var oe;(oe=r.onDayTouchStart)===null||oe===void 0||oe.call(r,t,s,re)},Q=function(re){var oe;(oe=r.onDayKeyUp)===null||oe===void 0||oe.call(r,t,s,re)},ce=function(re){var oe;switch(re.key){case"ArrowLeft":re.preventDefault(),re.stopPropagation(),r.dir==="rtl"?i():c();break;case"ArrowRight":re.preventDefault(),re.stopPropagation(),r.dir==="rtl"?c():i();break;case"ArrowDown":re.preventDefault(),re.stopPropagation(),u();break;case"ArrowUp":re.preventDefault(),re.stopPropagation(),m();break;case"PageUp":re.preventDefault(),re.stopPropagation(),re.shiftKey?w():y();break;case"PageDown":re.preventDefault(),re.stopPropagation(),re.shiftKey?j():_();break;case"Home":re.preventDefault(),re.stopPropagation(),N();break;case"End":re.preventDefault(),re.stopPropagation(),S();break}(oe=r.onDayKeyDown)===null||oe===void 0||oe.call(r,t,s,re)},ne={onClick:M,onFocus:I,onBlur:P,onKeyDown:ce,onKeyUp:Q,onMouseEnter:O,onMouseLeave:q,onPointerEnter:$,onPointerLeave:z,onTouchCancel:V,onTouchEnd:X,onTouchMove:Y,onTouchStart:J};return ne}function gUt(){var t=mc(),s=ctt(),r=Bke(),n=qke(),a=she(t)?s.selected:cR(t)?r.selected:dR(t)?n.selected:void 0;return a}function yUt(t){return Object.values(hy).includes(t)}function vUt(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(yUt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function bUt(t,s){var r=Ci({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=Ci(Ci({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function _Ut(t,s,r){var n,a,o,l=mc(),i=Vke(),c=mUt(t,s),u=xUt(t,c),m=gUt(),f=!!(l.onDayClick||l.mode!=="default");k.useEffect(function(){var O;c.outside||i.focusedDay&&f&&Tl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,c.outside]);var g=vUt(l,c).join(" "),y=bUt(l,c),_=!!(c.outside&&!l.showOutsideDays||c.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:qqt,j=e.jsx(w,{date:t,displayMonth:s,activeModifiers:c}),N={style:y,className:g,children:j,role:"gridcell"},S=i.focusTarget&&Tl(i.focusTarget,t)&&!c.outside,M=i.focusedDay&&Tl(i.focusedDay,t),I=Ci(Ci(Ci({},N),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||S?0:-1,n)),u),P={isButton:f,isHidden:_,activeModifiers:c,selectedDays:m,buttonProps:I,divProps:N};return P}function wUt(t){var s=k.useRef(null),r=_Ut(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Yle,Ci({name:"day",ref:s},r.buttonProps)):e.jsx("div",Ci({},r.divProps))}function jUt(t){var s=t.number,r=t.dates,n=mc(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,m=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:m});var f=c(Number(s),{locale:i}),g=function(y){a(s,r,y)};return e.jsx(Yle,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:g,children:m})}function NUt(t){var s,r,n=mc(),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:wUt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:jUt,m;return l&&(m=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:[m,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})},s3t(f))})]})}function E8e(t,s,r){for(var n=r!=null&&r.ISOWeek?XWe(s):mue(s,r),a=r!=null&&r.ISOWeek?O1(t):tm(t,r),o=ff(n,a),l=[],i=0;i<=o;i++)l.push(Ll(a,i));var c=l.reduce(function(u,m){var f=r!=null&&r.ISOWeek?Tje(m):Eje(m,r),g=u.find(function(y){return y.weekNumber===f});return g?(g.dates.push(m),u):(u.push({weekNumber:f,dates:[m]}),u)},[]);return c}function kUt(t,s){var r=E8e(Bc(t),px(t),s);if(s!=null&&s.useFixedWeeks){var n=n3t(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=j4(o,6-n),i=E8e(j4(o,1),l,s);r.push.apply(r,i)}}return r}function SUt(t){var s,r,n,a=mc(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,m=a.components,f=a.weekStartsOn,g=a.firstWeekContainsDate,y=a.ISOWeek,_=kUt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:y,locale:o,weekStartsOn:f,firstWeekContainsDate:g}),w=(s=m==null?void 0:m.Head)!==null&&s!==void 0?s:$qt,j=(r=m==null?void 0:m.Row)!==null&&r!==void 0?r:NUt,N=(n=m==null?void 0:m.Footer)!==null&&n!==void 0?n:Fqt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&e.jsx(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:_.map(function(S){return e.jsx(j,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function CUt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var MUt=CUt()?k.useLayoutEffect:k.useEffect,Hge=!1,TUt=0;function P8e(){return"react-day-picker-".concat(++TUt)}function AUt(t){var s,r=t??(Hge?P8e():null),n=k.useState(r),a=n[0],o=n[1];return MUt(function(){a===null&&o(P8e())},[]),k.useEffect(function(){Hge===!1&&(Hge=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function EUt(t){var s,r,n=mc(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=uR().displayMonths,u=AUt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),m=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],g=l.month,y=t.displayIndex===0,_=t.displayIndex===c.length-1,w=!y&&!_;a==="rtl"&&(s=[y,_],_=s[0],y=s[1]),y&&(f.push(o.caption_start),g=Ci(Ci({},g),l.caption_start)),_&&(f.push(o.caption_end),g=Ci(Ci({},g),l.caption_end)),w&&(f.push(o.caption_between),g=Ci(Ci({},g),l.caption_between));var j=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:Rqt;return e.jsxs("div",{className:f.join(" "),style:g,children:[e.jsx(j,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(SUt,{id:m,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function PUt(t){var s=mc(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function IUt(t){var s,r,n=t.initialProps,a=mc(),o=Vke(),l=uR(),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 m=[a.classNames.root,a.className];a.numberOfMonths>1&&m.push(a.classNames.multiple_months),a.showWeekNumber&&m.push(a.classNames.with_weeknumber);var f=Ci(Ci({},a.styles.root),a.style),g=Object.keys(n).filter(function(_){return _.startsWith("data-")}).reduce(function(_,w){var j;return Ci(Ci({},_),(j={},j[w]=n[w],j))},{}),y=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:PUt;return e.jsx("div",Ci({className:m.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:e.jsx(y,{children:l.displayMonths.map(function(_,w){return e.jsx(EUt,{displayIndex:w,displayMonth:_},w)})})}))}function LUt(t){var s=t.children,r=nqt(t,["children"]);return e.jsx(jqt,{initialProps:r,children:e.jsx(Iqt,{children:e.jsx(pUt,{initialProps:r,children:e.jsx(Uqt,{initialProps:r,children:e.jsx(Gqt,{initialProps:r,children:e.jsx(eUt,{children:e.jsx(hUt,{children:s})})})})})})})}function DUt(t){return e.jsx(LUt,Ci({},t,{children:e.jsx(IUt,{initialProps:t})}))}function Nf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(DUt,{showOutsideDays:r,className:Pt("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Pt(mD({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Pt(mD({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(tl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(da,{className:"h-4 w-4"})},...n})}Nf.displayName="Calendar";var rhe="Popover",[dtt]=od(rhe,[V0]),hR=V0(),[OUt,Vw]=dtt(rhe),utt=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=hR(s),c=k.useRef(null),[u,m]=k.useState(!1),[f,g]=lh({prop:n,defaultProp:a??!1,onChange:o,caller:rhe});return e.jsx(FO,{...i,children:e.jsx(OUt,{scope:s,contentId:Iu(),triggerRef:c,open:f,onOpenChange:g,onOpenToggle:k.useCallback(()=>g(y=>!y),[g]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>m(!0),[]),onCustomAnchorRemove:k.useCallback(()=>m(!1),[]),modal:l,children:r})})};utt.displayName=rhe;var htt="PopoverAnchor",RUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Vw(htt,r),o=hR(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return k.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(nE,{...o,...n,ref:s})});RUt.displayName=htt;var mtt="PopoverTrigger",ptt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Vw(mtt,r),o=hR(r),l=Ka(s,a.triggerRef),i=e.jsx(cn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":vtt(a.open),...n,ref:l,onClick:Or(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(nE,{asChild:!0,...o,children:i})});ptt.displayName=mtt;var Gke="PopoverPortal",[FUt,zUt]=dtt(Gke,{forceMount:void 0}),ftt=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Vw(Gke,s);return e.jsx(FUt,{scope:s,forceMount:r,children:e.jsx(qd,{present:r||o.open,children:e.jsx(eE,{asChild:!0,container:a,children:n})})})};ftt.displayName=Gke;var hA="PopoverContent",xtt=k.forwardRef((t,s)=>{const r=zUt(hA,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Vw(hA,t.__scopePopover);return e.jsx(qd,{present:n||o.open,children:o.modal?e.jsx($Ut,{...a,ref:s}):e.jsx(qUt,{...a,ref:s})})});xtt.displayName=hA;var BUt=fw("PopoverContent.RemoveScroll"),$Ut=k.forwardRef((t,s)=>{const r=Vw(hA,t.__scopePopover),n=k.useRef(null),a=Ka(s,n),o=k.useRef(!1);return k.useEffect(()=>{const l=n.current;if(l)return Yde(l)},[]),e.jsx(VO,{as:BUt,allowPinchZoom:!0,children:e.jsx(gtt,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Or(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Or(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:Or(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),qUt=k.forwardRef((t,s)=>{const r=Vw(hA,t.__scopePopover),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(gtt,{...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()}})}),gtt=k.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:m,...f}=t,g=Vw(hA,r),y=hR(r);return Wde(),e.jsx(qO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(zO,{"data-state":vtt(g.open),role:"dialog",id:g.contentId,...y,...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)"}})})})}),ytt="PopoverClose",UUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Vw(ytt,r);return e.jsx(cn.button,{type:"button",...n,ref:s,onClick:Or(t.onClick,()=>a.onOpenChange(!1))})});UUt.displayName=ytt;var VUt="PopoverArrow",HUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=hR(r);return e.jsx(BO,{...a,...n,ref:s})});HUt.displayName=VUt;function vtt(t){return t?"open":"closed"}var GUt=utt,WUt=ptt,KUt=ftt,btt=xtt;const Vo=GUt,Ho=WUt,$o=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(KUt,{children:e.jsx(btt,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));$o.displayName=btt.displayName;const ZUt=S3("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"}}),Wke=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Pt(ZUt({variant:s}),t),...r}));Wke.displayName="Alert";const YUt=k.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Pt("mb-1 font-medium leading-none tracking-tight",t),...s}));YUt.displayName="AlertTitle";const Kke=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("text-sm [&_p]:leading-relaxed",t),...s}));Kke.displayName="AlertDescription";function QUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Qt(),[c,u]=k.useState(a),[m,f]=k.useState([]),[g,y]=k.useState(null),[_,w]=k.useState("now"),[j,N]=k.useState(S6e(P6e(new Date),1)),[S,M]=k.useState("12"),[I,P]=k.useState("00"),[O,q]=k.useState("PM");k.useEffect(()=>{if(t){u(a),w("now"),f([]);const _e=S6e(P6e(new Date),1);N(_e);const Be=_e.getHours();M(String(Be>12?Be-12:Be===0?12:Be)),P("00"),q(Be>=12?"PM":"AM")}},[t,a]);const $=()=>{if(!j)return null;let _e=parseInt(S);const Be=parseInt(I);return O==="PM"&&_e!==12&&(_e+=12),O==="AM"&&_e===12&&(_e=0),l8(o8(j,_e),Be)},{data:z,isLoading:V}=pt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:_e}}=await H.auth.getUser();if(!_e)return[];const{data:Be,error:Se}=await H.from("social_accounts").select("*").eq("user_id",_e.id).eq("is_active",!0).order("platform",{ascending:!0});if(Se)throw Se;return console.log("Fetched social accounts for posting:",Be),Be},enabled:t,staleTime:0}),X=Tt({mutationFn:async({accountId:_e,platform:Be})=>{y(_e);const{data:Se,error:Ee}=await H.functions.invoke("social-post",{body:{platform:Be,accountId:_e,imageUrl:r,caption:c}});if(Ee)throw Ee;if(Se!=null&&Se.error)throw new Error(Se.error);return Se},onSuccess:_e=>{const Be=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":_e.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${Be}!`)},onError:_e=>{me.error(`Failed to post: ${_e.message}`)},onSettled:()=>{y(null)}}),Y=Tt({mutationFn:async({accountId:_e,platform:Be,scheduledFor:Se})=>{const{data:{user:Ee}}=await H.auth.getUser();if(!Ee)throw new Error("Not authenticated");const{error:Ae}=await H.from("scheduled_posts").insert({user_id:Ee.id,social_account_id:_e,platform:Be,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:Se.toISOString(),status:"scheduled"});if(Ae)throw Ae;return{platform:Be}},onSuccess:_e=>{const Be=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${Be}!`)},onError:_e=>{me.error(`Failed to schedule: ${_e.message}`)}}),J=async()=>{if(m.length===0){me.error("Please select at least one account");return}if(_==="schedule"){const _e=$();if(!_e||_e<=new Date){me.error("Please select a future date and time");return}for(const Be of m){const Se=z==null?void 0:z.find(Ee=>Ee.id===Be);Se&&await Y.mutateAsync({accountId:Be,platform:Se.platform,scheduledFor:_e})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${m.length} post(s) scheduled for ${ds(_e,"PPp")}`)}else for(const _e of m){const Be=z==null?void 0:z.find(Se=>Se.id===_e);Be&&await X.mutateAsync({accountId:_e,platform:Be.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Q=_e=>{f(Be=>Be.includes(_e)?Be.filter(Se=>Se!==_e):[...Be,_e])},ce=(z==null?void 0:z.filter(_e=>_e.platform==="facebook"))||[],ne=(z==null?void 0:z.filter(_e=>_e.platform==="instagram"))||[],re=(z==null?void 0:z.filter(_e=>_e.platform==="linkedin"))||[],oe=(z==null?void 0:z.filter(_e=>_e.platform==="google_business"))||[],he=((z==null?void 0:z.length)||0)>0,xe=X.isPending||Y.isPending,ue=Array.from({length:12},(_e,Be)=>String(Be+1)),ge=["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(js,{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(ye,{htmlFor:"caption",children:"Caption"}),e.jsx(Tr,{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(ye,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:Pt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="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(mn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!j&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),j?ds(j,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:j,onSelect:N,disabled:_e=>_ee.jsx(ft,{value:_e,children:_e},_e))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Rs,{value:I,onValueChange:P,children:[e.jsx(Ls,{className:"w-[70px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:ge.map(_e=>e.jsx(ft,{value:_e,children:_e},_e))})]}),e.jsxs(Rs,{value:O,onValueChange:_e=>q(_e),children:[e.jsx(Ls,{className:"w-[70px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"AM",children:"AM"}),e.jsx(ft,{value:"PM",children:"PM"})]})]})]})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ds($()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ys,{className:"h-6 w-6 animate-spin"})}),!V&&!he&&e.jsxs(Wke,{children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsxs(Kke,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(la,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(el,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),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(Au,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),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(Mo,{checked:m.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:_e.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Au,{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(ys,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),ne.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(Pu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ne.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(Mo,{checked:m.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:_e.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Pu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",_e.platform_username]}),g===_e.id&&e.jsx(ys,{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(Ap,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),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(Mo,{checked:m.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:_e.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Ap,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.platform_username}),g===_e.id&&e.jsx(ys,{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(aa,{className:"h-4 w-4 text-red-600"})," Google Business"]}),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(Mo,{checked:m.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:_e.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(aa,{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(ys,{className:"h-4 w-4 animate-spin"})]},_e.id))]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:J,disabled:m.length===0||xe,className:"gap-2",children:[xe?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):_==="schedule"?e.jsx(fn,{className:"h-4 w-4"}):e.jsx(Fn,{className:"h-4 w-4"}),_==="schedule"?`Schedule ${m.length} post${m.length!==1?"s":""}`:`Post to ${m.length} account${m.length!==1?"s":""}`]})]})]})})}function XUt(){const t=Qt(),[s,r]=k.useState(void 0),[n,a]=k.useState("all"),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,m]=k.useState(void 0),[f,g]=k.useState("12"),[y,_]=k.useState("00"),[w,j]=k.useState("PM"),{data:N=[],isLoading:S}=pt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:oe,error:he}=await H.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(he)throw he;return oe}}),M=N.filter(oe=>{if(n!=="all"&&oe.status!==n)return!1;if(s&&oe.scheduled_for){const he=new Date(oe.scheduled_for);if(!Tl(he,s))return!1}return!0}),I=N.filter(oe=>oe.scheduled_for).map(oe=>Um(new Date(oe.scheduled_for))),P=Tt({mutationFn:async oe=>{const{error:he}=await H.from("scheduled_posts").update({caption:oe.caption,scheduled_for:oe.scheduled_for}).eq("id",oe.id);if(he)throw he},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:oe=>{me.error(`Failed to update: ${oe.message}`)}}),O=Tt({mutationFn:async oe=>{const{error:he}=await H.from("scheduled_posts").update({status:"cancelled"}).eq("id",oe);if(he)throw he},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to cancel: ${oe.message}`)}}),q=Tt({mutationFn:async oe=>{const{error:he}=await H.from("scheduled_posts").delete().eq("id",oe);if(he)throw he},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to delete: ${oe.message}`)}}),$=Tt({mutationFn:async oe=>{const{data:he,error:xe}=await H.functions.invoke("social-post",{body:{platform:oe.platform,accountId:oe.social_account_id,imageUrl:oe.image_url,caption:oe.caption}});if(xe)throw xe;if(he!=null&&he.error)throw new Error(he.error);return await H.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:he.postId}).eq("id",oe.id),he},onSuccess:oe=>{const he=oe.platform==="facebook"?"Facebook":oe.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${he}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to post: ${oe.message}`)}}),z=oe=>{if(l(oe),c(oe.caption||""),oe.scheduled_for){const he=new Date(oe.scheduled_for);m(he);const xe=he.getHours();g(String(xe>12?xe-12:xe===0?12:xe)),_(String(he.getMinutes()).padStart(2,"0")),j(xe>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let oe=parseInt(f);const he=parseInt(y);w==="PM"&&oe!==12&&(oe+=12),w==="AM"&&oe===12&&(oe=0);const xe=l8(o8(u,oe),he);P.mutate({id:o.id,caption:i,scheduled_for:xe.toISOString()})},X=oe=>{switch(oe){case"facebook":return e.jsx(Au,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Pu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Ap,{className:"h-4 w-4 text-blue-700"});default:return null}},Y=oe=>{switch(oe){case"scheduled":return e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(Ye,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(wi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(Ye,{variant:"destructive",className:"gap-1",children:[e.jsx(Nc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(Ye,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(ul,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(Ye,{variant:"outline",children:oe})}},J=Array.from({length:12},(oe,he)=>String(he+1)),Q=["00","15","30","45"],ce=N.filter(oe=>oe.status==="scheduled").length,ne=N.filter(oe=>oe.status==="posted").length,re=N.filter(oe=>oe.status==="scheduled"&&oe.scheduled_for&&a3t(new Date(oe.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(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ce}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:re}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ne}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Pe,{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(Pe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Fd,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(Nf,{mode:"single",selected:s,onSelect:r,className:Pt("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(G,{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(ty,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(oe=>e.jsx(G,{variant:n===oe?"default":"outline",size:"sm",onClick:()=>a(oe),className:"capitalize",children:oe},oe))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&M.length===0&&e.jsxs(Pe,{className:"p-8 text-center",children:[e.jsx(fn,{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 ${ds(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:M.map(oe=>{var he,xe;return e.jsx(Pe,{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:oe.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(De,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[X(oe.platform),e.jsx("span",{className:"font-medium",children:((he=oe.social_accounts)==null?void 0:he.page_name)||((xe=oe.social_accounts)==null?void 0:xe.platform_username)||"Unknown"}),Y(oe.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[oe.status==="scheduled"&&e.jsxs(W1,{children:[e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>z(oe),children:e.jsx(Pa,{className:"h-4 w-4"})})}),e.jsx(sc,{children:"Edit post"})]}),e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>$.mutate(oe),disabled:$.isPending,children:$.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"})})}),e.jsx(sc,{children:"Post now"})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Cancel this scheduled post?"}),e.jsx(lc,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Keep"}),e.jsx(zl,{onClick:()=>O.mutate(oe.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(zl,{onClick:()=>q.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(oe.status==="posted"||oe.status==="cancelled"||oe.status==="failed")&&e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete this post?"}),e.jsx(lc,{children:"This will permanently remove this post from your history."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>q.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),oe.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:oe.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),oe.status==="posted"&&oe.posted_at?`Posted ${ds(new Date(oe.posted_at),"PPp")}`:oe.scheduled_for?`Scheduled for ${ds(new Date(oe.scheduled_for),"PPp")}`:"Not scheduled"]}),oe.status==="failed"&&oe.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",oe.error_message]})]})]})},oe.id)})})]})]}),e.jsx(fs,{open:!!o,onOpenChange:oe=>!oe&&l(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{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(ye,{children:"Caption"}),e.jsx(Tr,{value:i,onChange:oe=>c(oe.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(ye,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),u?ds(u,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:u,onSelect:m,disabled:oe=>oee.jsx(ft,{value:oe,children:oe},oe))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Rs,{value:y,onValueChange:_,children:[e.jsx(Ls,{className:"w-[70px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:Q.map(oe=>e.jsx(ft,{value:oe,children:oe},oe))})]}),e.jsxs(Rs,{value:w,onValueChange:oe=>j(oe),children:[e.jsx(Ls,{className:"w-[70px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"AM",children:"AM"}),e.jsx(ft,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(G,{onClick:V,disabled:P.isPending,children:[P.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function $z(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 _tt={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,m){if(!a[u]){if(!n[u]){var f=typeof $z=="function"&&$z;if(!m&&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 y=a[u]={exports:{}};n[u][0].call(y.exports,function(_){var w=n[u][1][_];return l(w||_)},y,y.exports,r,n,a,o)}return a[u].exports}for(var i=typeof $z=="function"&&$z,c=0;c>2,y=(3&u)<<4|m>>4,_=1>6:64,w=2>4,m=(15&g)<<4|(y=i.indexOf(c.charAt(w++)))>>2,f=(3&y)<<6|(_=i.indexOf(c.charAt(w++))),S[j++]=u,y!==64&&(S[j++]=m),_!==64&&(S[j++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(m,f,g,y,_){this.compressedSize=m,this.uncompressedSize=f,this.crc32=g,this.compression=y,this.compressedContent=_}u.prototype={getContentWorker:function(){var m=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return m.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},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(m,f,g){return m.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 m=0;m<8;m++)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,m,f,g){var y=l,_=g+f;u^=-1;for(var w=g;w<_;w++)u=u>>>8^y[255&(u^m[w])];return-1^u}(0|c,i,i.length,0):function(u,m,f,g){var y=l,_=g+f;u^=-1;for(var w=g;w<_;w++)u=u>>>8^y[255&(u^m.charCodeAt(w))];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 m(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}a.magic="\b\0",i.inherits(m,c),m.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},m.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},m.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 m("Deflate",f)},a.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(y,_){var w,j="";for(w=0;w<_;w++)j+=String.fromCharCode(255&y),y>>>=8;return j}function l(y,_,w,j,N,S){var M,I,P=y.file,O=y.compression,q=S!==u.utf8encode,$=i.transformTo("string",S(P.name)),z=i.transformTo("string",u.utf8encode(P.name)),V=P.comment,X=i.transformTo("string",S(V)),Y=i.transformTo("string",u.utf8encode(V)),J=z.length!==P.name.length,Q=Y.length!==V.length,ce="",ne="",re="",oe=P.dir,he=P.date,xe={crc32:0,compressedSize:0,uncompressedSize:0};_&&!w||(xe.crc32=y.crc32,xe.compressedSize=y.compressedSize,xe.uncompressedSize=y.uncompressedSize);var ue=0;_&&(ue|=8),q||!J&&!Q||(ue|=2048);var ge=0,_e=0;oe&&(ge|=16),N==="UNIX"?(_e=798,ge|=function(Se,Ee){var Ae=Se;return Se||(Ae=Ee?16893:33204),(65535&Ae)<<16}(P.unixPermissions,oe)):(_e=20,ge|=function(Se){return 63&(Se||0)}(P.dosPermissions)),M=he.getUTCHours(),M<<=6,M|=he.getUTCMinutes(),M<<=5,M|=he.getUTCSeconds()/2,I=he.getUTCFullYear()-1980,I<<=4,I|=he.getUTCMonth()+1,I<<=5,I|=he.getUTCDate(),J&&(ne=o(1,1)+o(m($),4)+z,ce+="up"+o(ne.length,2)+ne),Q&&(re=o(1,1)+o(m(X),4)+Y,ce+="uc"+o(re.length,2)+re);var Be="";return Be+=` \0`,Be+=o(ue,2),Be+=O.magic,Be+=o(M,2),Be+=o(I,2),Be+=o(xe.crc32,4),Be+=o(xe.compressedSize,4),Be+=o(xe.uncompressedSize,4),Be+=o($.length,2),Be+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Be+$+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(_e,2)+Be+o(X.length,2)+"\0\0\0\0"+o(ge,4)+o(j,4)+$+ce+X}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),m=r("../crc32"),f=r("../signature");function g(y,_,w,j){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=w,this.encodeFileName=j,this.streamFiles=y,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(y){var _=y.meta.percent||0,w=this.entriesCount,j=this._sources.length;this.accumulate?this.contentBuffer.push(y):(this.bytesWritten+=y.data.length,c.prototype.push.call(this,{data:y.data,meta:{currentFile:this.currentFile,percent:w?(_+100*(w-j-1))/w:100}}))},g.prototype.openedSource=function(y){this.currentSourceOffset=this.bytesWritten,this.currentFile=y.file.name;var _=this.streamFiles&&!y.file.dir;if(_){var w=l(y,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(y){this.accumulate=!1;var _=this.streamFiles&&!y.file.dir,w=l(y,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),_)this.push({data:function(j){return f.DATA_DESCRIPTOR+o(j.crc32,4)+o(j.compressedSize,4)+o(j.uncompressedSize,4)}(y),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var y=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"),m=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 m(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(m){u.dataIsReady=!0,u.data=m,u.max=m&&m.length||0,u.type=o.getTypeOf(m),u.isPaused||u._tickAndRepeat()},function(m){u.error(m)})}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"),m=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(_,w){return new m.Promise(function(j,N){var S=[],M=_._internalType,I=_._outputType,P=_._mimeType;_.on("data",function(O,q){S.push(O),w&&w(q)}).on("error",function(O){S=[],N(O)}).on("end",function(){try{var O=function(q,$,z){switch(q){case"blob":return o.newBlob(o.transformTo("arraybuffer",$),z);case"base64":return c.encode($);default:return o.transformTo(q,$)}}(I,function(q,$){var z,V=0,X=null,Y=0;for(z=0;z<$.length;z++)Y+=$[z].length;switch(q){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":for(X=new Uint8Array(Y),z=0;z<$.length;z++)X.set($[z],V),V+=$[z].length;return X;case"nodebuffer":return Buffer.concat($);default:throw new Error("concat : unsupported type '"+q+"'")}}(M,S),P);j(O)}catch(q){N(q)}S=[]}).resume()})}function y(_,w,j){var N=w;switch(w){case"blob":case"arraybuffer":N="uint8array";break;case"base64":N="string"}try{this._internalType=N,this._outputType=w,this._mimeType=j,o.checkSupport(N),this._worker=_.pipe(new l(N)),_.lock()}catch(S){this._worker=new i("error"),this._worker.error(S)}}y.prototype={accumulate:function(_){return g(this,_)},on:function(_,w){var j=this;return _==="data"?this._worker.on(_,function(N){w.call(j,N.data,N.meta)}):this._worker.on(_,function(){o.delay(w,arguments,j)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},_)}},n.exports=y},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,n,a){if(a.base64=!0,a.array=!0,a.string=!0,a.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",a.nodebuffer=typeof Buffer<"u",a.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"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),m=0;m<256;m++)u[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?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(y){return l.nodebuffer?i.newBufferFrom(y,"utf-8"):function(_){var w,j,N,S,M,I=_.length,P=0;for(S=0;S>>6:(j<65536?w[M++]=224|j>>>12:(w[M++]=240|j>>>18,w[M++]=128|j>>>12&63),w[M++]=128|j>>>6&63),w[M++]=128|63&j);return w}(y)},a.utf8decode=function(y){return l.nodebuffer?o.transformTo("nodebuffer",y).toString("utf-8"):function(_){var w,j,N,S,M=_.length,I=new Array(2*M);for(w=j=0;w>10&1023,I[j++]=56320|1023&N)}return I.length!==j&&(I.subarray?I=I.subarray(0,j):I.length=j),o.applyFromCharCode(I)}(y=o.transformTo(l.uint8array?"uint8array":"array",y))},o.inherits(f,c),f.prototype.processChunk=function(y){var _=o.transformTo(l.uint8array?"uint8array":"array",y.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=_;(_=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),_.set(w,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var j=function(S,M){var I;for((M=M||S.length)>S.length&&(M=S.length),I=M-1;0<=I&&(192&S[I])==128;)I--;return I<0||I===0?M:I+u[S[I]]>M?I:M}(_),N=_;j!==_.length&&(l.uint8array?(N=_.subarray(0,j),this.leftOver=_.subarray(j,_.length)):(N=_.slice(0,j),this.leftOver=_.slice(j,_.length))),this.push({data:a.utf8decode(N),meta:y.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(y){this.push({data:a.utf8encode(y.data),meta:y.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(w){return w}function m(w,j){for(var N=0;N>8;this.dir=!!(16&this.externalFileAttributes),y==0&&(this.dosPermissions=63&this.externalFileAttributes),y==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var y=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=y.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=y.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=y.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=y.readInt(4))}},readExtraFields:function(y){var _,w,j,N=y.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});y.index+4>>6:(y<65536?g[j++]=224|y>>>12:(g[j++]=240|y>>>18,g[j++]=128|y>>>12&63),g[j++]=128|y>>>6&63),g[j++]=128|63&y);return g},a.buf2binstring=function(f){return m(f,f.length)},a.binstring2buf=function(f){for(var g=new o.Buf8(f.length),y=0,_=g.length;y<_;y++)g[y]=f.charCodeAt(y);return g},a.buf2string=function(f,g){var y,_,w,j,N=g||f.length,S=new Array(2*N);for(y=_=0;y>10&1023,S[_++]=56320|1023&w)}return m(S,_)},a.utf8border=function(f,g){var y;for((g=g||f.length)>f.length&&(g=f.length),y=g-1;0<=y&&(192&f[y])==128;)y--;return y<0||y===0?g:y+c[f[y]]>g?y:g}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,c){for(var u=65535&o|0,m=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 m=o,f=u+c;l^=-1;for(var g=u;g>>8^m[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"),m=r("./messages"),f=0,g=4,y=0,_=-2,w=-1,j=4,N=2,S=8,M=9,I=286,P=30,O=19,q=2*I+1,$=15,z=3,V=258,X=V+z+1,Y=42,J=113,Q=1,ce=2,ne=3,re=4;function oe(pe,Ue){return pe.msg=m[Ue],Ue}function he(pe){return(pe<<1)-(4pe.avail_out&&(Xe=pe.avail_out),Xe!==0&&(l.arraySet(pe.output,Ue.pending_buf,Ue.pending_out,Xe,pe.next_out),pe.next_out+=Xe,Ue.pending_out+=Xe,pe.total_out+=Xe,pe.avail_out-=Xe,Ue.pending-=Xe,Ue.pending===0&&(Ue.pending_out=0))}function ge(pe,Ue){i._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,Ue),pe.block_start=pe.strstart,ue(pe.strm)}function _e(pe,Ue){pe.pending_buf[pe.pending++]=Ue}function Be(pe,Ue){pe.pending_buf[pe.pending++]=Ue>>>8&255,pe.pending_buf[pe.pending++]=255&Ue}function Se(pe,Ue){var Xe,et,Ce=pe.max_chain_length,Je=pe.strstart,Ge=pe.prev_length,lt=pe.nice_match,He=pe.strstart>pe.w_size-X?pe.strstart-(pe.w_size-X):0,We=pe.window,tt=pe.w_mask,Ke=pe.prev,rt=pe.strstart+V,it=We[Je+Ge-1],It=We[Je+Ge];pe.prev_length>=pe.good_match&&(Ce>>=2),lt>pe.lookahead&&(lt=pe.lookahead);do if(We[(Xe=Ue)+Ge]===It&&We[Xe+Ge-1]===it&&We[Xe]===We[Je]&&We[++Xe]===We[Je+1]){Je+=2,Xe++;do;while(We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&We[++Je]===We[++Xe]&&JeHe&&--Ce!=0);return Ge<=pe.lookahead?Ge:pe.lookahead}function Ee(pe){var Ue,Xe,et,Ce,Je,Ge,lt,He,We,tt,Ke=pe.w_size;do{if(Ce=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=Ke+(Ke-X)){for(l.arraySet(pe.window,pe.window,Ke,Ke,0),pe.match_start-=Ke,pe.strstart-=Ke,pe.block_start-=Ke,Ue=Xe=pe.hash_size;et=pe.head[--Ue],pe.head[Ue]=Ke<=et?et-Ke:0,--Xe;);for(Ue=Xe=Ke;et=pe.prev[--Ue],pe.prev[Ue]=Ke<=et?et-Ke:0,--Xe;);Ce+=Ke}if(pe.strm.avail_in===0)break;if(Ge=pe.strm,lt=pe.window,He=pe.strstart+pe.lookahead,We=Ce,tt=void 0,tt=Ge.avail_in,We=z)for(Je=pe.strstart-pe.insert,pe.ins_h=pe.window[Je],pe.ins_h=(pe.ins_h<=z&&(pe.ins_h=(pe.ins_h<=z)if(et=i._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-z),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=z){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<=z&&(pe.ins_h=(pe.ins_h<=z&&pe.match_length<=pe.prev_length){for(Ce=pe.strstart+pe.lookahead-z,et=i._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-z),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Ce&&(pe.ins_h=(pe.ins_h<pe.pending_buf_size-5&&(Xe=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(Ee(pe),pe.lookahead===0&&Ue===f)return Q;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var et=pe.block_start+Xe;if((pe.strstart===0||pe.strstart>=et)&&(pe.lookahead=pe.strstart-et,pe.strstart=et,ge(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-X&&(ge(pe,!1),pe.strm.avail_out===0))return Q}return pe.insert=0,Ue===g?(ge(pe,!0),pe.strm.avail_out===0?ne:re):(pe.strstart>pe.block_start&&(ge(pe,!1),pe.strm.avail_out),Q)}),new ke(4,4,8,4,Ae),new ke(4,5,16,8,Ae),new ke(4,6,32,32,Ae),new ke(4,4,16,16,Me),new ke(8,16,32,32,Me),new ke(8,16,128,128,Me),new ke(8,32,128,256,Me),new ke(32,128,258,1024,Me),new ke(32,258,258,4096,Me)],a.deflateInit=function(pe,Ue){return dt(pe,Ue,S,15,8,0)},a.deflateInit2=dt,a.deflateReset=ve,a.deflateResetKeep=qe,a.deflateSetHeader=function(pe,Ue){return pe&&pe.state?pe.state.wrap!==2?_:(pe.state.gzhead=Ue,y):_},a.deflate=function(pe,Ue){var Xe,et,Ce,Je;if(!pe||!pe.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&&(pe.adler=u(pe.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=J);else{var Ge=S+(et.w_bits-8<<4)<<8;Ge|=(2<=et.strategy||et.level<2?0:et.level<6?1:et.level===6?2:3)<<6,et.strstart!==0&&(Ge|=32),Ge+=31-Ge%31,et.status=J,Be(et,Ge),et.strstart!==0&&(Be(et,pe.adler>>>16),Be(et,65535&pe.adler)),pe.adler=1}if(et.status===69)if(et.gzhead.extra){for(Ce=et.pending;et.gzindex<(65535&et.gzhead.extra.length)&&(et.pending!==et.pending_buf_size||(et.gzhead.hcrc&&et.pending>Ce&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(pe),Ce=et.pending,et.pending!==et.pending_buf_size));)_e(et,255&et.gzhead.extra[et.gzindex]),et.gzindex++;et.gzhead.hcrc&&et.pending>Ce&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),et.gzindex===et.gzhead.extra.length&&(et.gzindex=0,et.status=73)}else et.status=73;if(et.status===73)if(et.gzhead.name){Ce=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Ce&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(pe),Ce=et.pending,et.pending===et.pending_buf_size)){Je=1;break}Je=et.gzindexCe&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),Je===0&&(et.gzindex=0,et.status=91)}else et.status=91;if(et.status===91)if(et.gzhead.comment){Ce=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Ce&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),ue(pe),Ce=et.pending,et.pending===et.pending_buf_size)){Je=1;break}Je=et.gzindexCe&&(pe.adler=u(pe.adler,et.pending_buf,et.pending-Ce,Ce)),Je===0&&(et.status=103)}else et.status=103;if(et.status===103&&(et.gzhead.hcrc?(et.pending+2>et.pending_buf_size&&ue(pe),et.pending+2<=et.pending_buf_size&&(_e(et,255&pe.adler),_e(et,pe.adler>>8&255),pe.adler=0,et.status=J)):et.status=J),et.pending!==0){if(ue(pe),pe.avail_out===0)return et.last_flush=-1,y}else if(pe.avail_in===0&&he(Ue)<=he(Xe)&&Ue!==g)return oe(pe,-5);if(et.status===666&&pe.avail_in!==0)return oe(pe,-5);if(pe.avail_in!==0||et.lookahead!==0||Ue!==f&&et.status!==666){var lt=et.strategy===2?function(He,We){for(var tt;;){if(He.lookahead===0&&(Ee(He),He.lookahead===0)){if(We===f)return Q;break}if(He.match_length=0,tt=i._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++,tt&&(ge(He,!1),He.strm.avail_out===0))return Q}return He.insert=0,We===g?(ge(He,!0),He.strm.avail_out===0?ne:re):He.last_lit&&(ge(He,!1),He.strm.avail_out===0)?Q:ce}(et,Ue):et.strategy===3?function(He,We){for(var tt,Ke,rt,it,It=He.window;;){if(He.lookahead<=V){if(Ee(He),He.lookahead<=V&&We===f)return Q;if(He.lookahead===0)break}if(He.match_length=0,He.lookahead>=z&&0He.lookahead&&(He.match_length=He.lookahead)}if(He.match_length>=z?(tt=i._tr_tally(He,1,He.match_length-z),He.lookahead-=He.match_length,He.strstart+=He.match_length,He.match_length=0):(tt=i._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++),tt&&(ge(He,!1),He.strm.avail_out===0))return Q}return He.insert=0,We===g?(ge(He,!0),He.strm.avail_out===0?ne:re):He.last_lit&&(ge(He,!1),He.strm.avail_out===0)?Q:ce}(et,Ue):o[et.level].func(et,Ue);if(lt!==ne&<!==re||(et.status=666),lt===Q||lt===ne)return pe.avail_out===0&&(et.last_flush=-1),y;if(lt===ce&&(Ue===1?i._tr_align(et):Ue!==5&&(i._tr_stored_block(et,0,0,!1),Ue===3&&(xe(et.head),et.lookahead===0&&(et.strstart=0,et.block_start=0,et.insert=0))),ue(pe),pe.avail_out===0))return et.last_flush=-1,y}return Ue!==g?y:et.wrap<=0?1:(et.wrap===2?(_e(et,255&pe.adler),_e(et,pe.adler>>8&255),_e(et,pe.adler>>16&255),_e(et,pe.adler>>24&255),_e(et,255&pe.total_in),_e(et,pe.total_in>>8&255),_e(et,pe.total_in>>16&255),_e(et,pe.total_in>>24&255)):(Be(et,pe.adler>>>16),Be(et,65535&pe.adler)),ue(pe),0=Xe.w_size&&(Je===0&&(xe(Xe.head),Xe.strstart=0,Xe.block_start=0,Xe.insert=0),We=new l.Buf8(Xe.w_size),l.arraySet(We,Ue,tt-Xe.w_size,Xe.w_size,0),Ue=We,tt=Xe.w_size),Ge=pe.avail_in,lt=pe.next_in,He=pe.input,pe.avail_in=tt,pe.next_in=0,pe.input=Ue,Ee(Xe);Xe.lookahead>=z;){for(et=Xe.strstart,Ce=Xe.lookahead-(z-1);Xe.ins_h=(Xe.ins_h<>>=z=$>>>24,M-=z,(z=$>>>16&255)===0)ce[m++]=65535&$;else{if(!(16&z)){if(!(64&z)){$=I[(65535&$)+(S&(1<>>=z,M-=z),M<15&&(S+=Q[c++]<>>=z=$>>>24,M-=z,!(16&(z=$>>>16&255))){if(!(64&z)){$=P[(65535&$)+(S&(1<>>=z,M-=z,(z=m-f)>3,S&=(1<<(M-=V<<3))-1,o.next_in=c,o.next_out=m,o.avail_in=c>>24&255)+(Y>>>8&65280)+((65280&Y)<<8)+((255&Y)<<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(Y){var J;return Y&&Y.state?(J=Y.state,Y.total_in=Y.total_out=J.total=0,Y.msg="",J.wrap&&(Y.adler=1&J.wrap),J.mode=_,J.last=0,J.havedict=0,J.dmax=32768,J.head=null,J.hold=0,J.bits=0,J.lencode=J.lendyn=new o.Buf32(w),J.distcode=J.distdyn=new o.Buf32(j),J.sane=1,J.back=-1,g):y}function I(Y){var J;return Y&&Y.state?((J=Y.state).wsize=0,J.whave=0,J.wnext=0,M(Y)):y}function P(Y,J){var Q,ce;return Y&&Y.state?(ce=Y.state,J<0?(Q=0,J=-J):(Q=1+(J>>4),J<48&&(J&=15)),J&&(J<8||15=re.wsize?(o.arraySet(re.window,J,Q-re.wsize,re.wsize,0),re.wnext=0,re.whave=re.wsize):(ce<(ne=re.wsize-re.wnext)&&(ne=ce),o.arraySet(re.window,J,Q-ce,ne,re.wnext),(ce-=ne)?(o.arraySet(re.window,J,Q-ce,ce,0),re.wnext=ce,re.whave=re.wsize):(re.wnext+=ne,re.wnext===re.wsize&&(re.wnext=0),re.whave>>8&255,Q.check=i(Q.check,Je,2,0),ge=ue=0,Q.mode=2;break}if(Q.flags=0,Q.head&&(Q.head.done=!1),!(1&Q.wrap)||(((255&ue)<<8)+(ue>>8))%31){Y.msg="incorrect header check",Q.mode=30;break}if((15&ue)!=8){Y.msg="unknown compression method",Q.mode=30;break}if(ge-=4,pe=8+(15&(ue>>>=4)),Q.wbits===0)Q.wbits=pe;else if(pe>Q.wbits){Y.msg="invalid window size",Q.mode=30;break}Q.dmax=1<>8&1),512&Q.flags&&(Je[0]=255&ue,Je[1]=ue>>>8&255,Q.check=i(Q.check,Je,2,0)),ge=ue=0,Q.mode=3;case 3:for(;ge<32;){if(he===0)break e;he--,ue+=ce[re++]<>>8&255,Je[2]=ue>>>16&255,Je[3]=ue>>>24&255,Q.check=i(Q.check,Je,4,0)),ge=ue=0,Q.mode=4;case 4:for(;ge<16;){if(he===0)break e;he--,ue+=ce[re++]<>8),512&Q.flags&&(Je[0]=255&ue,Je[1]=ue>>>8&255,Q.check=i(Q.check,Je,2,0)),ge=ue=0,Q.mode=5;case 5:if(1024&Q.flags){for(;ge<16;){if(he===0)break e;he--,ue+=ce[re++]<>>8&255,Q.check=i(Q.check,Je,2,0)),ge=ue=0}else Q.head&&(Q.head.extra=null);Q.mode=6;case 6:if(1024&Q.flags&&(he<(Se=Q.length)&&(Se=he),Se&&(Q.head&&(pe=Q.head.extra_len-Q.length,Q.head.extra||(Q.head.extra=new Array(Q.head.extra_len)),o.arraySet(Q.head.extra,ce,re,Se,pe)),512&Q.flags&&(Q.check=i(Q.check,ce,Se,re)),he-=Se,re+=Se,Q.length-=Se),Q.length))break e;Q.length=0,Q.mode=7;case 7:if(2048&Q.flags){if(he===0)break e;for(Se=0;pe=ce[re+Se++],Q.head&&pe&&Q.length<65536&&(Q.head.name+=String.fromCharCode(pe)),pe&&Se>9&1,Q.head.done=!0),Y.adler=Q.check=0,Q.mode=12;break;case 10:for(;ge<32;){if(he===0)break e;he--,ue+=ce[re++]<>>=7&ge,ge-=7&ge,Q.mode=27;break}for(;ge<3;){if(he===0)break e;he--,ue+=ce[re++]<>>=1)){case 0:Q.mode=14;break;case 1:if(V(Q),Q.mode=20,J!==6)break;ue>>>=2,ge-=2;break e;case 2:Q.mode=17;break;case 3:Y.msg="invalid block type",Q.mode=30}ue>>>=2,ge-=2;break;case 14:for(ue>>>=7&ge,ge-=7≥ge<32;){if(he===0)break e;he--,ue+=ce[re++]<>>16^65535)){Y.msg="invalid stored block lengths",Q.mode=30;break}if(Q.length=65535&ue,ge=ue=0,Q.mode=15,J===6)break e;case 15:Q.mode=16;case 16:if(Se=Q.length){if(he>>=5,ge-=5,Q.ndist=1+(31&ue),ue>>>=5,ge-=5,Q.ncode=4+(15&ue),ue>>>=4,ge-=4,286>>=3,ge-=3}for(;Q.have<19;)Q.lens[Ge[Q.have++]]=0;if(Q.lencode=Q.lendyn,Q.lenbits=7,Xe={bits:Q.lenbits},Ue=u(0,Q.lens,0,19,Q.lencode,0,Q.work,Xe),Q.lenbits=Xe.bits,Ue){Y.msg="invalid code lengths set",Q.mode=30;break}Q.have=0,Q.mode=19;case 19:for(;Q.have>>16&255,Oe=65535&Ce,!((Me=Ce>>>24)<=ge);){if(he===0)break e;he--,ue+=ce[re++]<>>=Me,ge-=Me,Q.lens[Q.have++]=Oe;else{if(Oe===16){for(et=Me+2;ge>>=Me,ge-=Me,Q.have===0){Y.msg="invalid bit length repeat",Q.mode=30;break}pe=Q.lens[Q.have-1],Se=3+(3&ue),ue>>>=2,ge-=2}else if(Oe===17){for(et=Me+3;ge>>=Me)),ue>>>=3,ge-=3}else{for(et=Me+7;ge>>=Me)),ue>>>=7,ge-=7}if(Q.have+Se>Q.nlen+Q.ndist){Y.msg="invalid bit length repeat",Q.mode=30;break}for(;Se--;)Q.lens[Q.have++]=pe}}if(Q.mode===30)break;if(Q.lens[256]===0){Y.msg="invalid code -- missing end-of-block",Q.mode=30;break}if(Q.lenbits=9,Xe={bits:Q.lenbits},Ue=u(m,Q.lens,0,Q.nlen,Q.lencode,0,Q.work,Xe),Q.lenbits=Xe.bits,Ue){Y.msg="invalid literal/lengths set",Q.mode=30;break}if(Q.distbits=6,Q.distcode=Q.distdyn,Xe={bits:Q.distbits},Ue=u(f,Q.lens,Q.nlen,Q.ndist,Q.distcode,0,Q.work,Xe),Q.distbits=Xe.bits,Ue){Y.msg="invalid distances set",Q.mode=30;break}if(Q.mode=20,J===6)break e;case 20:Q.mode=21;case 21:if(6<=he&&258<=xe){Y.next_out=oe,Y.avail_out=xe,Y.next_in=re,Y.avail_in=he,Q.hold=ue,Q.bits=ge,c(Y,Be),oe=Y.next_out,ne=Y.output,xe=Y.avail_out,re=Y.next_in,ce=Y.input,he=Y.avail_in,ue=Q.hold,ge=Q.bits,Q.mode===12&&(Q.back=-1);break}for(Q.back=0;ke=(Ce=Q.lencode[ue&(1<>>16&255,Oe=65535&Ce,!((Me=Ce>>>24)<=ge);){if(he===0)break e;he--,ue+=ce[re++]<>qe)])>>>16&255,Oe=65535&Ce,!(qe+(Me=Ce>>>24)<=ge);){if(he===0)break e;he--,ue+=ce[re++]<>>=qe,ge-=qe,Q.back+=qe}if(ue>>>=Me,ge-=Me,Q.back+=Me,Q.length=Oe,ke===0){Q.mode=26;break}if(32&ke){Q.back=-1,Q.mode=12;break}if(64&ke){Y.msg="invalid literal/length code",Q.mode=30;break}Q.extra=15&ke,Q.mode=22;case 22:if(Q.extra){for(et=Q.extra;ge>>=Q.extra,ge-=Q.extra,Q.back+=Q.extra}Q.was=Q.length,Q.mode=23;case 23:for(;ke=(Ce=Q.distcode[ue&(1<>>16&255,Oe=65535&Ce,!((Me=Ce>>>24)<=ge);){if(he===0)break e;he--,ue+=ce[re++]<>qe)])>>>16&255,Oe=65535&Ce,!(qe+(Me=Ce>>>24)<=ge);){if(he===0)break e;he--,ue+=ce[re++]<>>=qe,ge-=qe,Q.back+=qe}if(ue>>>=Me,ge-=Me,Q.back+=Me,64&ke){Y.msg="invalid distance code",Q.mode=30;break}Q.offset=Oe,Q.extra=15&ke,Q.mode=24;case 24:if(Q.extra){for(et=Q.extra;ge>>=Q.extra,ge-=Q.extra,Q.back+=Q.extra}if(Q.offset>Q.dmax){Y.msg="invalid distance too far back",Q.mode=30;break}Q.mode=25;case 25:if(xe===0)break e;if(Se=Be-xe,Q.offset>Se){if((Se=Q.offset-Se)>Q.whave&&Q.sane){Y.msg="invalid distance too far back",Q.mode=30;break}Ee=Se>Q.wnext?(Se-=Q.wnext,Q.wsize-Se):Q.wnext-Se,Se>Q.length&&(Se=Q.length),Ae=Q.window}else Ae=ne,Ee=oe-Q.offset,Se=Q.length;for(xeq?(z=Ee[Ae+j[J]],ge[_e+j[J]]):(z=96,0),S=1<>oe)+(M-=S)]=$<<24|z<<16|V|0,M!==0;);for(S=1<>=1;if(S!==0?(ue&=S-1,ue+=S):ue=0,J++,--Be[Y]==0){if(Y===ce)break;Y=f[g+j[J]]}if(ne>>7)]}function _e(Ce,Je){Ce.pending_buf[Ce.pending++]=255&Je,Ce.pending_buf[Ce.pending++]=Je>>>8&255}function Be(Ce,Je,Ge){Ce.bi_valid>N-Ge?(Ce.bi_buf|=Je<>N-Ce.bi_valid,Ce.bi_valid+=Ge-N):(Ce.bi_buf|=Je<>>=1,Ge<<=1,0<--Je;);return Ge>>>1}function Ae(Ce,Je,Ge){var lt,He,We=new Array(j+1),tt=0;for(lt=1;lt<=j;lt++)We[lt]=tt=tt+Ge[lt-1]<<1;for(He=0;He<=Je;He++){var Ke=Ce[2*He+1];Ke!==0&&(Ce[2*He]=Ee(We[Ke]++,Ke))}}function Me(Ce){var Je;for(Je=0;Je>1;1<=Ge;Ge--)qe(Ce,We,Ge);for(He=rt;Ge=Ce.heap[1],Ce.heap[1]=Ce.heap[Ce.heap_len--],qe(Ce,We,1),lt=Ce.heap[1],Ce.heap[--Ce.heap_max]=Ge,Ce.heap[--Ce.heap_max]=lt,We[2*He]=We[2*Ge]+We[2*lt],Ce.depth[He]=(Ce.depth[Ge]>=Ce.depth[lt]?Ce.depth[Ge]:Ce.depth[lt])+1,We[2*Ge+1]=We[2*lt+1]=He,Ce.heap[1]=He++,qe(Ce,We,1),2<=Ce.heap_len;);Ce.heap[--Ce.heap_max]=Ce.heap[1],function(It,Vt){var hs,Es,Ts,cr,zr,Ft,Ps=Vt.dyn_tree,yr=Vt.max_code,Is=Vt.stat_desc.static_tree,Ar=Vt.stat_desc.has_stree,tn=Vt.stat_desc.extra_bits,na=Vt.stat_desc.extra_base,Ln=Vt.stat_desc.max_length,tr=0;for(cr=0;cr<=j;cr++)It.bl_count[cr]=0;for(Ps[2*It.heap[It.heap_max]+1]=0,hs=It.heap_max+1;hs>=7;He>>=1)if(1&it&&Ke.dyn_ltree[2*rt]!==0)return l;if(Ke.dyn_ltree[18]!==0||Ke.dyn_ltree[20]!==0||Ke.dyn_ltree[26]!==0)return i;for(rt=32;rt>>3,(We=Ce.static_len+3+7>>>3)<=He&&(He=We)):He=We=Ge+5,Ge+4<=He&&Je!==-1?et(Ce,Je,Ge,lt):Ce.strategy===4||We===He?(Be(Ce,2+(lt?1:0),3),ve(Ce,X,Y)):(Be(Ce,4+(lt?1:0),3),function(Ke,rt,it,It){var Vt;for(Be(Ke,rt-257,5),Be(Ke,it-1,5),Be(Ke,It-4,4),Vt=0;Vt>>8&255,Ce.pending_buf[Ce.d_buf+2*Ce.last_lit+1]=255&Je,Ce.pending_buf[Ce.l_buf+Ce.last_lit]=255&Ge,Ce.last_lit++,Je===0?Ce.dyn_ltree[2*Ge]++:(Ce.matches++,Je--,Ce.dyn_ltree[2*(Q[Ge]+f+1)]++,Ce.dyn_dtree[2*ge(Je)]++),Ce.last_lit===Ce.lit_bufsize-1},a._tr_align=function(Ce){Be(Ce,2,3),Se(Ce,M,X),function(Je){Je.bi_valid===16?(_e(Je,Je.bi_buf),Je.bi_buf=0,Je.bi_valid=0):8<=Je.bi_valid&&(Je.pending_buf[Je.pending++]=255&Je.bi_buf,Je.bi_buf>>=8,Je.bi_valid-=8)}(Ce)}},{"../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,m,f,g=1,y={},_=!1,w=l.document,j=Object.getPrototypeOf&&Object.getPrototypeOf(l);j=j&&j.setTimeout?j:l,c={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){S(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,P=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=P,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",M,!1):l.attachEvent("onmessage",M),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((m=new MessageChannel).port1.onmessage=function(I){S(I.data)},function(I){m.port2.postMessage(I)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(I){var P=w.createElement("script");P.onreadystatechange=function(){S(I),P.onreadystatechange=null,u.removeChild(P),P=null},u.appendChild(P)}):function(I){setTimeout(S,0,I)},j.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var P=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof Jv<"u"?Jv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(_tt);var JUt=_tt.exports;const eVt=Do(JUt);function Gge(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 tVt=()=>{const{isAdmin:t}=Fs(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState("all"),[i,c]=k.useState(new Set),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState("images"),[w,j]=k.useState(null),{data:N=[],isLoading:S}=pt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:he,error:xe}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(xe)throw xe;return he}}),{data:M=[]}=pt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:he,error:xe}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(xe)throw xe;return he}}),{data:I=[]}=pt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:he,error:xe}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(xe)throw xe;return he}}),{data:P=[]}=pt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:he,error:xe}=await H.from("social_accounts").select("id, platform").eq("is_active",!0);if(xe)throw xe;return he||[]}}),O=P.length>0,q=k.useMemo(()=>o==="all"?null:I.find(he=>he.month===o)||null,[o,I]),$=k.useMemo(()=>[...new Set(N.map(xe=>xe.month))].sort((xe,ue)=>ue.localeCompare(xe)),[N]);k.useEffect(()=>{$.length>0&&o==="all"&&l($[0])},[$,o]);const z=he=>{try{const xe=Lje(he,"yyyy-MM",new Date);return ds(xe,"MMMM yyyy")}catch{return he}},V=k.useMemo(()=>o==="all"?N:N.filter(he=>he.month===o),[o,N]),X=k.useMemo(()=>{var he;return o==="all"?null:((he=M.find(xe=>xe.month===o))==null?void 0:he.canva_link)||null},[o,M]),Y=async he=>{try{await navigator.clipboard.writeText(he),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},J=async(he,xe)=>{try{const ge=await(await fetch(he)).blob(),_e=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Be=navigator.canShare&&navigator.canShare({files:[new File([ge],"test.jpg",{type:"image/jpeg"})]});if(_e&&Be){const Se=new File([ge],`social-swag-${xe}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Se],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const Se=window.URL.createObjectURL(ge),Ee=document.createElement("a");Ee.href=Se,Ee.download=`social-swag-${xe}.jpg`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),window.URL.revokeObjectURL(Se),me.success("Image downloaded!")}}catch(ue){ue.name!=="AbortError"&&me.error("Failed to download image")}},Q=he=>{c(xe=>{const ue=new Set(xe);return ue.has(he)?ue.delete(he):ue.add(he),ue})},ce=()=>{c(new Set(V.map(he=>he.id)))},ne=()=>{c(new Set),m(!1)},re=async()=>{const he=V.filter(xe=>i.has(xe.id));if(he.length===0){me.error("No images selected");return}g(!0),me.info(`Preparing ${he.length} images for download...`);try{const xe=new eVt,ue=[...he].sort((Ee,Ae)=>Ee.sort_order-Ae.sort_order);for(let Ee=0;Ee{u?Q(he.id):r(he)};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(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(bl,{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(ga,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(fa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ss,{value:"gallery",className:"gap-2",children:[e.jsx(bl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ss,{value:"scheduled",className:"gap-2",children:[e.jsx(Fd,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(bs,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Pe,{className:"border rounded-xl",children:e.jsx(De,{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(G,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(la,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Pe,{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(De,{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(Au,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Pu,{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(G,{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(la,{to:"/social-connections",children:[e.jsx(pl,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(De,{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(mn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Au,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Pu,{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(Ye,{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:$.map(he=>e.jsx("button",{onClick:()=>l(he),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:z(he)},he))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",z(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 ",z(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"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",y==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(bl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",y==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(_u,{className:"h-4 w-4"}),"Reels"]})]}),y==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:ne,className:"gap-2",children:[e.jsx(Er,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(G,{size:"sm",onClick:re,disabled:f,className:"gap-2",children:[e.jsx(vi,{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(G,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&y==="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(he=>{const xe=i.has(he.id);return e.jsx(Pe,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Gge(he.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),he.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ds(new Date(he.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(ua,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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&&y==="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(Pe,{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:Gge(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(Ye,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(_u,{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(_u,{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:Gge(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(fn,{className:"h-4 w-4"}),ds(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(fn,{className:"h-3.5 w-3.5"}),"Post on ",ds(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(G,{onClick:()=>{j({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(Fn,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(G,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(G,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(vi,{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(_u,{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(G,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(G,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(QUt,{open:!!w,onOpenChange:he=>!he&&j(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx(bs,{value:"scheduled",children:e.jsx(XUt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(De,{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(mn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Au,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Pu,{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(Ye,{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:$.map(he=>e.jsx("button",{onClick:()=>l(he),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:z(he)},he))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",z(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 ",z(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"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",y==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(bl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",y==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(_u,{className:"h-4 w-4"}),"Reels"]})]}),y==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:ne,className:"gap-2",children:[e.jsx(Er,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(G,{size:"sm",onClick:re,disabled:f,className:"gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&y==="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(he=>{const xe=i.has(he.id);return e.jsx(Pe,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:he.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(ua,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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&&y==="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(Pe,{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(Ye,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(_u,{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(_u,{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(fn,{className:"h-4 w-4"}),ds(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(G,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(G,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(vi,{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(_u,{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(G,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(G,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},sVt=()=>{const{swagId:t}=ao(),{user:s}=Fs(),{toast:r}=Ra(),n=Qt(),{trackEngagement:a}=bE(),[o,l]=k.useState(""),{data:i,isLoading:c}=pt({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=[]}=pt({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:m=[]}=pt({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:I}=await H.from("profiles").select("id, name").in("id",M),P=new Map((I==null?void 0:I.map(O=>[O.id,O.name]))||[]);return N.map(O=>({...O,user_name:P.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Tt({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=Tt({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"})}}),y=Tt({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)),w=N=>N.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/social-swag",children:[e.jsx(Ga,{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(kE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(G,{variant:_?"default":"outline",className:"gap-2 w-fit",onClick:()=>y.mutate(),disabled:!s||y.isPending,children:[e.jsx(ah,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Uo,{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(G,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(Qo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Uc,{className:"h-5 w-5"}),"Comments (",m.length,")"]}),s?e.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(G,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(Fn,{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:m.length===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):m.map(N=>e.jsx(Pe,{children:e.jsx(De,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Cn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Mn,{className:"text-sm",children:w(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:ql(new Date(N.created_at),{addSuffix:!0})}),N.user_id===(s==null?void 0:s.id)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>g.mutate(N.id),children:e.jsx(kr,{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(Uo,{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(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/social-swag",children:"Back to Social Swag"})})]})})},rVt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,m]=k.useState(!0),f=g=>g.split(" ").map(y=>y[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(G,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(Y_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(bf,{open:o,onOpenChange:l,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{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(Ji,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(wf,{className:"space-y-1 pl-2",children:t.map(g=>e.jsxs(G,{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(bf,{open:i,onOpenChange:c,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{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(zd,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Ji,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(wf,{className:"space-y-1 pl-2",children:s.map(g=>e.jsxs(G,{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(bf,{open:u,onOpenChange:m,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{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(ur,{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(Ji,{className:"h-4 w-4"}):e.jsx(da,{className:"h-4 w-4"})]})}),e.jsx(wf,{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(Cn,{className:"h-7 w-7",children:[e.jsx(Wa,{src:g.avatarUrl}),e.jsx(Mn,{className:"text-xs",children:f(g.name)})]}),e.jsx(jd,{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))})]})]})})})},nVt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!1),i=u=>u.split(" ").map(m=>m[0]).join("").toUpperCase().slice(0,2),c=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const m=r.replace("group:",""),f=s.find(g=>g.id===m);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(m=>m.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(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(Ji,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Ud,{className:"w-56 bg-background border",children:[e.jsxs(La,{onClick:()=>n("all"),children:[e.jsx(Y_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(yw,{}),e.jsx(Bve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(La,{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(yw,{}),e.jsxs(Bve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zd,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(La,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(xE,{open:o,onOpenChange:l,children:[e.jsx(yNe,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(ur,{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(P3,{children:[e.jsx(gE,{children:e.jsxs(yE,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Li,{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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:u.avatarUrl}),e.jsx(Mn,{children:i(u.name)})]}),e.jsx(jd,{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 Wge,nhe="HoverCard",[wtt]=od(nhe,[V0]),ahe=V0(),[aVt,Zke]=wtt(nhe),jtt=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=ahe(s),u=k.useRef(0),m=k.useRef(0),f=k.useRef(!1),g=k.useRef(!1),[y,_]=lh({prop:n,defaultProp:a??!1,onChange:o,caller:nhe}),w=k.useCallback(()=>{clearTimeout(m.current),u.current=window.setTimeout(()=>_(!0),l)},[l,_]),j=k.useCallback(()=>{clearTimeout(u.current),!f.current&&!g.current&&(m.current=window.setTimeout(()=>_(!1),i))},[i,_]),N=k.useCallback(()=>_(!1),[_]);return k.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(m.current)},[]),e.jsx(aVt,{scope:s,open:y,onOpenChange:_,onOpen:w,onClose:j,onDismiss:N,hasSelectionRef:f,isPointerDownOnContentRef:g,children:e.jsx(FO,{...c,children:r})})};jtt.displayName=nhe;var Ntt="HoverCardTrigger",ktt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Zke(Ntt,r),o=ahe(r);return e.jsx(nE,{asChild:!0,...o,children:e.jsx(cn.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Or(t.onPointerEnter,Xle(a.onOpen)),onPointerLeave:Or(t.onPointerLeave,Xle(a.onClose)),onFocus:Or(t.onFocus,a.onOpen),onBlur:Or(t.onBlur,a.onClose),onTouchStart:Or(t.onTouchStart,l=>l.preventDefault())})})});ktt.displayName=Ntt;var iVt="HoverCardPortal",[lEs,oVt]=wtt(iVt,{forceMount:void 0}),Qle="HoverCardContent",Stt=k.forwardRef((t,s)=>{const r=oVt(Qle,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=Zke(Qle,t.__scopeHoverCard);return e.jsx(qd,{present:n||o.open,children:e.jsx(lVt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Or(t.onPointerEnter,Xle(o.onOpen)),onPointerLeave:Or(t.onPointerLeave,Xle(o.onClose)),ref:s})})});Stt.displayName=Qle;var lVt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=Zke(Qle,r),u=ahe(r),m=k.useRef(null),f=Ka(s,m),[g,y]=k.useState(!1);return k.useEffect(()=>{if(g){const _=document.body;return Wge=_.style.userSelect||_.style.webkitUserSelect,_.style.userSelect="none",_.style.webkitUserSelect="none",()=>{_.style.userSelect=Wge,_.style.webkitUserSelect=Wge}}},[g]),k.useEffect(()=>{if(m.current){const _=()=>{y(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var j;((j=document.getSelection())==null?void 0:j.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(()=>{m.current&&uVt(m.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(Ew,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Or(o,_=>{_.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(zO,{...u,...i,onPointerDown:Or(i.onPointerDown,_=>{_.currentTarget.contains(_.target)&&y(!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)"}})})}),cVt="HoverCardArrow",dVt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=ahe(r);return e.jsx(BO,{...a,...n,ref:s})});dVt.displayName=cVt;function Xle(t){return s=>s.pointerType==="touch"?void 0:t()}function uVt(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 hVt=jtt,mVt=ktt,Ctt=Stt;const pVt=hVt,fVt=mVt,Mtt=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Ctt,{ref:a,align:s,sideOffset:r,className:Pt("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));Mtt.displayName=Ctt.displayName;const xVt=[{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"}],gVt=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(pVt,{openDelay:200,closeDelay:100,children:[e.jsx(fVt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(Mtt,{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=xVt.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(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:l.user_avatar||void 0}),e.jsx(Mn,{className:"text-[10px]",children:gVt(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 yVt({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",m),()=>window.removeEventListener("keydown",m)),[m]);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(G,{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(Er,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(G,{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(tl,{className:"h-8 w-8"})}),e.jsx(G,{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(G,{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(oT,{className:"h-5 w-5"}):e.jsx(tw,{className:"h-5 w-5"})}),e.jsx("div",{className:Pt("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:g=>g.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:Pt("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((g,y)=>e.jsx("button",{onClick:()=>{o(y),i(!1)},className:Pt("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===y?"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"})},y))})]})})}const qz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],vVt=({commentId:t,reactions:s,currentUserId:r})=>{var u,m;const n=Qt(),[a,o]=k.useState(!1),l=s.find(f=>f.user_id===r),i=Tt({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=qz.find(y=>y.type===f))==null?void 0:g.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(Vo,{open:a,onOpenChange:o,children:[e.jsx(Ho,{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=qz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(m=qz.find(f=>f.type===l.reaction_type))==null?void 0:m.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ja,{className:"h-3 w-3"}),"Like"]})})}),e.jsx($o,{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:qz.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 Yke({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],m=i==="#";n.push(e.jsx(la,{to:m?`/templates/${u}`:`/profile?user=${u}`,className:Pt("font-medium hover:underline",m?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:m?c:`@${c}`},`mention-${l++}`))}else if(o[4]){const i=o[4],c=i.replace(/[.,;:!?)]+$/,""),u=i.slice(c.length);let m;try{const f=new URL(c);m=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{m=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:m},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(k.Fragment,{children:i},c))})}function Jle({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 m=k.useRef(null),f=k.useRef(null),[g,y]=k.useState(!1),[_,w]=k.useState("user"),[j,N]=k.useState(""),[S,M]=k.useState(null),[I,P]=k.useState(0),[O,q]=k.useState({top:0,left:0,width:0}),$=k.useRef(new Map),z=k.useRef(new Map),V=ge=>{if(c==="plain"){const Ee=[];return $.current.forEach((Me,ke)=>{ge.includes(`@${ke}`)&&Ee.push(Me)}),[...new Set(Ee)]}const _e=/@\[([^\]]+)\]\(([^)]+)\)/g,Be=[];let Se;for(;(Se=_e.exec(ge))!==null;)Be.push(Se[2]);return[...new Set(Be)]},X=ge=>{if(c==="plain"){const Ee=[];return z.current.forEach((Me,ke)=>{ge.includes(`#${ke}`)&&Ee.push(Me)}),[...new Set(Ee)]}const _e=/#\[([^\]]+)\]\(([^)]+)\)/g,Be=[];let Se;for(;(Se=_e.exec(ge))!==null;)Be.push(Se[2]);return[...new Set(Be)]};k.useEffect(()=>{if(o){const ge=V(t);o(ge)}if(l){const ge=X(t);l(ge)}},[t,o,l,c]);const{data:Y=[],isLoading:J}=pt({queryKey:["mention-users",j],queryFn:async()=>{const ge=H.from("profiles").select("id, name").limit(8),_e=j.length>=1?ge.ilike("name",`%${j}%`):ge.order("name"),{data:Be,error:Se}=await _e;if(Se)throw Se;const Ee=Be.map(Me=>Me.id),Ae=await mYe(Ee);return Be.map(Me=>({id:Me.id,name:Me.name||"Unknown",avatar_url:Ae.get(Me.id)}))},enabled:g&&_==="user",staleTime:3e4}),{data:Q=[],isLoading:ce}=pt({queryKey:["mention-templates",j],queryFn:async()=>{let ge=H.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);j.length>=1&&(ge=ge.ilike("name",`%${j}%`));const{data:_e,error:Be}=await ge;if(Be)throw Be;return _e||[]},enabled:g&&_==="template"&&u,staleTime:3e4}),ne=_==="user"?J:ce,re=_==="user"?Y:Q,oe=ge=>ge.split(" ").map(_e=>_e[0]).join("").toUpperCase().slice(0,2),he=ge=>{const _e=ge.target.value,Be=ge.target.selectionStart;s(_e);const Se=_e.substring(0,Be),Ee=Se.lastIndexOf("@"),Ae=u?Se.lastIndexOf("#"):-1;let Me=-1,ke="user";if(Ee>Ae?(Me=Ee,ke="user"):Ae>Ee&&u&&(Me=Ae,ke="template"),Me!==-1){const Oe=Se.substring(Me+1),qe=Oe.includes(" "),ve=Oe.includes(` `);if(!qe&&!ve&&Oe.length<=30){M(Me),N(Oe),w(ke),y(!0),P(0);return}}y(!1),M(null)},xe=ge=>{if(S===null)return;const _e=t.substring(0,S),Be=t.substring(S+j.length+1),Se=_==="user"?"@":"#",Ee=c==="plain"?`${Se}${ge.name} `:`${Se}[${ge.name}](${ge.id}) `;c==="plain"&&(_==="user"?$.current.set(ge.name,ge.id):z.current.set(ge.name,ge.id));const Ae=_e+Ee+Be;s(Ae),y(!1),M(null),N(""),setTimeout(()=>{if(m.current){const Me=_e.length+Ee.length;m.current.focus(),m.current.setSelectionRange(Me,Me)}},0)},ue=ge=>{if(!(!g||re.length===0))switch(ge.key){case"ArrowDown":ge.preventDefault(),P(_e=>(_e+1)%re.length);break;case"ArrowUp":ge.preventDefault(),P(_e=>(_e-1+re.length)%re.length);break;case"Enter":re[I]&&(ge.preventDefault(),xe(re[I]));break;case"Escape":ge.preventDefault(),y(!1);break;case"Tab":re[I]&&(ge.preventDefault(),xe(re[I]));break}};return k.useEffect(()=>{const ge=_e=>{f.current&&!f.current.contains(_e.target)&&m.current&&!m.current.contains(_e.target)&&y(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]),k.useEffect(()=>{if(!g)return;const ge=()=>{const _e=m.current;if(!_e)return;const Be=_e.getBoundingClientRect();q({top:Be.bottom+4,left:Be.left,width:Be.width})};return ge(),window.addEventListener("resize",ge),window.addEventListener("scroll",ge,!0),()=>{window.removeEventListener("resize",ge),window.removeEventListener("scroll",ge,!0)}},[g,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Tr,{ref:m,value:t,onChange:he,onKeyDown:ge=>{ue(ge),ge.defaultPrevented||i==null||i(ge)},placeholder:r,className:Pt("resize-none",n),style:{minHeight:a}}),g&&vp.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"}),ne?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):re.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:j.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:re.map((ge,_e)=>e.jsx("li",{className:Pt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",_e===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>xe(ge),onMouseEnter:()=>P(_e),children:_==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:ge.avatar_url}),e.jsx(Mn,{className:"text-xs",children:oe(ge.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:ge.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:ge.preview_image_url?e.jsx("img",{src:ge.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx($l,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:ge.name})]})},ge.id))})]}),document.body)]})}function bVt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const I8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function Att({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Qt(),[c,u]=k.useState(!1),[m,f]=k.useState(""),[g,y]=k.useState([]),_=Tt({mutationFn:async({content:S,parentCommentId:M})=>{const{data:I,error:P}=await H.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:M}).select("id").single();if(P)throw P;const O=g;if(O.length>0&&I){const q=O.filter($=>$!==r).map($=>({comment_id:I.id,mentioned_user_id:$,mentioned_by_user_id:r}));q.length>0&&await H.from("community_comment_mentions").insert(q)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),y([]),u(!1)}}),w=Tt({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"]})}),j=()=>{m.trim()&&_.mutate({content:m,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(Cn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Wa,{src:t.user_avatar||void 0}),e.jsx(Mn,{className:"text-xs",children:I8e(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(Yke,{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:ql(new Date(t.created_at),{addSuffix:!0})}),e.jsx(vVt,{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(qL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),c&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Cn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Wa,{src:n||void 0}),e.jsx(Mn,{className:"text-xs",children:I8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Jle,{placeholder:`Reply to ${t.user_name}...`,value:m,onChange:f,onMentionsChange:y,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(G,{size:"sm",variant:"ghost",onClick:j,disabled:!m.trim()||_.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Fn,{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(Att,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const Uz=[{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"}],_Vt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Fs(),{avatarUrl:a}=hYe(t==null?void 0:t.id),{onlineUsers:o}=pQe(),{toast:l}=Ra(),i=Qt(),c=k.useRef(null),[u,m]=k.useState("all"),[f,g]=k.useState(""),[y,_]=k.useState(""),[w,j]=k.useState(""),[N,S]=k.useState([]),[M,I]=k.useState([]),[P,O]=k.useState(""),[q,$]=k.useState(!1),[z,V]=k.useState(null),[X,Y]=k.useState(""),[J,Q]=k.useState(new Set),[ce,ne]=k.useState({}),[re,oe]=k.useState({}),[he,xe]=k.useState([]),[ue,ge]=k.useState([]),[_e,Be]=k.useState({open:!1,images:[],index:0});k.useEffect(()=>{if(u.startsWith("group:")){const it=u.replace("group:","");j(it),_("")}else u!=="all"?(_(u),j("")):(_(""),j(""))},[u]);const{data:Se=[]}=pt({queryKey:["community-categories"],queryFn:async()=>{const{data:it,error:It}=await H.from("community_categories").select("*").order("sort_order");if(It)throw It;return it}}),{data:Ee=[]}=pt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:it,error:It}=await H.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(It)throw It;return it}}),Ae=20,{data:Me,isLoading:ke,hasNextPage:Oe,fetchNextPage:qe,isFetchingNextPage:ve}=W2e({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:it})=>{var $e;const It=it*Ae,Vt=It+Ae;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(It,Vt);if(u.startsWith("group:")){const st=u.replace("group:","");hs=hs.eq("private_group_id",st)}else u==="all"||(hs=hs.eq("category_id",u).is("private_group_id",null));const{data:Es,error:Ts}=await hs;if(Ts)throw Ts;const cr=((Es==null?void 0:Es.length)||0)>Ae,zr=(Es||[]).slice(0,Ae);if(zr.length===0)return{posts:[],hasMore:!1,nextPage:it+1};const Ft=zr.map(st=>st.id),Ps=[...new Set(zr.filter(st=>st.category_id).map(st=>st.category_id))].filter(Boolean),[yr,Is,Ar,tn,na]=await Promise.all([Ps.length?H.from("community_categories").select("*").in("id",Ps):Promise.resolve({data:[]}),H.from("community_post_media").select("*").in("post_id",Ft).order("sort_order"),H.from("community_reactions").select("*").in("post_id",Ft),H.from("community_comments").select("*").in("post_id",Ft).order("created_at",{ascending:!0}),H.from("community_post_resources").select("*").in("post_id",Ft)]),Ln=yr==null?void 0:yr.data,tr=Is==null?void 0:Is.data,dr=Ar==null?void 0:Ar.data,Sr=tn==null?void 0:tn.data,dn=na==null?void 0:na.data,Yr=(Sr||[]).map(st=>st.id),[ui,ns]=await Promise.all([Yr.length?H.from("community_comment_reactions").select("*").in("comment_id",Yr):Promise.resolve({data:[]}),(()=>{const st=(dn||[]).filter(vt=>vt.resource_type==="template").map(vt=>vt.resource_id);return st.length===0?Promise.resolve({data:[]}):H.from("canva_templates").select("id, name, preview_image_url").in("id",st)})()]),Wt=(ui==null?void 0:ui.data)||[],Hr=(ns==null?void 0:ns.data)||[],Mr=new Map(Hr.map(st=>[st.id,{name:st.name,preview_image_url:st.preview_image_url}])),xr=Array.from(new Set([...zr.map(st=>st.user_id),...(dr||[]).map(st=>st.user_id),...(Sr||[]).map(st=>st.user_id),...Wt.map(st=>st.user_id)])),[Wn,ai]=await Promise.all([xr.length?H.from("profiles").select("id, name").in("id",xr):Promise.resolve({data:[]}),mYe(xr)]),Aa=new Map((($e=Wn==null?void 0:Wn.data)==null?void 0:$e.map(st=>[st.id,st.name]))||[]),no=new Map((Ln||[]).map(st=>[st.id,st])),$t=st=>{const vt=new Map,xt=[];return st.forEach(Ot=>{vt.set(Ot.id,{...Ot,user_name:Aa.get(Ot.user_id)||"Unknown User",user_avatar:ai.get(Ot.user_id),reactions:Wt.filter(Zt=>Zt.comment_id===Ot.id).map(Zt=>({...Zt,user_name:Aa.get(Zt.user_id)||"Unknown User",user_avatar:ai.get(Zt.user_id)})),replies:[]})}),st.forEach(Ot=>{const Zt=vt.get(Ot.id);if(Ot.parent_comment_id&&vt.has(Ot.parent_comment_id)){const qt=vt.get(Ot.parent_comment_id);qt.replies=qt.replies||[],qt.replies.push(Zt)}else xt.push(Zt)}),xt};return{posts:zr.map(st=>{const vt=(dn||[]).filter(xt=>xt.post_id===st.id).map(xt=>{let Ot="",Zt=null;if(xt.resource_type==="template"){const qt=Mr.get(xt.resource_id);Ot=(qt==null?void 0:qt.name)||"Unknown Template",Zt=(qt==null?void 0:qt.preview_image_url)||null}return{id:xt.id,resource_type:xt.resource_type,resource_id:xt.resource_id,resource_name:Ot,resource_preview_url:Zt}});return{...st,user_name:Aa.get(st.user_id)||"Unknown User",user_avatar:ai.get(st.user_id),category:st.category_id?no.get(st.category_id):null,media:(tr||[]).filter(xt=>xt.post_id===st.id),reactions:((dr||[]).filter(xt=>xt.post_id===st.id)||[]).map(xt=>({...xt,user_name:Aa.get(xt.user_id)||"Unknown User",user_avatar:ai.get(xt.user_id)})),comments:$t((Sr||[]).filter(xt=>xt.post_id===st.id)),resources:vt}}),hasMore:cr,nextPage:it+1}},getNextPageParam:it=>it.hasMore?it.nextPage:void 0}),dt=k.useMemo(()=>(Me==null?void 0:Me.pages.flatMap(it=>it.posts))??[],[Me]),pe=Tt({mutationFn:async()=>{$(!0);const{data:it,error:It}=await H.from("community_posts").insert({user_id:t.id,category_id:w?null:y||null,private_group_id:w||null,content:f,link_url:P||null}).select().single();if(It)throw It;for(let hs=0;hs0){const hs=he.filter(Es=>Es!==t.id).map(Es=>({post_id:it.id,mentioned_user_id:Es,mentioned_by_user_id:t.id}));hs.length>0&&await H.from("community_post_mentions").insert(hs)}const Vt=bVt(f);if(Vt.length>0){const hs=Vt.map(Es=>({post_id:it.id,resource_type:"template",resource_id:Es}));await H.from("community_post_resources").insert(hs)}return it},onSuccess:async it=>{var It;i.invalidateQueries({queryKey:["community-posts"]}),g(""),xe([]),ge([]),_(""),j(""),S([]),I([]),O(""),l({title:"Post created!"});try{const Vt=((It=t==null?void 0:t.user_metadata)==null?void 0:It.name)||"Someone",hs=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Es=hs.length>50?hs.substring(0,50)+"...":hs;await H.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Vt}: ${Es}`,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:()=>$(!1)}),Ue=Tt({mutationFn:async({postId:it,content:It})=>{const{error:Vt}=await H.from("community_posts").update({content:It}).eq("id",it);if(Vt)throw Vt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),Y(""),l({title:"Post updated!"})}}),Xe=Tt({mutationFn:async it=>{const{error:It}=await H.from("community_posts").delete().eq("id",it);if(It)throw It},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),et=Tt({mutationFn:async({postId:it,isPinned:It})=>{const{error:Vt}=await H.from("community_posts").update({is_pinned:!It,pinned_at:It?null:new Date().toISOString(),pinned_by:It?null:t==null?void 0:t.id}).eq("id",it);if(Vt)throw Vt},onSuccess:(it,{isPinned:It})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:It?"Post unpinned":"Post pinned to top"})}}),Ce=Tt({mutationFn:async({postId:it,reactionType:It})=>{var hs;const Vt=(hs=dt.find(Es=>Es.id===it))==null?void 0:hs.reactions.find(Es=>Es.user_id===(t==null?void 0:t.id));Vt?Vt.reaction_type===It?await H.from("community_reactions").delete().eq("id",Vt.id):await H.from("community_reactions").update({reaction_type:It}).eq("id",Vt.id):await H.from("community_reactions").insert({post_id:it,user_id:t.id,reaction_type:It})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),Je=Tt({mutationFn:async({postId:it,content:It})=>{const{data:Vt,error:hs}=await H.from("community_comments").insert({post_id:it,user_id:t.id,content:It}).select("id").single();if(hs)throw hs;const Es=re[it]||[];if(Es.length>0&&Vt){const Ts=Es.filter(cr=>cr!==t.id).map(cr=>({comment_id:Vt.id,mentioned_user_id:cr,mentioned_by_user_id:t.id}));Ts.length>0&&await H.from("community_comment_mentions").insert(Ts)}},onSuccess:(it,{postId:It})=>{i.invalidateQueries({queryKey:["community-posts"]}),ne(Vt=>({...Vt,[It]:""})),oe(Vt=>({...Vt,[It]:[]}))}});Tt({mutationFn:async it=>{const{error:It}=await H.from("community_comments").delete().eq("id",it);if(It)throw It},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Ge=it=>{const It=Array.from(it.target.files||[]);if(It.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Vt=>[...Vt,...It]),It.forEach(Vt=>{const hs=new FileReader;hs.onloadend=()=>{I(Es=>[...Es,hs.result])},hs.readAsDataURL(Vt)})},lt=it=>{S(It=>It.filter((Vt,hs)=>hs!==it)),I(It=>It.filter((Vt,hs)=>hs!==it))},He=it=>it.split(" ").map(It=>It[0]).join("").toUpperCase().slice(0,2),We=it=>{const It={};return it.forEach(Vt=>{It[Vt.reaction_type]=(It[Vt.reaction_type]||0)+1}),It},tt=it=>{var It;return(It=it.find(Vt=>Vt.user_id===(t==null?void 0:t.id)))==null?void 0:It.reaction_type},Ke=it=>it.reduce((It,Vt)=>It+1+(Vt.replies?Ke(Vt.replies):0),0),rt=it=>{if(n)return!0;if(!s||!it.private_group_id)return!1;const It=Ee.find(Vt=>Vt.id===it.private_group_id);return It!=null&&It.brokerage_id?r.some(Vt=>Vt.id===It.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(rVt,{categories:Se,privateGroups:Ee,selectedFilter:u,onFilterChange:m,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(nVt,{categories:Se,privateGroups:Ee,selectedFilter:u,onFilterChange:m,onlineUsers:o}),e.jsx(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:a||void 0}),e.jsx(Mn,{children:t!=null&&t.email?He(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Jle,{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:xe,onTemplatesChange:ge,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),M.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.map((it,It)=>{var Vt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Vt=N[It])!=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(G,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>lt(It),children:e.jsx(Er,{className:"h-3 w-3"})})]},It)})}),P&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:P,onChange:it=>O(it.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(Er,{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:Ge,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(bl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(G,{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(G,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(Uo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Ee.length>0?e.jsxs(Rs,{value:w||y||"none",onValueChange:it=>{it==="none"?(_(""),j("")):it.startsWith("group:")?(j(it.replace("group:","")),_("")):(_(it),j(""))},children:[e.jsx(Ls,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx($s,{placeholder:"Select..."})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No category"}),Se.map(it=>e.jsxs(ft,{value:it.id,children:[it.icon," ",it.name]},it.id)),Ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Ee.map(it=>e.jsxs(ft,{value:`group:${it.id}`,children:[it.icon||"🔒"," ",it.name]},it.id))]})]})]}):e.jsxs(Rs,{value:y,onValueChange:_,children:[e.jsx(Ls,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx($s,{placeholder:"Category"})}),e.jsx(Ds,{children:Se.map(it=>e.jsxs(ft,{value:it.id,children:[it.icon," ",it.name]},it.id))})]}),e.jsxs(G,{size:"sm",onClick:()=>pe.mutate(),disabled:!f.trim()||q,children:[e.jsx(Fn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),ke?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((it,It)=>e.jsx(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ws,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ws,{className:"h-4 w-32"}),e.jsx(ws,{className:"h-4 w-full"}),e.jsx(ws,{className:"h-4 w-3/4"})]})]})})},It))}):dt.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(Uc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[dt.map(it=>{var It,Vt,hs,Es;return e.jsx(Pe,{children:e.jsxs(De,{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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:it.user_avatar||void 0}),e.jsx(Mn,{children:He(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:ql(new Date(it.created_at),{addSuffix:!0})}),it.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[it.category.icon," ",it.category.name]})]})]})]})]}),(it.user_id===(t==null?void 0:t.id)||rt(it))&&e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(bx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",children:[rt(it)&&it.private_group_id&&e.jsx(La,{onClick:()=>et.mutate({postId:it.id,isPinned:it.is_pinned}),children:it.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(RL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(J_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),it.user_id===(t==null?void 0:t.id)&&e.jsxs(La,{onClick:()=>{V(it),Y(it.content)},children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(La,{className:"text-destructive",onClick:()=>Xe.mutate(it.id),children:[e.jsx(kr,{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(J_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(Yke,{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((Ts,cr)=>{const zr=cr===3&&it.media.length>4,Ft=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:()=>Be({open:!0,images:it.media.map(Ps=>({url:Ps.media_url,type:Ps.media_type==="video"?"video":"image"})),index:cr}),children:[Ts.media_type==="video"?e.jsx("video",{src:Ts.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Ts.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"})})})}),zr&&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:["+",Ft]})})]},Ts.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:Ts=>{Ts.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(Uo,{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(We(it.reactions)).slice(0,3).map(([Ts])=>{var cr;return e.jsx("span",{className:"text-base",children:(cr=Uz.find(zr=>zr.type===Ts))==null?void 0:cr.emoji},Ts)})}),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(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"flex-1",children:[tt(it.reactions)?e.jsx("span",{className:"mr-1",children:(It=Uz.find(Ts=>Ts.type===tt(it.reactions)))==null?void 0:It.emoji}):e.jsx(ah,{className:"h-4 w-4 mr-1"}),tt(it.reactions)?(Vt=Uz.find(Ts=>Ts.type===tt(it.reactions)))==null?void 0:Vt.label:"Like"]})}),e.jsx($o,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Uz.map(Ts=>e.jsx("button",{onClick:()=>Ce.mutate({postId:it.id,reactionType:Ts.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Ts.label,children:Ts.emoji},Ts.type))})})]}),e.jsxs(G,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Q(Ts=>{const cr=new Set(Ts);return cr.has(it.id)?cr.delete(it.id):cr.add(it.id),cr}),children:[e.jsx(Uc,{className:"h-4 w-4 mr-1"}),(()=>{const Ts=Ke(it.comments);return Ts>0?`Comment (${Ts})`:"Comment"})()]})]}),J.has(it.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[it.comments.map(Ts=>e.jsx(Att,{comment:Ts,postId:it.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:rt(it)},Ts.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:a||void 0}),e.jsx(Mn,{className:"text-xs",children:He(((hs=t.email)==null?void 0:hs.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Jle,{placeholder:"Write a comment... (use @ to mention)",value:ce[it.id]||"",onChange:Ts=>ne(cr=>({...cr,[it.id]:Ts})),onMentionsChange:Ts=>oe(cr=>({...cr,[it.id]:Ts})),mentionFormat:"plain",onKeyDown:Ts=>{var cr;Ts.defaultPrevented||Ts.key==="Enter"&&!Ts.shiftKey&&((cr=ce[it.id])!=null&&cr.trim())&&(Ts.preventDefault(),Je.mutate({postId:it.id,content:ce[it.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{var Ts;(Ts=ce[it.id])!=null&&Ts.trim()&&Je.mutate({postId:it.id,content:ce[it.id]})},disabled:!((Es=ce[it.id])!=null&&Es.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Fn,{className:"h-4 w-4"})})]})]})]})]})},it.id)}),Oe&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(G,{variant:"outline",onClick:()=>qe(),disabled:ve,children:ve?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!z,onOpenChange:()=>V(null),children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Edit Post"})}),e.jsx(Tr,{value:X,onChange:it=>Y(it.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(G,{onClick:()=>{z&&Ue.mutate({postId:z.id,content:X})},disabled:!X.trim(),children:"Save Changes"})]})]})}),e.jsx(yVt,{images:_e.images,initialIndex:_e.index,open:_e.open,onOpenChange:it=>Be(It=>({...It,open:it}))})]})]})})},q5={open:{label:"Open",icon:mn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Uc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:wi,color:"bg-green-500"},closed:{label:"Closed",icon:Nc,color:"bg-muted-foreground"}},L8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function wVt(){const{user:t}=Fs(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),{data:l=[],isLoading:i}=pt({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=[]}=pt({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=Tt({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")}}),m=()=>{a.trim()&&u.mutate(a)};if(r){const f=q5[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(G,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ga,{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(Ye,{variant:"secondary",children:L8e[r.category]}),e.jsxs(Ye,{className:q5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),q5[r.status].label]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(vr,{children:["Created on ",ds(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Conversation"})}),e.jsxs(De,{children:[e.jsx(Li,{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 y;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":((y=g.profiles)==null?void 0:y.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ds(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(Qo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Type your reply...",value:a,onChange:g=>o(g.target.value),className:"min-h-[80px]"}),e.jsx(G,{onClick:m,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Fn,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(De,{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(Uv,{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(T1e,{trigger:e.jsxs(G,{size:"lg",className:"gap-2",children:[e.jsx(qs,{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(Nn,{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(T1e,{trigger:e.jsxs(G,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(qs,{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(Pe,{className:"border-dashed",children:e.jsxs(De,{className:"text-center py-12",children:[e.jsx(Uc,{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=q5[f.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(De,{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(Ye,{variant:"outline",className:"text-xs",children:L8e[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ds(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(Ye,{className:q5[f.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),q5[f.status].label]})]})})},f.id)})})]})})}function jVt({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(js,{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(fn,{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 NVt({open:t,onOpenChange:s}){const{brokerageId:r}=Fs(),[n,a]=k.useState(""),[o,l]=k.useState([]),[i,c]=k.useState(!1),{data:u,isLoading:m}=pt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(j)throw j;return w},enabled:t&&!!r}),f=u==null?void 0:u.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),g=w=>{l(j=>j.includes(w)?j.filter(N=>N!==w):[...j,w])},y=async()=>{if(o.length===0){me.error("Please select at least one agent");return}c(!0);try{const{data:w,error:j}=await H.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(j)throw j;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),me.error(w.message||"Failed to send onboarding link")}finally{c(!1)}},_=w=>{w||(l([]),a("")),s(w)};return e.jsx(fs,{open:t,onOpenChange:_,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{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(Fn,{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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ys,{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(ur,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Li,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>g(w.id),children:[e.jsx(Mo,{checked:o.includes(w.id),onCheckedChange:()=>g(w.id)}),e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{className:"text-xs",children:w.name.split(" ").map(j=>j[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(G,{onClick:y,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function kVt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Et,{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(ur,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{children:"Agent Onboarding"}),e.jsx(vr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(G,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(G,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Fn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(jVt,{open:t,onOpenChange:s}),e.jsx(NVt,{open:r,onOpenChange:n})]})}function SVt({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(js,{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(_0,{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 CVt(){const[t,s]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Et,{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(_0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{children:"Launch or ReLaunch Meeting"}),e.jsx(vr,{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(De,{children:e.jsxs(G,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(_0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(SVt,{open:t,onOpenChange:s})]})}function MVt(){const t=ar(),[s,r]=k.useState(""),[n,a]=k.useState(null),{data:o,isLoading:l}=pt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return w}}),{data:i}=pt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(j)throw j;return w}}),{data:c}=pt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_pdfs").select("resource_id");if(j)throw j;return w}}),{data:u}=pt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_videos").select("resource_id");if(j)throw j;return w}}),{data:m}=pt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_links").select("resource_id");if(j)throw j;return w}}),f=o==null?void 0:o.filter(w=>{var S;const j=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),N=!n||w.category_id===n;return j&&N}),g=i==null?void 0:i.filter(w=>o==null?void 0:o.some(j=>j.category_id===w.id)),y=w=>{const j=(c==null?void 0:c.filter(M=>M.resource_id===w).length)||0,N=(u==null?void 0:u.filter(M=>M.resource_id===w).length)||0,S=(m==null?void 0:m.filter(M=>M.resource_id===w).length)||0;return{pdfCount:j,videoCount:N,linkCount:S}},_=w=>{t(`/brokerage-resources/${w}`)};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(kVt,{}),e.jsx(CVt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),g&&g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ye,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),g.map(w=>e.jsx(Ye,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,j)=>e.jsxs(Pe,{children:[e.jsx(ws,{className:"h-40 w-full"}),e.jsx(Et,{children:e.jsx(ws,{className:"h-5 w-3/4"})}),e.jsxs(De,{children:[e.jsx(ws,{className:"h-4 w-full mb-2"}),e.jsx(ws,{className:"h-4 w-2/3"})]})]},j))}):(f==null?void 0:f.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(sh,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(w=>{const{pdfCount:j,videoCount:N,linkCount:S}=y(w.id),M=i==null?void 0:i.find(I=>I.id===w.category_id);return e.jsxs(Pe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>_(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(sh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Lt,{className:"text-lg line-clamp-1",children:w.title}),M&&e.jsx(Ye,{variant:"secondary",className:"shrink-0 text-xs",children:M.name})]})}),e.jsxs(De,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[j>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),j]}),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(Uo,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const TVt=()=>{const{resourceId:t}=ao(),{data:s,isLoading:r}=pt({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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/brokerage-resources",children:[e.jsx(Ga,{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(Pe,{children:e.jsxs(De,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"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(wn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(rn,{className:"h-4 w-4"}),"Canva Templates (",s.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.links.map(a=>e.jsxs("a",{href:a.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(rn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ms,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(sh,{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(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function AVt(){const{onlineUsers:t,totalOnline:s}=pQe();return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(Ye,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(jd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(De,{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(Li,{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(Cn,{className:"h-9 w-9",children:[e.jsx(Wa,{src:r.avatarUrl,alt:r.name}),e.jsx(Mn,{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 ",ql(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const D8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:ur,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:QL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Px,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:bL,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:Lh,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:nd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:ur,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Xh,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:El,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:$l,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Qh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:ry,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:nn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:nn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:x1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Fd,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:sh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:sh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:rr,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:Ph,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:hS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:dx,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:rr,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:Ph,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:UM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:j0,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:bo,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:_o,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:pl,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:ur,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:Ph,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:Ki,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:QM,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:ea,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:rr,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:co,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:Ah,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:Qh,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:Ja,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:xn,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:sy,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:Ah,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:bl,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:rr,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:Z_,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:Nd,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:_L,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:Bo,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"},{title:"Website Interests",description:"Track interest form submissions from TheLocalMove.com",icon:wn,path:"/admin/website-interests",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Website Order Tracker",description:"Full setup requests with all build details from /get-started",icon:wn,path:"/admin/website-orders",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"MLS Fee Tracker",description:"Track MLS providers, setup fees, and monthly costs",icon:ml,path:"/admin/mls-fee-tracker",color:"bg-gradient-to-br from-teal-500/20 to-cyan-500/10 text-teal-600"}]}};function O8e(){const t=ar();return console.log("[AdminDashboard] render"),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(AVt,{})})]}),e.jsxs(ga,{defaultValue:"users",className:"w-full",children:[e.jsx(fa,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(D8e).map(([s,r])=>e.jsx(ss,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(D8e).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(Pe,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Et,{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(Lt,{className:"text-base",children:n.title})]}),e.jsx(De,{className:"pt-0",children:e.jsx(vr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Bn=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Pt("w-full caption-bottom text-sm",t),...s})}));Bn.displayName="Table";const $n=k.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Pt("[&_tr]:border-b",t),...s}));$n.displayName="TableHeader";const qn=k.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Pt("[&_tr:last-child]:border-0",t),...s}));qn.displayName="TableBody";const EVt=k.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Pt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));EVt.displayName="TableFooter";const ks=k.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Pt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));ks.displayName="TableRow";const jt=k.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Pt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));jt.displayName="TableHead";const ut=k.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Pt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));ut.displayName="TableCell";const PVt=k.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Pt("mt-4 text-sm text-muted-foreground",t),...s}));PVt.displayName="TableCaption";const IVt=()=>{const{isAdmin:t}=Fs(),s=ar(),[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}m()},[t]);const m=async()=>{try{const{data:w,error:j}=await H.from("app_tiles").select("*").order("name");if(j)throw j;n(w||[])}catch(w){console.error("Error loading apps:",w),me.error("Failed to load apps")}finally{o(!1)}},f=async w=>{w.preventDefault();const j=new FormData(w.currentTarget),N={name:j.get("name"),description:j.get("description"),icon:j.get("icon"),app_id:j.get("app_id"),target_url:j.get("target_url"),required_tags:j.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(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),m()}catch(S){console.error("Error saving app:",S),me.error("Failed to save app")}},g=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:j}=await H.from("app_tiles").delete().eq("id",w);if(j)throw j;me.success("App deleted successfully"),m()}catch(j){console.error("Error deleting app:",j),me.error("Failed to delete app")}},y=w=>{u(w),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(G,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Ga,{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(Oi,{asChild:!0,children:e.jsxs(G,{onClick:_,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(js,{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(ye,{htmlFor:"name",children:"App Name"}),e.jsx(Le,{id:"name",name:"name",defaultValue:c==null?void 0:c.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"app_id",children:"App ID"}),e.jsx(Le,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{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(ye,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Le,{id:"icon",name:"icon",defaultValue:c==null?void 0:c.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Le,{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(ye,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Le,{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(G,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(G,{type:"submit",children:c?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Application Tiles"}),e.jsx(vr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(De,{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(G,{onClick:_,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"App ID"}),e.jsx(jt,{children:"Target URL"}),e.jsx(jt,{children:"Tags"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:r.map(w=>e.jsxs(ks,{children:[e.jsx(ut,{className:"text-2xl",children:w.icon}),e.jsx(ut,{className:"font-medium",children:w.name}),e.jsx(ut,{className:"font-mono text-sm",children:w.app_id}),e.jsx(ut,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(ut,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(j=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:j},j))})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>y(w),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>g(w.id),children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function dh({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(la,{to:"/admin",children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Ga,{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 R8e=({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(Ye,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(vd,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(Ye,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(Ye,{className:Pt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(Ye,{variant:"secondary",className:Pt("gap-1",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},Ett=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ra(),l=k.useRef(null),[i,c]=k.useState([]),[u,m]=k.useState(""),[f,g]=k.useState(!1),[y,_]=k.useState("upload"),[w,j]=k.useState(null),N=()=>{c([]),m(""),_("upload"),j(null),l.current&&(l.current.value="")},S=()=>{N(),s(!1)},M=$=>{const z=$.split(` `).map(Q=>Q.trim()).filter(Q=>Q);if(z.length===0)return[];const V=z[0].toLowerCase(),Y=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?z.slice(1):z,J=[];for(const Q of Y){const ne=(Q.includes(" ")?Q.split(" "):Q.split(",")).map(re=>re.trim().replace(/^["']|["']$/g,""));if(ne.length>=2){let re="",oe="",he="",xe="",ue;if(ne.length===2){const Be=ne[0].split(" ");re=Be[0]||"",oe=Be.slice(1).join(" ")||"",he=ne[1]}else if(ne.length===3)re=ne[0],oe=ne[1],he=ne[2];else if(ne.length===4)re=ne[0],oe=ne[1],he=ne[2],xe=ne[3];else if(ne.length>=5){re=ne[0],oe=ne[1],he=ne[2],xe=ne[3];const Be=ne[4].toLowerCase();ue=Be==="true"||Be==="yes"||Be==="1"||Be==="y"}const _e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(he);J.push({firstName:re.trim(),lastName:oe.trim(),email:he.trim().toLowerCase(),phone:xe.trim()||void 0,smsConsent:ue,isValid:_e&&re.trim().length>0,error:_e?re.trim()?void 0:"Missing name":"Invalid email"})}}return J},I=$=>{var X;const z=(X=$.target.files)==null?void 0:X[0];if(!z)return;const V=new FileReader;V.onload=Y=>{var ce;const J=(ce=Y.target)==null?void 0:ce.result,Q=M(J);if(Q.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}c(Q),_("preview")},V.readAsText(z)},P=async()=>{const $=i.filter(V=>V.isValid);if($.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const z=n||u||null;g(!0);try{const{data:{session:V}}=await H.auth.getSession(),X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:$.map(J=>({firstName:J.firstName,lastName:J.lastName,email:J.email,phone:J.phone,smsConsent:J.smsConsent})),brokerageId:z})}),Y=await X.json();if(!X.ok)throw new Error(Y.error||"Failed to import users");j(Y),_("result"),Y.created>0&&a(),o({title:"Import Complete",description:`${Y.created} user(s) created successfully.${Y.failed>0?` ${Y.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($=>$.isValid).length,q=i.filter($=>!$.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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(h1,{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."})]}),y==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:I,className:"hidden"}),e.jsx(ci,{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(G,{onClick:()=>{var $;return($=l.current)==null?void 0:$.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."})]})]}),y==="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(ye,{children:"Assign to Brokerage (optional)"}),e.jsxs(Rs,{value:u||"none",onValueChange:$=>m($==="none"?"":$),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a brokerage..."})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No brokerage"}),r.map($=>e.jsx(ft,{value:$.id,children:$.name},$.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(ul,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"SMS"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(qn,{children:i.slice(0,100).map(($,z)=>e.jsxs(ks,{children:[e.jsx(ut,{children:$.firstName}),e.jsx(ut,{children:$.lastName}),e.jsx(ut,{children:$.email}),e.jsx(ut,{className:"text-muted-foreground",children:$.phone||"-"}),e.jsx(ut,{className:"text-muted-foreground",children:$.smsConsent===!0?"✓":$.smsConsent===!1?"✗":"-"}),e.jsx(ut,{children:$.isValid?e.jsx(Ye,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(Ye,{variant:"destructive",children:$.error||"Invalid"})})]},z))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),y==="result"&&w&&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:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map(($,z)=>e.jsxs("li",{children:["• ",$]},z)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(Rn,{children:[y==="upload"&&e.jsx(G,{variant:"outline",onClick:S,children:"Cancel"}),y==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"outline",onClick:N,children:"Back"}),e.jsx(G,{onClick:P,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),y==="result"&&e.jsx(G,{onClick:S,children:"Done"})]})]})})};function _l({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(jt,{className:Pt("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(Tu,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Yh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(wd,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function mR(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 m=u[r];return[...c].sort((f,g)=>{const y=m(f),_=m(g);if(y==null&&_==null)return 0;if(y==null)return 1;if(_==null)return-1;let w;return typeof y=="string"&&typeof _=="string"?w=y.localeCompare(_,void 0,{sensitivity:"base"}):w=y-_,a==="asc"?w:-w})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const LVt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:ea},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:_o},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:iu}];function Ptt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=k.useState("custom"),[l,i]=k.useState(""),[c,u]=k.useState(""),m=VNt(),f=y=>{o(y.type),i(y.title),u(y.message)},g=async y=>{if(y.preventDefault(),!l.trim()){kn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await m.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:c.trim()||void 0}),kn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{kn({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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(iu,{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(ye,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:LVt.map((y,_)=>e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>f(y),className:"text-xs",children:[e.jsx(y.icon,{className:"h-3 w-3 mr-1"}),y.title]},_))})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Rs,{value:a,onValueChange:y=>o(y),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ea,{className:"h-4 w-4"})," Custom"]})}),e.jsx(ft,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(ft,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(ft,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ml,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:l,onChange:y=>i(y.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Tr,{id:"message",value:c,onChange:y=>u(y.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:m.isPending,children:[e.jsx(iu,{className:"h-4 w-4 mr-2"}),m.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Kge={points_earned:{label:"Points Earned",icon:_o,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:xn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:ml,color:"bg-green-500"},custom:{label:"Custom",icon:nn,color:"bg-purple-500"}};function DVt(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),{data:l=[],isLoading:i}=pt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:m,error:f}=await H.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const g=[...new Set([...m.map(w=>w.user_id),...m.map(w=>w.created_by).filter(Boolean)])],{data:y}=await H.from("profiles").select("id, name, email").in("id",g),_=new Map((y==null?void 0:y.map(w=>[w.id,w]))||[]);return m.map(w=>{var j,N,S;return{...w,user_name:((j=_.get(w.user_id))==null?void 0:j.name)||"Unknown",user_email:((N=_.get(w.user_id))==null?void 0:N.email)||"",creator_name:w.created_by?((S=_.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),c=l.filter(m=>{var _,w;const f=((_=m.user_name)==null?void 0:_.toLowerCase().includes(t.toLowerCase()))||((w=m.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||m.title.toLowerCase().includes(t.toLowerCase()),g=r==="all"||m.celebration_type===r,y=a==="all"||a==="seen"&&m.seen_at||a==="unseen"&&!m.seen_at;return f&&g&&y}),u={total:l.length,seen:l.filter(m=>m.seen_at).length,unseen:l.filter(m=>!m.seen_at).length,byType:Object.keys(Kge).reduce((m,f)=>(m[f]=l.filter(g=>g.celebration_type===f).length,m),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ys,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(iu,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(vr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(De,{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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by agent name, email, or title...",value:t,onChange:m=>s(m.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:r,onValueChange:n,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Filter by type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),Object.entries(Kge).map(([m,f])=>e.jsx(ft,{value:m,children:f.label},m))]})]}),e.jsxs(Rs,{value:a,onValueChange:o,children:[e.jsx(Ls,{className:"w-[140px]",children:e.jsx($s,{placeholder:"Status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Status"}),e.jsx(ft,{value:"seen",children:"Seen"}),e.jsx(ft,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Points"}),e.jsx(jt,{children:"Created By"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(qn,{children:c.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(m=>{const f=Kge[m.celebration_type],g=f.icon;return e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(g,{className:"h-3 w-3"}),f.label]})}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:m.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:m.user_email})]})}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:m.title}),m.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:m.message})]})}),e.jsx(ut,{children:m.points_amount?e.jsxs(Ye,{variant:"secondary",children:["+",m.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:m.creator_name})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ds(new Date(m.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(ut,{children:m.seen_at?e.jsx(Ye,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(Ye,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},m.id)})})]})}),c.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",c.length," of ",l.length," celebrations"]})]})]})]})}const OVt=()=>{const{user:t}=Fs(),{toast:s}=Ra(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[c,u]=k.useState("all"),[m,f]=k.useState("all"),[g,y]=k.useState("new"),[_,w]=k.useState(new Set),j=k.useCallback(async()=>{try{o(!0);const{data:J,error:Q}=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(Q)throw Q;const{data:ce,error:ne}=await H.from("trial_email_exports").select("user_id");if(ne)throw ne;const re=new Set((ce||[]).map(he=>he.user_id)),oe=(J||[]).map(he=>({...he,converted_from_trial_at:he.converted_from_trial_at??null,already_exported:re.has(he.id)}));oe.sort((he,xe)=>new Date(xe.created_at).getTime()-new Date(he.created_at).getTime()),n(oe)}catch(J){console.error("Error loading trial users:",J),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);k.useEffect(()=>{j()},[j]);const N=J=>J.trial_started_at?"ghl":"stripe",S=J=>J.trial_expires_at?J.trial_expires_at:J.subscription_end_date?J.subscription_end_date:null,M=J=>J.converted_from_trial_at!==null,I=J=>{if(M(J))return!1;const Q=S(J);return Q?new Date(Q).getTime()<=Date.now():!1},P=r.filter(J=>!(c!=="all"&&N(J)!==c||m==="active"&&(I(J)||M(J))||m==="expired"&&!I(J)||m==="converted"&&!M(J)||g==="new"&&J.already_exported||g==="exported"&&!J.already_exported)),O=()=>{_.size===P.length?w(new Set):w(new Set(P.map(J=>J.id)))},q=J=>{const Q=new Set(_);Q.has(J)?Q.delete(J):Q.add(J),w(Q)},$=async()=>{if(_.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const J=r.filter(ue=>_.has(ue.id)),Q="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=J.map(ue=>{const ge=(ue.name||"").split(" "),_e=ge[0]||"",Be=ge.slice(1).join(" ")||"",Se=N(ue)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ee=M(ue)?"Converted":I(ue)?"Expired":"Active",Ae=ue.created_at?new Date(ue.created_at).toLocaleDateString():"",Me=S(ue)?new Date(S(ue)).toLocaleDateString():"";return`"${_e}","${Be}","${ue.email}","${ue.phone||""}","${Se}","${Ee}","${Ae}","${Me}"`}),ne=[Q,...ce].join(` `),re=new Blob([ne],{type:"text/csv"}),oe=URL.createObjectURL(re),he=document.createElement("a");he.href=oe,he.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,he.click(),URL.revokeObjectURL(oe);const xe=J.filter(ue=>!ue.already_exported).map(ue=>({user_id:ue.id,exported_by:t.id}));if(xe.length>0){const{error:ue}=await H.from("trial_email_exports").upsert(xe,{onConflict:"user_id"});ue&&console.error("Error marking exports:",ue)}s({title:"Export complete",description:`Downloaded ${J.length} trial user(s). ${xe.length} newly marked as exported.`}),w(new Set),j()}catch(J){console.error("Export error:",J),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},z=r.filter(J=>!J.already_exported).length,V=r.filter(J=>J.already_exported).length,X=r.filter(J=>M(J)).length,Y=r.filter(J=>!I(J)&&!M(J)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ys,{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(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Total"}),e.jsx(Lt,{className:"text-2xl",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"New (Not Exported)"}),e.jsx(Lt,{className:"text-2xl text-green-600",children:z})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Active Trials"}),e.jsx(Lt,{className:"text-2xl",children:Y})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Converted 🎉"}),e.jsx(Lt,{className:"text-2xl text-primary",children:X})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Already Exported"}),e.jsx(Lt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Rs,{value:g,onValueChange:J=>y(J),children:[e.jsx(Ls,{className:"w-[160px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Users"}),e.jsx(ft,{value:"new",children:"New Only"}),e.jsx(ft,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(Rs,{value:c,onValueChange:J=>u(J),children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Trial Types"}),e.jsx(ft,{value:"stripe",children:"Credit Card Trial"}),e.jsx(ft,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(Rs,{value:m,onValueChange:J=>f(J),children:[e.jsx(Ls,{className:"w-[160px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Statuses"}),e.jsx(ft,{value:"active",children:"Active Trial"}),e.jsx(ft,{value:"expired",children:"Expired"}),e.jsx(ft,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(G,{onClick:$,disabled:l||_.size===0,children:[l?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export Selected (",_.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(Mo,{checked:P.length>0&&_.size===P.length,onCheckedChange:O})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Trial Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Expires / Renews"}),e.jsx(jt,{children:"Exported"})]})}),e.jsx(qn,{children:P.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):P.map(J=>{const Q=N(J),ce=M(J),ne=I(J),re=S(J);return e.jsxs(ks,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(ut,{children:e.jsx(Mo,{checked:_.has(J.id),onCheckedChange:()=>q(J.id)})}),e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[J.name,ce&&e.jsx(Bo,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(ut,{className:"text-muted-foreground",children:J.email}),e.jsx(ut,{children:Q==="stripe"?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Px,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(rr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(ut,{children:ce?e.jsxs(Ye,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Bo,{className:"h-3 w-3"}),"Converted"]}):ne?e.jsx(Ye,{variant:"destructive",children:"Expired"}):e.jsx(Ye,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(ut,{className:"text-sm",children:J.created_at?new Date(J.created_at).toLocaleDateString():"—"}),e.jsx(ut,{className:"text-sm",children:ce&&re?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(re).toLocaleDateString()]}):re?new Date(re).toLocaleDateString():"—"}),e.jsx(ut,{children:J.already_exported?e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ye,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},J.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",P.length," of ",r.length," trial users · ",X," converted to paid"]})]})},RVt=()=>{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(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(kr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(De,{children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Deleted By"})]})}),e.jsx(qn,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(ut,{className:"whitespace-nowrap text-sm",children:ds(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(ut,{children:a.brokerage_name||"—"}),e.jsx(ut,{children:e.jsx(Ye,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(ut,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},L3=t=>{const{user:s}=Fs(),r=Qt(),n=pt({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:y}=await f;if(y)throw y;return g||[]},enabled:!!s}),a=f=>pt({queryKey:["team-members",f],queryFn:async()=>{const{data:g,error:y}=await H.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(y)throw y;const _=(g||[]).map(N=>N.user_id),{data:w}=await H.from("profiles").select("id, name, email, avatar_url").in("id",_),j=new Map((w||[]).map(N=>[N.id,N]));return(g||[]).map(N=>({...N,profile:j.get(N.user_id)||null}))},enabled:!!f}),o=Tt({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:y,error:_}=await H.from("teams").insert(g).select().single();if(_)throw _;return y},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team created!")},onError:f=>{me.error("Failed to create team: "+f.message)}}),l=Tt({mutationFn:async({id:f,...g})=>{const{data:y,error:_}=await H.from("teams").update(g).eq("id",f).select().single();if(_)throw _;return y},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team updated")},onError:f=>{me.error("Failed to update team: "+f.message)}}),i=Tt({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=Tt({mutationFn:async f=>{const{data:g,error:y}=await H.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(y)throw y.message.includes("duplicate")||y.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):y;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=Tt({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)}}),m=Tt({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:m,useTeamMembers:a}},FVt=()=>{const{user:t}=Fs();return pt({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})},Itt=t=>{const{user:s}=Fs(),r=Qt(),n=pt({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),m=[...new Set(i.map(N=>N.added_by))],f=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),g=[...new Set([...m,...f])],[y,_]=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)]),w=new Map((y.data||[]).map(N=>[N.id,N])),j=new Map((_.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:w.get(N.contact_id)||null,contributor:j.get(N.added_by)||null,claimer:N.claimed_by&&j.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Tt({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=Tt({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=Tt({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}},zVt=()=>{const t=Qt();return Tt({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 Ltt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var P;const{user:o}=Fs(),{data:l}=Gx(),{useTeamMembers:i}=L3(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=zVt(),[m,f]=k.useState(null),[g,y]=k.useState(""),[_,w]=k.useState(!1),j=c.filter(O=>O.user_id!==(o==null?void 0:o.id)),N=async()=>{if(m){w(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:m,notes:g||void 0});s(!1),f(null),y(""),a==null||a()}catch{}finally{w(!1)}}},S=j.find(O=>O.user_id===m),M=r.length>1,I=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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(l1,{className:"h-5 w-5"}),"Transfer ",I]}),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(ye,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):j.map(O=>{var q,$,z;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 ${m===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:((q=O.profile)==null?void 0:q.avatar_url)||""}),e.jsx(Mn,{className:"text-xs",children:((($=O.profile)==null?void 0:$.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((z=O.profile)==null?void 0:z.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(ye,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Tr,{id:"transfer-notes",value:g,onChange:O=>y(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:N,disabled:!m||_,children:[_?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(l1,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(P=S.profile)==null?void 0:P.name}`:""]})]})]})})}const Qke=()=>{const t=ar(),{data:s,isLoading:r}=FVt(),{data:n}=Gx(),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState(null),[m,f]=k.useState(""),g=(n==null?void 0:n.role)==="team_leader",y=k.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(j=>{w.has(j.owner_user_id)||w.set(j.owner_user_id,{id:j.owner_user_id,name:j.owner_name||"Unknown",avatar:j.owner_avatar_url})}),Array.from(w.values())},[s]),_=k.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();w=w.filter(N=>{var S,M,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(j)||((S=N.email)==null?void 0:S.toLowerCase().includes(j))||((M=N.phone)==null?void 0:M.includes(j))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ws,{className:"h-10 w-full"}),e.jsx(ws,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ur,{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(Pe,{children:e.jsx(De,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:l,onValueChange:i,children:[e.jsx(Ls,{className:"w-[200px]",children:e.jsx($s,{placeholder:"Filter by agent"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Team Members"}),y.map(w=>e.jsx(ft,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.length," contact",_.length!==1?"s":""," from ",y.length," teammate",y.length!==1?"s":""]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0 overflow-x-auto",children:e.jsxs(Bn,{className:"min-w-[800px]",children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Address"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Date Added"}),g&&e.jsx(jt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(qn,{children:_.length===0?e.jsx(ks,{children:e.jsx(ut,{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(w=>e.jsxs(ks,{className:`hover:bg-accent/50 ${g?"cursor-pointer":""}`,onClick:g?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("span",{className:g?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:w.owner_avatar_url||""}),e.jsx(Mn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(rr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Nn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(ut,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(aa,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ut,{children:w.lead_source?e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ds(new Date(w.created_at),"MMM d, yyyy")})}),g&&e.jsx(ut,{children:e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:j=>{j.stopPropagation(),u(w.id),f(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(l1,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(Ltt,{open:!!c,onOpenChange:w=>{w||u(null)},contactIds:c?[c]:[],contactNames:m?[m]:[],onComplete:()=>u(null)})]})},Xke=({teamId:t})=>{const{user:s}=Fs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=Itt(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(ws,{className:"h-20 w-full"},c))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ey,{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,m,f,g,y,_,w;return e.jsx(Pe,{children:e.jsxs(De,{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," ",((m=c.contact)==null?void 0:m.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(rr,{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(Nn,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(Cn,{className:"h-4 w-4",children:[e.jsx(Wa,{src:((y=c.contributor)==null?void 0:y.avatar_url)||""}),e.jsx(Mn,{className:"text-[8px]",children:(((_=c.contributor)==null?void 0:_.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=c.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(G,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(kL,{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,m,f;return e.jsx(Pe,{className:"opacity-75",children:e.jsxs(De,{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," ",((m=c.contact)==null?void 0:m.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(Ye,{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(G,{size:"sm",variant:"outline",onClick:()=>o.mutate(c.id),disabled:o.isPending,children:[e.jsx(w0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},Dtt=({teamId:t})=>{const{useTeamMembers:s}=L3(),{data:r=[]}=s(t),n=r.map(y=>y.user_id),a=new Map(r.map(y=>[y.user_id,y.profile])),{data:o=[],isLoading:l}=pt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:y,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 y||[]},enabled:n.length>0}),{data:i=[],isLoading:c}=pt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:y,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 y||[]},enabled:n.length>0}),{data:u=[],isLoading:m}=pt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:y,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 y||[]},enabled:n.length>0});if(l||c||m)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(y=>e.jsx(ws,{className:"h-20 w-full"},y))});const g=y=>{const _=a.get(y);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(Pe,{children:e.jsxs(De,{className:"flex items-center gap-3 p-4",children:[e.jsx(sy,{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(Pe,{children:e.jsxs(De,{className:"flex items-center gap-3 p-4",children:[e.jsx(xn,{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(Pe,{children:e.jsxs(De,{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(ga,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ss,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ss,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(bs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Zge,{icon:e.jsx(sy,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(y=>{const _=g(y.owner_user_id);return e.jsx(Pe,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Cn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Wa,{src:_.avatar}),e.jsx(Mn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:y.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ds(new Date(y.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Ye,{variant:y.status==="published"?"default":"secondary",className:"text-xs capitalize",children:y.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),y.view_count||0]})]})]})},y.id)})}),e.jsx(bs,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Zge,{icon:e.jsx(xn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(y=>{const _=g(y.agent_id);return e.jsx(Pe,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Cn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Wa,{src:_.avatar}),e.jsx(Mn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:y.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ds(new Date(y.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[y.is_active?e.jsx(Ye,{className:"text-xs",children:"Active"}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ur,{className:"h-3 w-3"}),y.visitor_count||0]})]})]})},y.id)})}),e.jsx(bs,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Zge,{icon:e.jsx(An,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(y=>{const _=g(y.owner_user_id);return e.jsx(Pe,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Cn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Wa,{src:_.avatar}),e.jsx(Mn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:y.title||y.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ds(new Date(y.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Ye,{variant:"secondary",className:"text-xs capitalize",children:y.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),y.view_count||0]})]})]})},y.id)})})]})]})},Zge=({icon:t,label:s})=>e.jsx(Pe,{children:e.jsxs(De,{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})]})}),Ott=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var q,$;const{useTeamMembers:m}=L3(),{data:f=[],isLoading:g}=m(t.id),[y,_]=k.useState(!1),[w,j]=k.useState(""),[N,S]=k.useState("team_member"),{data:M}=pt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:z}=await H.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(z||[]).forEach(X=>{var Y;V.set(X.user_id,((Y=X.teams)==null?void 0:Y.name)||"another team")}),V}}),I=new Set(f.map(z=>z.user_id)),P=s.filter(z=>!I.has(z.id)),O=async()=>{w&&(await a(w,N),j(""),S("team_member"),_(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(G,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ga,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"members",children:"Members"}),e.jsxs(ss,{value:"contacts",children:[e.jsx(iS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ss,{value:"lead-pond",children:[e.jsx(ey,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ss,{value:"shared-assets",children:[e.jsx(Bm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ss,{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:y,onOpenChange:_,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(El,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Agent"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[w&&(((q=P.find(z=>z.id===w))==null?void 0:q.name)||(($=P.find(z=>z.id===w))==null?void 0:$.email))||"Select an agent",e.jsx(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search agents..."}),e.jsxs(qx,{children:[e.jsx(Ux,{children:"No agents found."}),e.jsx(Vx,{children:P.map(z=>{const V=M==null?void 0:M.get(z.id);return e.jsxs(_p,{value:z.name||z.email||z.id,disabled:!!V,onSelect:()=>j(z.id),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",w===z.id?"opacity-100":"opacity-0")}),z.name||z.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},z.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Role"}),e.jsxs(Rs,{value:N,onValueChange:S,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"team_leader",children:"Team Leader"}),e.jsx(ft,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(G,{onClick:O,disabled:!w||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),g?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(z=>e.jsx(ws,{className:"h-16 w-full"},z))}):f.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ur,{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(z=>{var V,X,Y,J,Q;return e.jsx(Pe,{children:e.jsxs(De,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:((V=z.profile)==null?void 0:V.avatar_url)||""}),e.jsx(Mn,{children:(((X=z.profile)==null?void 0:X.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=z.profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(J=z.profile)==null?void 0:J.email})]}),z.role==="team_leader"?e.jsxs(Ye,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(zm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Ye,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Rs,{value:z.role,onValueChange:ce=>l(z.id,ce),children:[e.jsx(Ls,{className:"w-[140px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"team_leader",children:"Team Leader"}),e.jsx(ft,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(e8,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Remove Member?"}),e.jsxs(lc,{children:["Remove ",((Q=z.profile)==null?void 0:Q.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>o(z.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},z.id)})})]}),e.jsx(bs,{value:"contacts",className:"space-y-4",children:e.jsx(Qke,{})}),t.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Xke,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(Dtt,{teamId:t.id})}),e.jsxs(bs,{value:"settings",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{className:"text-lg",children:"Team Settings"}),e.jsx(vr,{children:"Configure how this team operates."})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Team Name"}),e.jsx(Le,{defaultValue:t.name,onBlur:z=>{z.target.value!==t.name&&n({name:z.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{defaultValue:t.description||"",onBlur:z=>{z.target.value!==(t.description||"")&&n({description:z.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Contact Visibility"}),e.jsxs(Rs,{defaultValue:t.contact_visibility,onValueChange:z=>n({contact_visibility:z}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(ft,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(ft,{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(ye,{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:z=>n({lead_pond_enabled:z})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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:z=>n({shared_assets_enabled:z})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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:z=>n({shared_videos_enabled:z})})]})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsxs(G,{variant:"destructive",size:"sm",children:[e.jsx(kr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Team?"}),e.jsxs(lc,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},Rtt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=k.useState(1),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState(""),[j,N]=k.useState(""),[S,M]=k.useState([]),I=()=>{u(1),f(""),y(""),w(""),N(""),M([])},P=z=>{z||I(),s(z)},O=async()=>{const z=_&&_!=="none"?_:i||null;await r({name:m.trim(),description:g.trim()||void 0,brokerage_id:z,leaderId:j||void 0,memberIds:S.length>0?S:void 0}),I()},q=z=>{z!==j&&M(V=>V.includes(z)?V.filter(X=>X!==z):[...V,z])},$=a.filter(z=>z.id!==j);return e.jsx(fs,{open:t,onOpenChange:P,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(js,{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:Pt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Pt("h-1.5 flex-1 rounded-full transition-colors",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(ye,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Le,{id:"team-name",value:m,onChange:z=>f(z.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"team-desc",children:"Description"}),e.jsx(Tr,{id:"team-desc",value:g,onChange:z=>y(z.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(ye,{children:"Brokerage"}),e.jsxs(Rs,{value:_,onValueChange:w,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No brokerage (independent)"}),l.map(z=>e.jsx(ft,{value:z.id,children:z.name},z.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(zm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Rs,{value:j,onValueChange:z=>{N(z),M(V=>V.filter(X=>X!==z))},children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No leader for now"}),a.map(z=>e.jsx(ft,{value:z.id,children:z.name||z.email||"Unknown"},z.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(El,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(Ye,{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:$.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(ur,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):$.map(z=>{const V=S.includes(z.id);return e.jsxs("button",{type:"button",className:Pt("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>q(z.id),children:[e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:z.avatar_url||""}),e.jsx(Mn,{className:"text-xs",children:(z.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:z.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:z.email})]}),e.jsx("div",{className:Pt("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(ua,{className:"h-3 w-3"})})]},z.id)})})]})]})}),e.jsx(Rn,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsxs(G,{onClick:()=>u(2),disabled:!m.trim(),children:["Next",e.jsx(ba,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Ga,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(G,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},BVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=L3(),[c,u]=k.useState(!1),[m,f]=k.useState(null),[g,y]=k.useState(""),{data:_}=pt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:P,error:O}=await H.from("brokerages").select("id, name").order("name");if(O)throw O;return P||[]}}),{data:w}=pt({queryKey:["admin-team-member-info",t.map(P=>P.id).join(",")],queryFn:async()=>{var z;if(t.length===0)return{};const{data:P}=await H.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!P)return{};const O=P.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(X=>[X.id,{name:X.name}])))}const $={};for(const V of t){const X=P.filter(J=>J.team_id===V.id),Y=X.find(J=>J.role==="team_leader");$[V.id]={count:X.length,leaderName:Y&&((z=q[Y.user_id])==null?void 0:z.name)||null}}return $},enabled:t.length>0}),j=(m==null?void 0:m.brokerage_id)||null,{data:N}=pt({queryKey:["brokerage-agents-for-teams",j],queryFn:async()=>{let P=H.from("profiles").select("id, name, email, avatar_url").order("name");j&&(P=P.eq("brokerage_id",j));const{data:O,error:q}=await P;if(q)throw q;return O||[]},enabled:!!m}),S=Object.fromEntries((_||[]).map(P=>[P.id,P.name])),M=async P=>{const O=await r.mutateAsync({name:P.name,brokerage_id:P.brokerage_id||null,description:P.description});if(P.leaderId&&P.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:P.leaderId,role:"team_leader"}),P.memberIds)for(const q of P.memberIds)await o.mutateAsync({team_id:O.id,user_id:q,role:"team_member"});u(!1)};if(m)return e.jsx(Ott,{team:m,brokerageAgents:N||[],onBack:()=>f(null),onUpdate:P=>n.mutateAsync({id:m.id,...P}).then(O=>f(O)),onAddMember:(P,O)=>o.mutateAsync({team_id:m.id,user_id:P,role:O}),onRemoveMember:P=>l.mutateAsync({team_id:m.id,member_id:P}),onUpdateRole:(P,O)=>i.mutateAsync({team_id:m.id,member_id:P,role:O}),onDeleteTeam:()=>{a.mutate(m.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(P=>P.name.toLowerCase().includes(g.toLowerCase())||(P.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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search teams...",value:g,onChange:P=>y(P.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[I.length," of ",t.length," teams"]})]}),e.jsxs(G,{size:"sm",onClick:()=>u(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Rtt,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Team Name"}),e.jsx(jt,{className:"font-semibold",children:"Brokerage"}),e.jsx(jt,{className:"font-semibold",children:"Leader"}),e.jsx(jt,{className:"font-semibold",children:"Members"}),e.jsx(jt,{className:"font-semibold",children:"Visibility"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(qn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(P=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-32"})}),e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-24"})}),e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-28"})}),e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-12"})}),e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-20"})}),e.jsx(ut,{children:e.jsx(ws,{className:"h-4 w-16"})})]},P))}):I.length===0?e.jsx(ks,{children:e.jsx(ut,{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."})}):I.map(P=>{const O=w==null?void 0:w[P.id];return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsxs(ut,{children:[e.jsx("button",{onClick:()=>f(P),className:"text-primary hover:underline font-medium",children:P.name}),P.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:P.description})]}),e.jsx(ut,{children:P.brokerage_id?e.jsx("span",{className:"text-sm",children:S[P.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(ut,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(zm,{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(ut,{children:e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(ur,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(ut,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(ou,{className:"h-3 w-3"}),P.contact_visibility.replace("_"," ")]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(P),title:"Edit team",children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${P.name}"? This cannot be undone.`)&&a.mutate(P.id)},title:"Delete team",children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})})]},P.id)})})]})})]})},$Vt=()=>{const t=ar(),{user:s,isAdmin:r}=Fs(),{startImpersonation:n,isLoading:a}=Gde(),{toast:o}=Ra(),[l,i]=k.useState([]),[c,u]=k.useState([]),[m,f]=k.useState([]),[g,y]=k.useState({}),[_,w]=k.useState(!0),[j,N]=k.useState({}),[S,M]=k.useState(!1),[I,P]=k.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[O,q]=k.useState(!1),[$,z]=k.useState(""),[V,X]=k.useState(1),[Y,J]=k.useState(50),[Q,ce]=k.useState("all"),[ne,re]=k.useState("all"),[oe,he]=k.useState("all"),[xe,ue]=k.useState("all"),[ge,_e]=k.useState(!1),[Be,Se]=k.useState(!1),[Ee,Ae]=k.useState(null),[Me,ke]=k.useState(null),[Oe,qe]=k.useState(!1),[ve,dt]=k.useState({name:"",email:"",brokerage_id:"",phone:""}),[pe,Ue]=k.useState(null),[Xe,et]=k.useState(!1),[Ce,Je]=k.useState(""),[Ge,lt]=k.useState(!1),[He,We]=k.useState(!1),[tt,Ke]=k.useState(null),[rt,it]=k.useState(""),[It,Vt]=k.useState(!1),[hs,Es]=k.useState(!1),[Ts,cr]=k.useState(null),[zr,Ft]=k.useState(!1),[Ps,yr]=k.useState(!1),[Is,Ar]=k.useState(null),[tn,na]=k.useState(""),[Ln,tr]=k.useState(!1),[dr,Sr]=k.useState({email:"",name:"",password:"",phone:""}),[dn,Yr]=k.useState(!1),[ui,ns]=k.useState(!1),[Wt,Hr]=k.useState(""),[Mr,xr]=k.useState(!1),[Wn,ai]=k.useState(!1),[Aa,no]=k.useState(""),[$t,je]=k.useState(new Set),[$e,st]=k.useState(!1),[vt,xt]=k.useState(!1),[Ot,Zt]=k.useState(null),[qt,Xt]=k.useState(!1),[Os,Ns]=k.useState(null),[_r,Zr]=k.useState([]),[gr,Un]=k.useState([]),[Vn,Dn]=k.useState(!1),[ka,jo]=k.useState({});k.useEffect(()=>{!s||!r||(ii(),fl())},[s,r]);const cl=async()=>{try{const{data:_t,error:As}=await H.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(As)throw As;const Js={};for(const yn of _t??[])Js[yn.brokerage_id]||(Js[yn.brokerage_id]=[]),Js[yn.brokerage_id].push(yn.user_id);y(Js)}catch(_t){console.error("Error loading brokerage manager assignments:",_t)}},ii=async()=>{try{w(!0);const{data:_t,error:As}=await H.functions.invoke("get-user-details");if(As)throw As;const Js=_t.users||[];i(Js),f(_t.brokerages||[]),await cl();const yn=Js.filter(vn=>vn.roles.includes("assistant"));if(yn.length>0){const vn=yn.map(Wr=>Wr.id),{data:xa}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",vn);if(xa&&xa.length>0){const Wr=[...new Set(xa.map(Fp=>Fp.agent_id))],{data:fo}=await H.from("profiles").select("id, name, email").in("id",Wr),sg={};for(const Fp of xa){const Xr=fo==null?void 0:fo.find(iv=>iv.id===Fp.agent_id);Xr&&(sg[Fp.assistant_id]={agent_name:Xr.name||"",agent_email:Xr.email||""})}jo(sg)}}}catch(_t){console.error("Error loading members:",_t),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},fl=async()=>{try{const{data:_t,error:As}=await H.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(As)throw As;u(_t||[])}catch(_t){console.error("Error loading apps:",_t),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},ho=async _t=>{if(!ve.name.trim()||!ve.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ve.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Js}=await H.from("profiles").update({name:ve.name.trim(),email:ve.email.trim(),brokerage_id:ve.brokerage_id||null,phone:ve.phone.trim()||null}).eq("id",_t);if(Js)throw Js;o({title:"Success",description:"Member details updated successfully"}),Ae(null),ii()}catch(Js){console.error("Error updating member:",Js),o({title:"Error",description:Js.message||"Failed to update member",variant:"destructive"})}},za=async _t=>{try{const{data:{session:As}}=await H.auth.getSession(),Js=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:_t})}),yn=await Js.json();if(!Js.ok)throw new Error(yn.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"})}},mo=async(_t,As)=>{try{const{error:Js}=await H.functions.invoke("send-password-reset",{body:{email:_t,redirectTo:window.location.origin}});if(Js)throw Js;o({title:"Password Reset Sent",description:`Password reset email sent to ${As}`})}catch(Js){console.error("Error sending password reset:",Js),o({title:"Error",description:Js.message||"Failed to send password reset email",variant:"destructive"})}},Ei=async(_t,As)=>{if(confirm(`Are you sure you want to delete ${As}? This action cannot be undone.`))try{const{data:{session:Js}}=await H.auth.getSession(),yn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:_t})}),vn=await yn.json();if(!yn.ok)throw new Error(vn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),ii()}catch(Js){console.error("Error deleting user:",Js),o({title:"Error",description:Js.message||"Failed to delete user",variant:"destructive"})}},ya=async()=>{if(!I.email||!I.name||!I.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(I.role==="brokerage_manager"&&!I.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}M(!0);try{const{data:{session:_t}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_t==null?void 0:_t.access_token}`},body:JSON.stringify(I)}),Js=await As.json();if(!As.ok)throw new Error(Js.error||"Failed to create user");if(I.role&&I.role!=="user"&&Js.userId){const yn=I.role==="brokerage_manager"?I.brokerage_id:void 0;await po(Js.userId,I.role,"add",yn)}o({title:"Success",description:`User ${I.email} created successfully`}),P({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),q(!1),ii()}catch(_t){console.error("Error creating user:",_t),o({title:"Error",description:_t.message||"Failed to create user",variant:"destructive"})}finally{M(!1)}},po=async(_t,As,Js,yn)=>{try{const{data:{session:vn}}=await H.auth.getSession(),xa={userId:_t,role:As,action:Js};if(As==="brokerage_manager"){if(!yn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}xa.brokerageId=yn}const Wr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify(xa)}),fo=await Wr.json();if(!Wr.ok)throw new Error(fo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Js==="add"?"added":"removed"} successfully`}),ii()}catch(vn){console.error("Error managing user role:",vn),o({title:"Error",description:vn.message||"Failed to manage user role",variant:"destructive"})}},Ac=(_t,As)=>As.length===0?!0:As.some(Js=>_t.includes(Js)),Wc=async(_t,As,Js)=>{const yn=`${_t}-${As.id}`;Ue(yn);try{if(Js){const vn=l.find(Wr=>Wr.id===_t),xa=As.required_tags.filter(Wr=>vn==null?void 0:vn.tags.includes(Wr));for(const Wr of xa){const{error:fo}=await H.from("user_tags").delete().eq("user_id",_t).eq("tag",Wr);if(fo)throw fo}o({title:"Access Removed",description:`Removed access to ${As.name}`})}else if(As.required_tags.length>0){const{error:vn}=await H.from("user_tags").insert({user_id:_t,tag:As.required_tags[0]});if(vn)throw vn;o({title:"Access Granted",description:`Granted access to ${As.name}`})}await ii()}catch(vn){console.error("Error toggling access:",vn),o({title:"Error",description:vn.message||"Failed to update access",variant:"destructive"})}finally{Ue(null)}},hu=async()=>{const _t=Ce.trim();if(!_t){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(_t.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(m.find(Js=>Js.name.toLowerCase()===_t.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}lt(!0);try{const{error:Js}=await H.from("brokerages").insert({name:_t});if(Js)throw Js;o({title:"Success",description:`Brokerage "${_t}" created successfully`}),Je(""),et(!1),ii()}catch(Js){console.error("Error creating brokerage:",Js),o({title:"Error",description:Js.message||"Failed to create brokerage",variant:"destructive"})}finally{lt(!1)}},$f=_t=>{Ke(_t),it(_t.name),We(!0)},Vl=()=>{Ke(null),it(""),We(!1)},hh=async()=>{if(!tt)return;const _t=rt.trim();if(!_t){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(_t.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:_t}).eq("id",tt.id);if(As)throw As;o({title:"Success",description:"Brokerage updated successfully"}),Vl(),ii()}catch(As){console.error("Error updating brokerage:",As),o({title:"Error",description:As.message||"Failed to update brokerage",variant:"destructive"})}finally{Vt(!1)}},Md=async(_t,As)=>{var Js;if(!As||typeof As!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const yn={userId:_t,role:"brokerage_manager",action:"add",brokerageId:As};console.debug("[assignManagerToBrokerage] payload",yn);const{data:{session:vn}}=await H.auth.getSession(),xa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify(yn)}),Wr=await xa.json();if(!xa.ok&&!((Js=Wr.error)!=null&&Js.includes("duplicate")))throw new Error(Wr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await ii()}catch(yn){console.error("Error assigning manager:",yn),o({title:"Error",description:yn.message||"Failed to assign manager",variant:"destructive"})}},Zm=_t=>{cr(_t),Es(!0)},Hl=async()=>{if(Ts){Ft(!0);try{const _t=l.filter(yn=>yn.brokerage_id===Ts.id),{data:{session:As}}=await H.auth.getSession();for(const yn of _t){const vn=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:yn.id})});if(!vn.ok){const xa=await vn.json();console.error(`Failed to delete user ${yn.email}:`,xa.error)}}const{error:Js}=await H.from("brokerages").delete().eq("id",Ts.id);if(Js)throw Js;o({title:"Success",description:`Brokerage "${Ts.name}" and ${_t.length} member(s) deleted`}),Es(!1),cr(null),ii()}catch(_t){console.error("Error deleting brokerage:",_t),o({title:"Error",description:_t.message||"Failed to delete brokerage",variant:"destructive"})}finally{Ft(!1)}}},Jx=_t=>{Ar(_t),na(""),yr(!0)},_y=()=>{Ar(null),na(""),yr(!1)},J1=async _t=>{try{const{error:As}=await H.from("profiles").update({brokerage_id:null}).eq("id",_t);if(As)throw As;o({title:"Success",description:"User removed from brokerage"}),ii()}catch(As){console.error("Error removing user from brokerage:",As),o({title:"Error",description:As.message||"Failed to remove user",variant:"destructive"})}},eb=async(_t,As)=>{try{const{error:Js}=await H.from("profiles").update({brokerage_id:As}).eq("id",_t);if(Js)throw Js;o({title:"Success",description:"User added to brokerage"}),ii()}catch(Js){console.error("Error adding user to brokerage:",Js),o({title:"Error",description:Js.message||"Failed to add user",variant:"destructive"})}},tb=async()=>{if(!Is||!dr.email||!dr.name||!dr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Yr(!0);try{const{data:{session:_t}}=await H.auth.getSession(),As=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_t==null?void 0:_t.access_token}`},body:JSON.stringify({...dr,brokerage_id:Is.id,role:"user"})}),Js=await As.json();if(!As.ok)throw new Error(Js.error||"Failed to create agent");o({title:"Success",description:`Agent ${dr.email} created successfully`}),Sr({email:"",name:"",password:"",phone:""}),tr(!1),ii()}catch(_t){console.error("Error creating agent:",_t),o({title:"Error",description:_t.message||"Failed to create agent",variant:"destructive"})}finally{Yr(!1)}},Rp=_t=>l.filter(As=>As.brokerage_id===_t),dm=_t=>{const As=Rp(_t);if(!tn)return As;const Js=tn.toLowerCase();return As.filter(yn=>yn.name.toLowerCase().includes(Js)||yn.email.toLowerCase().includes(Js))},mu=_t=>l.filter(As=>As.brokerage_id!==_t),um=l.filter(_t=>{var Js;if($){const yn=$.toLowerCase();if(!(_t.name.toLowerCase().includes(yn)||_t.email.toLowerCase().includes(yn)||((Js=_t.brokerage_name)==null?void 0:Js.toLowerCase().includes(yn))))return!1}if(Q==="claimed"&&!_t.claimed||Q==="unclaimed"&&_t.claimed||ne!=="all"&&!_t.roles.includes(ne))return!1;const As=_t.is_trial||_t.subscription_status==="trialing";return!(oe==="trial"&&!As||oe==="non-trial"&&As||xe==="none"&&_t.brokerage_id||xe!=="all"&&xe!=="none"&&_t.brokerage_id!==xe)}),{sortKey:Vd,sortDirection:Td,handleSort:pu,sortData:qf}=mR("created_at","desc"),Uf=qf(um,{name:_t=>{var As;return((As=_t.name)==null?void 0:As.toLowerCase())||""},brokerage:_t=>{var As;return((As=_t.brokerage_name)==null?void 0:As.toLowerCase())||""},status:_t=>_t.claimed?"active":"pending",role:_t=>_t.roles[0]||"",last_login:_t=>_t.last_sign_in_at?new Date(_t.last_sign_in_at).getTime():null,created_at:_t=>_t.created_at?new Date(_t.created_at).getTime():null}),Ym=Uf.length,Qm=Y===0,Ad=Qm?1:Math.ceil(Ym/Y),sv=Qm?0:(V-1)*Y,eg=Qm?Ym:sv+Y,Il=Uf.slice(sv,eg),sb=_t=>{z(_t),X(1)},tg=_t=>{J(_t),X(1)},Fh=(_t,As)=>{_t(As),X(1)},Qw=async(_t,As)=>{_e(!0);try{const Js=l.find(Wr=>Wr.id===_t);if(!Js)return;const yn=Js.trial_expires_at?new Date(Js.trial_expires_at):new Date,vn=new Date(yn.getTime()+As*24*60*60*1e3),{error:xa}=await H.from("profiles").update({trial_expires_at:vn.toISOString()}).eq("id",_t);if(xa)throw xa;o({title:"Trial Extended",description:`Trial extended by ${As} days`}),ii()}catch(Js){console.error("Error extending trial:",Js),o({title:"Error",description:Js.message||"Failed to extend trial",variant:"destructive"})}finally{_e(!1)}},H3=async _t=>{Se(!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",_t);if(As)throw As;o({title:"Account Converted",description:"User has been converted to a full account"}),ii(),wy()}catch(As){console.error("Error converting trial:",As),o({title:"Error",description:As.message||"Failed to convert account",variant:"destructive"})}finally{Se(!1)}},rv=async _t=>{Dn(!0);try{const{data:As}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",_t);if(As&&As.length>0){const yn=As.map(xa=>xa.assistant_id),{data:vn}=await H.from("profiles").select("id, name, email").in("id",yn);Zr(As.map(xa=>{const Wr=vn==null?void 0:vn.find(fo=>fo.id===xa.assistant_id);return{id:xa.id,assistant_id:xa.assistant_id,assistant_name:(Wr==null?void 0:Wr.name)||"Unknown",assistant_email:(Wr==null?void 0:Wr.email)||"",permissions:xa.permissions||{}}}))}else Zr([]);const{data:Js}=await H.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",_t);if(Js&&Js.length>0){const yn=Js.map(xa=>xa.agent_id),{data:vn}=await H.from("profiles").select("id, name, email").in("id",yn);Un(Js.map(xa=>{const Wr=vn==null?void 0:vn.find(fo=>fo.id===xa.agent_id);return{id:xa.id,agent_id:xa.agent_id,agent_name:(Wr==null?void 0:Wr.name)||"Unknown",agent_email:(Wr==null?void 0:Wr.email)||"",permissions:xa.permissions||{}}}))}else Un([])}catch(As){console.error("Error loading assistant data:",As)}finally{Dn(!1)}},Ba=_t=>{ke(_t),dt({name:_t.name,email:_t.email,brokerage_id:_t.brokerage_id||"",phone:_t.phone||""}),qe(!0),rv(_t.id)},wy=()=>{ke(null),qe(!1),dt({name:"",email:"",brokerage_id:"",phone:""})},Xw=async()=>{Me&&(await ho(Me.id),wy())},G3=_t=>{je(As=>{const Js=new Set(As);return Js.has(_t)?Js.delete(_t):Js.add(_t),Js})},W3=()=>{if($t.size===Il.length&&Il.every(_t=>$t.has(_t.id))){const _t=new Set($t);Il.forEach(As=>_t.delete(As.id)),je(_t)}else{const _t=new Set($t);Il.forEach(As=>_t.add(As.id)),je(_t)}},hm=()=>{je(new Set)},nv=async()=>{if($t.size===0)return;st(!0);let _t=0,As=0;try{const{data:{session:Js}}=await H.auth.getSession();for(const yn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:yn})})).ok?_t++:As++}catch{As++}o({title:"Bulk Email Complete",description:`Sent ${_t} emails${As>0?`, ${As} failed`:""}`}),hm()}catch(Js){o({title:"Error",description:Js.message||"Failed to send emails",variant:"destructive"})}finally{st(!1)}},av=async()=>{if($t.size===0)return;st(!0);let _t=0,As=0;try{const{data:{session:Js}}=await H.auth.getSession();for(const yn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:yn})})).ok?_t++:As++}catch{As++}o({title:"Bulk Password Reset Complete",description:`Sent ${_t} reset emails${As>0?`, ${As} failed`:""}`}),hm()}catch(Js){o({title:"Error",description:Js.message||"Failed to send password reset emails",variant:"destructive"})}finally{st(!1)}},Jw=async()=>{if($t.size===0)return;const _t=l.filter(vn=>$t.has(vn.id)).map(vn=>vn.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 (${_t}${As})? This action cannot be undone.`))return;st(!0);let Js=0,yn=0;try{const{data:{session:vn}}=await H.auth.getSession();for(const xa of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify({userId:xa})})).ok?Js++:yn++}catch{yn++}o({title:"Bulk Delete Complete",description:`Deleted ${Js} users${yn>0?`, ${yn} failed`:""}`}),hm(),ii()}catch(vn){o({title:"Error",description:vn.message||"Failed to delete users",variant:"destructive"})}finally{st(!1)}},rb=async()=>{xt(!0);try{const{data:{session:_t}}=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 ${_t==null?void 0:_t.access_token}`}});if(!As.ok){const yn=await As.json();throw new Error(yn.error||"Failed to sync phones")}const Js=await As.json();o({title:"Phone Sync Complete",description:`Pulled ${Js.summary.pulledFromGHL} from GHL, pushed ${Js.summary.pushedToGHL} to GHL, ${Js.summary.alreadySynced} already synced`}),ii()}catch(_t){o({title:"Error",description:_t.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{xt(!1)}},Xm=async(_t,As)=>{Zt(_t);try{const{data:{session:Js}}=await H.auth.getSession(),{data:yn}=await H.from("profiles").select("phone").eq("id",_t).single(),vn=(yn==null?void 0:yn.phone)||"",xa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({email:As,action:"update",phone:vn||void 0})});if(!xa.ok){const fo=await xa.json();throw new Error(fo.error||"Failed to sync with GHL")}const Wr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(As)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:vn?`Phone ${vn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),ii()}catch(Js){o({title:"Error",description:Js.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},jy=async _t=>{await n(_t)},e2=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const _t=l.filter(fo=>$t.has(fo.id)),As=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Js=_t.map(fo=>[fo.name,fo.email,fo.phone||"",fo.brokerage_name||"",fo.roles.join("; "),fo.claimed?"Claimed":"Unclaimed",new Date(fo.created_at).toLocaleDateString()]),yn=[As.join(","),...Js.map(fo=>fo.map(sg=>`"${(sg||"").replace(/"/g,'""')}"`).join(","))].join(` `),vn=new Blob([yn],{type:"text/csv"}),xa=URL.createObjectURL(vn),Wr=document.createElement("a");Wr.href=xa,Wr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Wr.click(),URL.revokeObjectURL(xa),o({title:"Export complete",description:`Exported ${_t.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(dh,{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(G,{size:"sm",variant:"outline",onClick:rb,disabled:vt,children:[vt?e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:vt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:vt?"Syncing...":"Sync GHL"})]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>ns(!0),children:[e.jsx(h1,{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(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(El,{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(js,{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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",placeholder:"John Doe",value:I.name,onChange:_t=>P({...I,name:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:_t=>P({...I,email:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"password",children:"Password"}),e.jsx(Le,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:_t=>P({...I,password:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Le,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:_t=>P({...I,phone:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Rs,{value:I.brokerage_id||"none",onValueChange:_t=>P({...I,brokerage_id:_t==="none"?"":_t}),children:[e.jsx(Ls,{id:"brokerage",children:e.jsx($s,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"None"}),m.map(_t=>e.jsx(ft,{value:_t.id,children:_t.name},_t.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"role",children:"Role"}),e.jsxs(Rs,{value:I.role,onValueChange:_t=>P({...I,role:_t}),children:[e.jsx(Ls,{id:"role",children:e.jsx($s,{placeholder:"Select role"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"user",children:"User"}),e.jsx(ft,{value:"moderator",children:"Moderator"}),e.jsx(ft,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(ft,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Rs,{value:I.trial_days||"none",onValueChange:_t=>P({...I,trial_days:_t==="none"?"":_t}),children:[e.jsx(Ls,{id:"trial_days",children:e.jsx($s,{placeholder:"No trial (full access)"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No trial (full access)"}),e.jsx(ft,{value:"7",children:"7-day trial"}),e.jsx(ft,{value:"30",children:"30-day trial"}),e.jsx(ft,{value:"60",children:"60-day trial"}),e.jsx(ft,{value:"90",children:"90-day trial"}),e.jsx(ft,{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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(G,{onClick:ya,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ga,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"members",children:"Members"}),e.jsx(ss,{value:"brokerages",children:"Brokerages"}),e.jsx(ss,{value:"teams",children:"Teams"}),e.jsx(ss,{value:"trials",children:"Trial Users"}),e.jsx(ss,{value:"access",children:"Access Matrix"}),e.jsx(ss,{value:"celebrations",children:"Celebrations"}),e.jsx(ss,{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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search members...",value:$,onChange:_t=>sb(_t.target.value),className:"pl-10 h-9"})]}),e.jsxs(Rs,{value:Q,onValueChange:_t=>Fh(ce,_t),children:[e.jsx(Ls,{className:"w-[130px] h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Status"}),e.jsx(ft,{value:"claimed",children:"Active"}),e.jsx(ft,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(Rs,{value:ne,onValueChange:_t=>Fh(re,_t),children:[e.jsx(Ls,{className:"w-[130px] h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Roles"}),e.jsx(ft,{value:"admin",children:"Admin"}),e.jsx(ft,{value:"brokerage_manager",children:"Manager"}),e.jsx(ft,{value:"assistant",children:"Assistant"}),e.jsx(ft,{value:"user",children:"User"})]})]}),e.jsxs(Rs,{value:oe,onValueChange:_t=>Fh(he,_t),children:[e.jsx(Ls,{className:"w-[130px] h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Users"}),e.jsx(ft,{value:"trial",children:"Trial Only"}),e.jsx(ft,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(Rs,{value:xe,onValueChange:_t=>Fh(ue,_t),children:[e.jsx(Ls,{className:"w-[150px] h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Brokerages"}),e.jsx(ft,{value:"none",children:"No Brokerage"}),m.map(_t=>e.jsx(ft,{value:_t.id,children:_t.name},_t.id))]})]}),($||Q!=="all"||ne!=="all"||oe!=="all"||xe!=="all")&&e.jsxs(G,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{z(""),ce("all"),re("all"),he("all"),ue("all"),X(1)},children:[e.jsx(Er,{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:Qm?`Showing all ${Ym} members`:`Showing ${sv+1}-${Math.min(eg,Ym)} of ${Ym} members`}),e.jsxs(Rs,{value:Y.toString(),onValueChange:_t=>tg(Number(_t)),children:[e.jsx(Ls,{className:"h-9 w-[110px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"50",children:"50 / page"}),e.jsx(ft,{value:"100",children:"100 / page"}),e.jsx(ft,{value:"250",children:"250 / page"}),e.jsx(ft,{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(Wv,{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(G,{size:"sm",variant:"outline",onClick:nv,disabled:$e,children:[$e?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rr,{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(G,{size:"sm",variant:"outline",onClick:av,disabled:$e,children:[$e?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Mp,{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(G,{size:"sm",variant:"outline",onClick:e2,children:[e.jsx(vi,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Export"}),e.jsx("span",{className:"sm:hidden",children:"CSV"})]}),e.jsxs(G,{size:"sm",variant:"destructive",onClick:Jw,disabled:$e,children:[$e?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(kr,{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(G,{size:"sm",variant:"ghost",onClick:hm,disabled:$e,children:e.jsx(Er,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"w-[50px]",children:e.jsx(Mo,{checked:Il.length>0&&Il.every(_t=>$t.has(_t.id)),onCheckedChange:W3,"aria-label":"Select all on page"})}),e.jsx(_l,{sortKey:"name",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Name"}),e.jsx(_l,{sortKey:"brokerage",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Brokerage"}),e.jsx(_l,{sortKey:"status",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Status"}),e.jsx(_l,{sortKey:"role",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Role"}),e.jsx(_l,{sortKey:"last_login",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Last Login"}),e.jsx(_l,{sortKey:"created_at",currentSortKey:Vd,currentDirection:Td,onSort:pu,children:"Member Since"}),e.jsx(jt,{className:"w-[100px]"})]})}),e.jsx(qn,{children:Il.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Il.map(_t=>e.jsxs(ks,{className:`hover:bg-muted/30 ${$t.has(_t.id)?"bg-primary/5":""}`,children:[e.jsx(ut,{children:e.jsx(Mo,{checked:$t.has(_t.id),onCheckedChange:()=>G3(_t.id),"aria-label":`Select ${_t.name}`})}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>Ba(_t),className:"text-primary hover:underline font-medium text-left",children:_t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:_t.email})]})}),e.jsx(ut,{className:"text-muted-foreground",children:_t.brokerage_name||"—"}),e.jsx(ut,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const As=_t.is_trial&&_t.trial_expires_at||!_t.is_trial&&_t.subscription_status==="trialing"&&_t.subscription_end_date,Js=_t.trial_expires_at||_t.subscription_end_date;if(As&&Js){const yn=Math.ceil((new Date(Js).getTime()-Date.now())/864e5),vn=yn<=0,xa=yn<=3;return e.jsx(Ye,{variant:"outline",className:Pt("w-fit",vn?"border-destructive text-destructive":xa?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:vn?"Trial Expired":`Trial · ${yn}d left`})}return e.jsx(Ye,{variant:_t.claimed?"default":"secondary",className:_t.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:_t.claimed?"Active":"Pending"})})()})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col",children:[_t.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:_t.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),_t.roles.includes("assistant")&&ka[_t.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ka[_t.id].agent_name||ka[_t.id].agent_email]})]})}),e.jsx(ut,{className:"text-muted-foreground",children:_t.last_sign_in_at?new Date(_t.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(ut,{className:"text-muted-foreground",children:_t.created_at?new Date(_t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{Ns(_t),Xt(!0)},title:"Send celebration",children:e.jsx(iu,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ba(_t),title:"Edit member",children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Xm(_t.id,_t.email),disabled:Ot===_t.id,title:"Sync phone with GHL",children:Ot===_t.id?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Nn,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>za(_t.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>mo(_t.email,_t.name),title:"Send password reset",children:e.jsx(uS,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>jy(_t.id),disabled:a||_t.id===(s==null?void 0:s.id),title:_t.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${_t.name}`,children:a?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(pS,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ei(_t.id,_t.name),title:"Delete user",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},_t.id))})]})}),Ad>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 ",Ad]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:V===1,children:"First"}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(_t=>Math.max(1,_t-1)),disabled:V===1,children:e.jsx(tl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Ad)},(_t,As)=>{let Js;return Ad<=5||V<=3?Js=As+1:V>=Ad-2?Js=Ad-4+As:Js=V-2+As,e.jsx(G,{variant:V===Js?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(Js),children:Js},Js)})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(_t=>Math.min(Ad,_t+1)),disabled:V===Ad,children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>X(Ad),disabled:V===Ad,children:"Last"})]})]})]}),e.jsx(fs,{open:Oe,onOpenChange:qe,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Edit Member"}),e.jsx(Gr,{children:"Update member details, roles, and app access"})]}),Me&&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(ye,{htmlFor:"edit-name",children:"Name"}),e.jsx(Le,{id:"edit-name",value:ve.name,onChange:_t=>dt({...ve,name:_t.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"edit-email",children:"Email"}),e.jsx(Le,{id:"edit-email",type:"email",value:ve.email,onChange:_t=>dt({...ve,email:_t.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(ye,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Le,{id:"edit-phone",type:"tel",value:ve.phone,onChange:_t=>dt({...ve,phone:_t.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Rs,{value:ve.brokerage_id||"none",onValueChange:_t=>dt({...ve,brokerage_id:_t==="none"?"":_t}),children:[e.jsx(Ls,{id:"edit-brokerage",children:e.jsx($s,{placeholder:"Select brokerage"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"None"}),m.map(_t=>e.jsx(ft,{value:_t.id,children:_t.name},_t.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:[Me.roles.map(_t=>e.jsxs(Ye,{variant:"default",className:"gap-1",children:[e.jsx(ou,{className:"h-3 w-3"}),_t,_t==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>po(Me.id,_t,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Er,{className:"h-3 w-3"})})]},_t)),Me.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Rs,{onValueChange:_t=>po(Me.id,_t,"add"),children:[e.jsx(Ls,{className:"w-[200px]",children:e.jsx($s,{placeholder:"Add role..."})}),e.jsxs(Ds,{children:[!Me.roles.includes("admin")&&e.jsx(ft,{value:"admin",children:"Admin"}),!Me.roles.includes("user")&&e.jsx(ft,{value:"user",children:"User"})]})]}),!Me.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"})]}),(_r.length>0||gr.length>0||Me.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(ur,{className:"h-4 w-4"}),"Assistant Relationships"]}),Vn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[_r.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:"}),_r.map(_t=>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:_t.assistant_name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_t.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(_t.permissions).filter(([,As])=>As).map(([As])=>e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},_t.id))]}),gr.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:"}),gr.map(_t=>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:_t.agent_name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_t.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(_t.permissions).filter(([,As])=>As).map(([As])=>e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:As},As))})]},_t.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(_t=>{const As=Ac(Me.tags,_t.required_tags),Js=`${Me.id}-${_t.id}`,yn=pe===Js,vn=_t.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:_t.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_t.name}),vn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:yn?e.jsx(ys,{className:"h-4 w-4 animate-spin text-muted-foreground"}):vn?e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(qr,{checked:As,onCheckedChange:()=>Wc(Me.id,_t,As)})})]},_t.id)})})]}),(Me.is_trial||Me.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(mn,{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:[Me.trial_expires_at&&e.jsx(R8e,{expiresAt:Me.trial_expires_at}),!Me.trial_expires_at&&Me.subscription_status==="trialing"&&Me.subscription_end_date&&e.jsx(R8e,{expiresAt:Me.subscription_end_date})]}),(Me.trial_expires_at||Me.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Me.trial_expires_at||Me.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Qw(Me.id,7),disabled:ge,children:[e.jsx(G_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Qw(Me.id,14),disabled:ge,children:[e.jsx(G_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>Qw(Me.id,30),disabled:ge,children:[e.jsx(G_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(G,{size:"sm",variant:"default",onClick:()=>H3(Me.id),disabled:Be,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(ew,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Me.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Me.trial_started_at).toLocaleDateString(),Me.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Me.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:[Me.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Me.email_confirmed_at).toLocaleString()]}),Me.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Me.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Me.created_at).toLocaleString()]})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:wy,children:"Cancel"}),e.jsx(G,{onClick:Xw,children:"Save Changes"})]})]})}),e.jsxs(bs,{value:"access",children:[c.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(G,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Member Access Matrix"}),e.jsx(vr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs("div",{className:"relative w-full sm:w-72",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents by name or email...",value:$,onChange:_t=>{z(_t.target.value),X(1)},className:"pl-9"})]})]}),e.jsxs(De,{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(_t=>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:_t.icon}),e.jsx("span",{className:"text-sm",children:_t.name})]})},_t.id))]})}),e.jsxs("tbody",{children:[Il.map(_t=>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:_t.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:_t.email})]})}),c.map(As=>{const Js=Ac(_t.tags,As.required_tags),yn=`${_t.id}-${As.id}`,vn=pe===yn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:vn?e.jsx(ys,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(qr,{checked:Js,onCheckedChange:()=>Wc(_t.id,As,Js),disabled:As.required_tags.length===0})})},As.id)})]},_t.id)),Il.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"})})]})]})}),Ad>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 ",sv+1,"-",Math.min(eg,Ym)," of ",Ym," • Page ",V," of ",Ad]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(_t=>Math.max(1,_t-1)),disabled:V===1,children:e.jsx(tl,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(_t=>Math.min(Ad,_t+1)),disabled:V===Ad,children:e.jsx(da,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(G,{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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:Wt,onChange:_t=>Hr(_t.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[m.filter(_t=>_t.name.toLowerCase().includes(Wt.toLowerCase())).length," of ",m.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>{const _t=[];for(const Wr of m){const fo=g[Wr.id]??[];for(const sg of fo){const Fp=l.find(Xr=>Xr.id===sg);if(Fp){const Xr=(Fp.name||"").trim().split(/\s+/),iv=Xr[0]||"",ov=Xr.slice(1).join(" ")||"";_t.push({firstName:iv,lastName:ov,email:Fp.email,brokerageName:Wr.name})}}}if(_t.length===0){o({title:"No managers found to export"});return}const Js=[["First Name","Last Name","Email","Brokerage Name"].join(","),..._t.map(Wr=>[Wr.firstName,Wr.lastName,Wr.email,Wr.brokerageName].map(fo=>`"${(fo||"").replace(/"/g,'""')}"`).join(","))].join(` `),yn=new Blob([Js],{type:"text/csv"}),vn=URL.createObjectURL(yn),xa=document.createElement("a");xa.href=vn,xa.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,xa.click(),URL.revokeObjectURL(vn),o({title:`Exported ${_t.length} managers`})},children:[e.jsx(vi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:Xe,onOpenChange:et,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Le,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ce,onChange:_t=>Je(_t.target.value),maxLength:100})]})}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>et(!1),children:"Cancel"}),e.jsx(G,{onClick:hu,disabled:Ge,children:Ge?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(jt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(jt,{className:"font-semibold",children:"Agents"}),e.jsx(jt,{className:"w-[150px]"})]})}),e.jsx(qn,{children:(()=>{const _t=m.filter(As=>As.name.toLowerCase().includes(Wt.toLowerCase()));return _t.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:Wt?"No brokerages match your search":"No brokerages found"})}):_t.map(As=>{const Js=l.filter(Wr=>Wr.brokerage_id===As.id),vn=(g[As.id]??[]).map(Wr=>l.find(fo=>fo.id===Wr)).filter(Boolean),xa=Js.length;return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(ut,{children:e.jsx("button",{onClick:()=>$f(As),className:"text-primary hover:underline font-medium",children:As.name})}),e.jsx(ut,{children:vn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:vn.map(Wr=>e.jsx(Ye,{variant:"secondary",className:"text-xs",children:Wr.name},Wr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(ut,{children:[xa," member",xa!==1?"s":""]}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(G,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Jx(As),children:[e.jsx(ur,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>$f(As),title:"Edit brokerage",children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Zm(As),title:"Delete brokerage",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},As.id)})})()})]})}),e.jsx(fs,{open:He,onOpenChange:We,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Edit Brokerage"}),e.jsx(Gr,{children:"Update brokerage details and manage managers"})]}),tt&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Le,{id:"edit-brokerage-name",value:rt,onChange:_t=>it(_t.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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[tt.id]??[]).map(Js=>l.find(yn=>yn.id===Js)).filter(Boolean);return As.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):As.map(Js=>e.jsxs(Ye,{variant:"default",className:"gap-1",children:[e.jsx(ou,{className:"h-3 w-3"}),Js.name,e.jsx("button",{onClick:()=>po(Js.id,"brokerage_manager","remove",tt.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Er,{className:"h-3 w-3"})})]},Js.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(Vo,{open:Mr,onOpenChange:xr,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":Mr,className:"w-full justify-between",children:["Search for a member...",e.jsx(sn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-full p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search by name or email..."}),e.jsxs(qx,{className:"max-h-[200px]",children:[e.jsx(Ux,{children:"No members found."}),e.jsx(Vx,{children:(()=>{const _t=new Set(g[tt.id]??[]);return l.filter(As=>!_t.has(As.id)&&(r||As.brokerage_id===tt.id)).map(As=>e.jsxs(_p,{value:`${As.name} ${As.email}`,onSelect:()=>{Md(As.id,tt.id),xr(!1)},children:[As.name," (",As.email,")"]},As.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(_t=>_t.brokerage_id===tt.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(_t=>_t.brokerage_id===tt.id).map(_t=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:_t.name}),_t.roles.includes("brokerage_manager")&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Manager"})]},_t.id))})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:Vl,children:"Cancel"}),e.jsx(G,{onClick:hh,disabled:It,children:It?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:hs,onOpenChange:Es,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Gr,{children:['Are you sure you want to delete "',Ts==null?void 0:Ts.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 "',Ts==null?void 0:Ts.name,'"']}),e.jsxs("li",{children:["All ",l.filter(_t=>_t.brokerage_id===(Ts==null?void 0:Ts.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>Es(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:Hl,disabled:zr,children:zr?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Ps,onOpenChange:yr,children:e.jsxs(ps,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-5 w-5"}),"Manage ",Is==null?void 0:Is.name]}),e.jsx(Gr,{children:"Add, remove, or manage users in this brokerage"})]}),Is&&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(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search members...",value:tn,onChange:_t=>na(_t.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:Ln,onOpenChange:tr,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(El,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Add New Agent"}),e.jsxs(Gr,{children:["Create a new agent for ",Is.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-name",children:"Name"}),e.jsx(Le,{id:"agent-name",placeholder:"John Doe",value:dr.name,onChange:_t=>Sr({...dr,name:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-email",children:"Email"}),e.jsx(Le,{id:"agent-email",type:"email",placeholder:"john@example.com",value:dr.email,onChange:_t=>Sr({...dr,email:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-password",children:"Password"}),e.jsx(Le,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:dr.password,onChange:_t=>Sr({...dr,password:_t.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Le,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:dr.phone,onChange:_t=>Sr({...dr,phone:_t.target.value})})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>tr(!1),children:"Cancel"}),e.jsx(G,{onClick:tb,disabled:dn,children:dn?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(Vo,{open:Wn,onOpenChange:ai,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":Wn,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(sn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search users...",value:Aa,onValueChange:no}),e.jsxs(qx,{children:[e.jsx(Ux,{children:"No users found."}),e.jsx(Vx,{children:mu(Is.id).filter(_t=>Aa===""||_t.name.toLowerCase().includes(Aa.toLowerCase())||_t.email.toLowerCase().includes(Aa.toLowerCase())).map(_t=>e.jsxs(_p,{value:`${_t.name} ${_t.email}`,onSelect:()=>{eb(_t.id,Is.id),ai(!1),no("")},children:[_t.name," (",_t.email,")"]},_t.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(jt,{className:"font-semibold",children:"Name"}),e.jsx(jt,{className:"font-semibold",children:"Email"}),e.jsx(jt,{className:"font-semibold",children:"Status"}),e.jsx(jt,{className:"font-semibold",children:"Role"}),e.jsx(jt,{className:"w-[120px]"})]})}),e.jsx(qn,{children:dm(Is.id).length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:tn?"No matching members found":"No members in this brokerage"})}):dm(Is.id).map(_t=>e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(ut,{className:"font-medium",children:_t.name}),e.jsx(ut,{className:"text-muted-foreground",children:_t.email}),e.jsx(ut,{children:_t.claimed?e.jsx(Ye,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(Ye,{variant:"secondary",children:"Pending"})}),e.jsx(ut,{children:_t.roles.includes("brokerage_manager")?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(ou,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!_t.claimed&&e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>za(_t.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>J1(_t.id),title:"Remove from brokerage",children:e.jsx(Er,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>jy(_t.id),disabled:a||_t.id===(s==null?void 0:s.id),title:_t.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${_t.name}`,children:a?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(pS,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ei(_t.id,_t.name),title:"Delete user",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},_t.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Rp(Is.id).length," total member",Rp(Is.id).length!==1?"s":""," •",Rp(Is.id).filter(_t=>_t.roles.includes("brokerage_manager")).length," manager",Rp(Is.id).filter(_t=>_t.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(Rn,{children:e.jsx(G,{variant:"outline",onClick:_y,children:"Close"})})]})})]}),e.jsx(bs,{value:"teams",children:e.jsx(BVt,{})}),e.jsx(bs,{value:"trials",children:e.jsx(OVt,{})}),e.jsx(bs,{value:"celebrations",children:e.jsx(DVt,{})}),e.jsx(bs,{value:"deletions",children:e.jsx(RVt,{})})]})]}),e.jsx(Ett,{open:ui,onOpenChange:ns,brokerages:m,onSuccess:ii}),Os&&e.jsx(Ptt,{open:qt,onOpenChange:_t=>{Xt(_t),_t||Ns(null)},userId:Os.id,userName:Os.name})]})},qVt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState(""),[m,f]=k.useState(""),[g,y]=k.useState("");k.useEffect(()=>{_()},[]);const _=async()=>{const{data:P,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(P||[]),n(!1)},w=async P=>{if(P.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:m?parseInt(m):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(""),y(""),_()),o(!1)},j=async(P,O)=>{const{error:q}=await H.from("invite_codes").update({is_active:!O}).eq("id",P);q?me.error("Failed to update code"):s(t.map($=>$.id===P?{...$,is_active:!O}:$))},N=async P=>{const{error:O}=await H.from("invite_codes").delete().eq("id",P);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter(q=>q.id!==P)))},S="https://dashboard.relevelup.com",M=P=>{const O=`${S}/join?code=${P}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},I=`${S}/join`;return e.jsx(Ms,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Create New Code"}),e.jsxs(vr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(De,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"code",children:"Code"}),e.jsx(Le,{id:"code",placeholder:"WELCOME2024",value:l,onChange:P=>i(P.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(ye,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Le,{id:"description",placeholder:"For marketing campaign",value:c,onChange:P=>u(P.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Le,{id:"maxUses",type:"number",placeholder:"Unlimited",value:m,onChange:P=>f(P.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(Le,{id:"trialDays",type:"number",placeholder:"None",value:g,onChange:P=>y(P.target.value),className:"w-28"})]}),e.jsxs(G,{type:"submit",disabled:a,children:[a?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Active Codes"})}),e.jsx(De,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Code"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Uses"}),e.jsx(jt,{children:"Trial"}),e.jsx(jt,{children:"Created"}),e.jsx(jt,{children:"Active"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:t.map(P=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-mono font-medium",children:P.code}),e.jsx(ut,{className:"text-muted-foreground",children:P.description||"—"}),e.jsxs(ut,{children:[P.uses_count,P.max_uses&&` / ${P.max_uses}`]}),e.jsx(ut,{children:P.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[P.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-muted-foreground",children:ds(new Date(P.created_at),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx(qr,{checked:P.is_active,onCheckedChange:()=>j(P.id,P.is_active)})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>M(P.code),title:"Copy invite link",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>N(P.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},P.id))})]})})]})]})})},pR=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}},SE=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}}},UVt=async(t,s)=>await pR("new_templates")?SE({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}),VVt=async(t,s)=>SE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),HVt=async(t,s)=>await pR("new_events")?SE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),GVt=async(t,s)=>await pR("new_toolbox")?SE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),bbe=async(t,s)=>await pR("new_social_swag")?SE({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}),WVt=async(t,s)=>await pR("new_newsletters")?SE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),Vz={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 KVt(){const t=ar(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState(Vz),[c,u]=k.useState(null),[m,f]=k.useState(null),[g,y]=k.useState(!1),_=k.useRef(null),[w,j]=k.useState(!1),[N,S]=k.useState(null),[M,I]=k.useState(!1),[P,O]=k.useState(null),[q,$]=k.useState(null),[z,V]=k.useState(!0),[X,Y]=k.useState(""),{data:J,isLoading:Q}=pt({queryKey:["admin-events"],queryFn:async()=>{const{data:Ce,error:Je}=await H.from("events").select("*").order("event_date",{ascending:!0});if(Je)throw Je;return Ce}}),{data:ce}=pt({queryKey:["event-registrations-count"],queryFn:async()=>{let Ce=[],Je=0;const Ge=1e3;for(;;){const{data:He,error:We}=await H.from("event_registrations").select("event_id").range(Je,Je+Ge-1);if(We)throw We;if(!He||He.length===0||(Ce=Ce.concat(He),He.length{lt[He.event_id]=(lt[He.event_id]||0)+1}),lt}}),{data:ne,isLoading:re}=pt({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Ce,error:Je}=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(Je)throw Je;if(!Ce||Ce.length===0)return[];const Ge=Ce.map(We=>We.user_id).filter(Boolean);let lt=[];if(Ge.length>0){const{data:We,error:tt}=await H.from("profiles").select("id, name, email").in("id",Ge);if(tt)throw tt;lt=We||[]}const He=new Map((lt==null?void 0:lt.map(We=>[We.id,We]))||[]);return Ce.map(We=>({...We,profiles:We.user_id&&He.get(We.user_id)||null}))},enabled:!!N}),{data:oe,isLoading:he}=pt({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Ce,error:Je}=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(Je)throw Je;if(!Ce||Ce.length===0)return[];const Ge=Ce.map(Ke=>Ke.user_id).filter(Boolean);let lt=[];if(Ge.length>0){const{data:Ke,error:rt}=await H.from("profiles").select("id, name, email").in("id",Ge);if(rt)throw rt;lt=Ke||[]}const{data:He}=await H.from("agent_points").select("user_id").eq("event_id",N.id),We=new Set((He==null?void 0:He.map(Ke=>Ke.user_id))||[]),tt=new Map((lt==null?void 0:lt.map(Ke=>[Ke.id,Ke]))||[]);return Ce.map(Ke=>({...Ke,profiles:Ke.user_id&&tt.get(Ke.user_id)||null,points_awarded:Ke.user_id?We.has(Ke.user_id):!1}))},enabled:!!N}),xe=Ce=>{S(Ce),j(!0)},ue=Tt({mutationFn:async Ce=>{const{data:{session:Je}}=await H.auth.getSession();if(!Je)throw new Error("Not authenticated");const Ge=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Je.access_token}`},body:JSON.stringify({event_id:Ce})}),lt=await Ge.json();if(!Ge.ok)throw new Error(lt.error||"Failed to sync");return lt},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Ce.message)},onError:Ce=>{me.error("Failed to sync: "+Ce.message)}}),ge=Tt({mutationFn:async Ce=>{const{data:{session:Je}}=await H.auth.getSession();if(!Je)throw new Error("Not authenticated");const Ge=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Je.access_token}`},body:JSON.stringify({event_id:Ce})}),lt=await Ge.json();if(!Ge.ok)throw new Error(lt.error||"Failed to sync attendees");return lt},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ce!=null&&Ce.message?me.success(Ce.message):me.success(`Synced ${Ce.synced||0} attendees. ${Ce.points_awarded||0} points awarded!`)},onError:Ce=>{me.error("Failed to sync attendees: "+Ce.message)}}),_e=Tt({mutationFn:async({eventId:Ce,testMode:Je})=>{const{data:{session:Ge}}=await H.auth.getSession();if(!Ge)throw new Error("Not authenticated");const lt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ge.access_token}`},body:JSON.stringify({event_id:Ce,test_mode:Je})}),He=await lt.json();if(!lt.ok)throw new Error(He.error||"Failed to send reminders");return He},onSuccess:Ce=>{Ce.test?me.success(Ce.message||"Test email sent!"):me.success(Ce.message||`Reminder emails sent to ${Ce.sent} registrants!`)},onError:Ce=>{me.error("Failed to send reminders: "+Ce.message)}}),{data:Be}=pt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ce=[],Je=0;const Ge=1e3;for(;;){const{data:lt,error:He}=await H.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(Je,Je+Ge-1);if(He)throw He;if(!lt||lt.length===0||(Ce=[...Ce,...lt],lt.length{const{error:He}=await H.from("event_attendees").update({user_id:Je}).eq("id",Ce);if(He)throw He;if(lt&&Ge){const{error:tt}=await H.from("zoom_email_aliases").upsert({user_id:Je,zoom_email:Ge.toLowerCase()},{onConflict:"zoom_email"});tt&&console.error("Failed to save alias:",tt)}const We=N==null?void 0:N.id;if(We){const{data:tt}=await H.from("user_roles").select("id").eq("user_id",Je).eq("role","admin").single();if(!tt){const{data:Ke}=await H.from("agent_points").select("id").eq("user_id",Je).eq("event_id",We).single();Ke||(await H.rpc("award_attendance_points",{p_user_id:Je,p_event_id:We,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await H.rpc("check_and_award_badges",{p_user_id:Je}))}}return{userId:Je,zoomEmail:Ge,shouldSaveAlias:lt}},onSuccess:Ce=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let Je="Attendee linked and points awarded!";Ce.shouldSaveAlias&&Ce.zoomEmail&&(Je+=` Email "${Ce.zoomEmail}" will be auto-matched in the future.`),me.success(Je),I(!1),O(null),$(null),Y("")},onError:Ce=>{me.error("Failed to link attendee: "+Ce.message)}}),Ee=Ce=>{O(Ce),$(null),V(!0),Y(""),I(!0)},Ae=()=>{!P||!q||Se.mutate({attendeeId:P.id,userId:q,zoomEmail:P.zoom_email,shouldSaveAlias:z})},Me=(Be==null?void 0:Be.filter(Ce=>{var Ge,lt;if(!X)return!0;const Je=X.toLowerCase();return((Ge=Ce.name)==null?void 0:Ge.toLowerCase().includes(Je))||((lt=Ce.email)==null?void 0:lt.toLowerCase().includes(Je))}))||[],ke=async Ce=>{const Je=Ce.name.split(".").pop(),lt=`${`${crypto.randomUUID()}.${Je}`}`,{error:He}=await H.storage.from("event-images").upload(lt,Ce);if(He)throw He;const{data:{publicUrl:We}}=H.storage.from("event-images").getPublicUrl(lt);return We},Oe=Ce=>{var Ge;const Je=(Ge=Ce.target.files)==null?void 0:Ge[0];if(Je){if(Je.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(Je),f(URL.createObjectURL(Je))}},qe=()=>{u(null),f(null),i({...l,image_url:""}),_.current&&(_.current.value="")},ve=Tt({mutationFn:async Ce=>{y(!0);let Je=Ce.image_url;c&&(Je=await ke(c)||"");const Ge=new Date(Ce.event_date),[lt,He]=Ce.event_time.split(":");Ge.setHours(parseInt(lt),parseInt(He));const We=[new Date(Ge)];if(Ce.is_recurring&&Ce.recurrence_end_date){let it=new Date(Ge);for(;Ce.recurrence_pattern==="weekly"?it=j4(it,1):Ce.recurrence_pattern==="biweekly"?it=j4(it,2):it=qm(it,1),!(it>Ce.recurrence_end_date);)We.push(new Date(it))}const tt=We.map(it=>({title:Ce.title,description:Ce.description||null,image_url:Je||null,video_url:Ce.video_url||null,event_date:it.toISOString(),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||null,capacity:Ce.capacity?parseInt(Ce.capacity):null,is_published:Ce.is_published})),{data:Ke,error:rt}=await H.from("events").insert(tt).select();if(rt)throw rt;return Ke&&Ke.length>0&&HVt(Ce.title,Ke[0].id),We.length},onSuccess:Ce=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Ce>1?`${Ce} recurring events created successfully`:"Event created successfully"),n(!1),i(Vz),u(null),f(null),y(!1)},onError:Ce=>{me.error("Failed to create event: "+Ce.message),y(!1)}}),dt=Tt({mutationFn:async({id:Ce,data:Je})=>{y(!0);let Ge=Je.image_url;c&&(Ge=await ke(c)||"");const lt=new Date(Je.event_date),[He,We]=Je.event_time.split(":");lt.setHours(parseInt(He),parseInt(We));const{error:tt}=await H.from("events").update({title:Je.title,description:Je.description||null,image_url:Ge||null,video_url:Je.video_url||null,event_date:lt.toISOString(),zoom_link:Je.zoom_link,zoom_meeting_id:Je.zoom_meeting_id||null,capacity:Je.capacity?parseInt(Je.capacity):null,is_published:Je.is_published}).eq("id",Ce);if(tt)throw tt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(Vz),u(null),f(null),y(!1)},onError:Ce=>{me.error("Failed to update event: "+Ce.message),y(!1)}}),pe=Tt({mutationFn:async Ce=>{const{error:Je}=await H.from("events").delete().eq("id",Ce);if(Je)throw Je},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Ce=>{me.error("Failed to delete event: "+Ce.message)}}),Ue=Ce=>{var Ge;const Je=new Date(Ce.event_date);o(Ce),i({title:Ce.title,description:Ce.description||"",image_url:Ce.image_url||"",video_url:Ce.video_url||"",event_date:Je,event_time:ds(Je,"HH:mm"),zoom_link:Ce.zoom_link,zoom_meeting_id:Ce.zoom_meeting_id||"",capacity:((Ge=Ce.capacity)==null?void 0:Ge.toString())||"",is_published:Ce.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Ce.image_url||null),u(null),n(!0)},Xe=Ce=>{if(Ce.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?dt.mutate({id:a.id,data:l}):ve.mutate(l)},et=()=>{n(!1),o(null),i(Vz),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(G,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Ga,{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(Pe,{className:"mb-6",children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Ce=>!Ce&&et(),children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{onClick:()=>n(!0),children:[e.jsx(qs,{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(js,{children:e.jsx(vs,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:Xe,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:l.title,onChange:Ce=>i({...l,title:Ce.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:l.description,onChange:Ce=>i({...l,description:Ce}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Event Image"}),e.jsx("input",{type:"file",ref:_,accept:"image/*",onChange:Oe,className:"hidden"}),m?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:m,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(G,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:qe,children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs(G,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Ce;return(Ce=_.current)==null?void 0:Ce.click()},children:[e.jsx(ci,{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(ye,{children:"Date *"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),l.event_date?ds(l.event_date,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:l.event_date,onSelect:Ce=>i({...l,event_date:Ce}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"time",children:"Time *"}),e.jsx(Le,{id:"time",type:"time",value:l.event_time,onChange:Ce=>i({...l,event_time:Ce.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Le,{id:"zoom_link",value:l.zoom_link,onChange:Ce=>i({...l,zoom_link:Ce.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Le,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ce=>i({...l,zoom_meeting_id:Ce.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(ye,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Le,{id:"video_url",value:l.video_url,onChange:Ce=>i({...l,video_url:Ce.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(ye,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Le,{id:"capacity",type:"number",value:l.capacity,onChange:Ce=>i({...l,capacity:Ce.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($L,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(qr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ce=>i({...l,is_recurring:Ce})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Frequency"}),e.jsxs(Rs,{value:l.recurrence_pattern,onValueChange:Ce=>i({...l,recurrence_pattern:Ce}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"weekly",children:"Weekly"}),e.jsx(ft,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(ft,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Repeat Until"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ds(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:l.recurrence_end_date,onSelect:Ce=>i({...l,recurrence_end_date:Ce}),disabled:Ce=>Ce<(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 Ce=1,Je=new Date(l.event_date);for(;Je=l.recurrence_pattern==="weekly"?j4(Je,1):l.recurrence_pattern==="biweekly"?j4(Je,2):qm(Je,1),!(Je>l.recurrence_end_date);)Ce++;return Ce})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{htmlFor:"is_published",children:"Published"}),e.jsx(qr,{id:"is_published",checked:l.is_published,onCheckedChange:Ce=>i({...l,is_published:Ce})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:et,className:"flex-1",children:"Cancel"}),e.jsx(G,{type:"submit",className:"flex-1",disabled:ve.isPending||dt.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(De,{children:Q?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(J==null?void 0:J.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Date & Time"}),e.jsx(jt,{children:"Registrations"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:J==null?void 0:J.map(Ce=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:Ce.title}),e.jsx(ut,{children:ds(new Date(Ce.event_date),"PPP p")}),e.jsx(ut,{children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>xe(Ce),children:[e.jsx(ur,{className:"h-4 w-4"}),(ce==null?void 0:ce[Ce.id])||0,Ce.capacity&&` / ${Ce.capacity}`]})}),e.jsx(ut,{children:e.jsx("span",{className:Pt("px-2 py-1 rounded-full text-xs font-medium",Ce.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:Ce.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>window.open(Ce.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>Ue(Ce),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&pe.mutate(Ce.id)},children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},Ce.id))})]})})]}),e.jsx(fs,{open:w,onOpenChange:j,children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ur,{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(G,{variant:"ghost",size:"sm",onClick:()=>_e.mutate({eventId:N.id,testMode:!0}),disabled:_e.isPending,children:[e.jsx(rr,{className:Pt("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>_e.mutate({eventId:N.id}),disabled:_e.isPending||!(ne!=null&&ne.length),children:[e.jsx(rr,{className:Pt("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(G,{variant:"outline",size:"sm",onClick:()=>ue.mutate(N.id),disabled:ue.isPending,children:[e.jsx(zo,{className:Pt("h-4 w-4 mr-2",ue.isPending&&"animate-spin")}),ue.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(G,{variant:"default",size:"sm",onClick:()=>ge.mutate(N.id),disabled:ge.isPending,children:[e.jsx(_o,{className:Pt("h-4 w-4 mr-2",ge.isPending&&"animate-spin")}),ge.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ga,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ss,{value:"registrations",className:"gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),"Registrations (",(ne==null?void 0:ne.length)||0,")"]}),e.jsxs(ss,{value:"attendees",className:"gap-2",children:[e.jsx(sa,{className:"h-4 w-4"}),"Attendees (",(oe==null?void 0:oe.length)||0,")"]})]}),e.jsx(bs,{value:"registrations",className:"mt-4",children:re?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ne==null?void 0:ne.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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Registered"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(qn,{children:ne==null?void 0:ne.map(Ce=>{var He,We;const Je=((He=Ce.profiles)==null?void 0:He.name)||Ce.zoom_name||"Unknown",Ge=((We=Ce.profiles)==null?void 0:We.email)||Ce.zoom_email||null,lt=!Ce.user_id;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Je,lt&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(ut,{children:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ut,{className:"text-muted-foreground text-sm",children:ds(new Date(Ce.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{children:Ce.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"})})]},Ce.id)})})]})}),e.jsx(bs,{value:"attendees",className:"mt-4",children:he?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(oe==null?void 0:oe.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:[(oe==null?void 0:oe.filter(Ce=>!Ce.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(ul,{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 (",oe==null?void 0:oe.filter(Ce=>!Ce.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:oe==null?void 0:oe.filter(Ce=>!Ce.user_id).map(Ce=>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:Ce.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ce.zoom_email||"No email"})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>Ee(Ce),className:"gap-1",children:[e.jsx(pl,{className:"h-3 w-3"}),"Link to Profile"]})]},Ce.id))})]}),e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Points"})]})}),e.jsx(qn,{children:oe==null?void 0:oe.filter(Ce=>Ce.user_id).map(Ce=>{var lt,He;const Je=((lt=Ce.profiles)==null?void 0:lt.name)||Ce.zoom_name||"Unknown",Ge=((He=Ce.profiles)==null?void 0:He.email)||Ce.zoom_email||null;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Je,Ce.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(ut,{children:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ut,{children:Ce.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(mn,{className:"h-3 w-3"}),Ce.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:Ce.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(_o,{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"})})]},Ce.id)})})]})]})})]})]})}),e.jsx(fs,{open:M,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(pl,{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."})]}),P&&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:P.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:P.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:X,onChange:Ce=>Y(Ce.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Me.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:Me.slice(0,20).map(Ce=>e.jsxs("button",{type:"button",onClick:()=>$(Ce.id),className:Pt("w-full p-3 text-left hover:bg-muted/50 transition-colors",q===Ce.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ce.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ce.email})]},Ce.id))})}),P.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Mo,{id:"save-alias",checked:z,onCheckedChange:Ce=>V(Ce)}),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(G,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(G,{onClick:Ae,disabled:!q||Se.isPending,children:Se.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function ZVt({selectedKitIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=pt({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])},m=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(Al,{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(Ye,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>m(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Er,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Vo,{open:a,onOpenChange:o,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Al,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs($o,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{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(Al,{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 YVt=()=>{const{user:t}=Fs(),{toast:s}=Ra(),r=Qt(),[n,a]=Ul(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=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),[y,_]=k.useState(0),[w,j]=k.useState(!1),[N,S]=k.useState(null),[M,I]=k.useState(""),[P,O]=k.useState([]),[q,$]=k.useState(""),[z,V]=k.useState(""),[X,Y]=k.useState(!1),[J,Q]=k.useState(!1),{data:ce=[]}=pt({queryKey:["template-categories"],queryFn:async()=>{const{data:Ue,error:Xe}=await H.from("template_categories").select("*").order("name");if(Xe)throw Xe;return Ue}}),{data:ne=[]}=pt({queryKey:["template-types"],queryFn:async()=>{const{data:Ue,error:Xe}=await H.from("template_types").select("*").order("name");if(Xe)throw Xe;return Ue}}),{data:re=[],isLoading:oe}=pt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ue,error:Xe}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(Xe)throw Xe;const{data:et,error:Ce}=await H.from("template_links").select("*").order("sort_order");if(Ce)throw Ce;const{data:Je,error:Ge}=await H.from("template_guides").select("*").order("sort_order");if(Ge)throw Ge;return Ue.map(He=>({...He,links:(et==null?void 0:et.filter(We=>We.template_id===He.id))||[],guides:(Je==null?void 0:Je.filter(We=>We.template_id===He.id))||[]}))}});k.useEffect(()=>{const Ue=n.get("edit");if(Ue&&re.length>0){const Xe=re.find(et=>et.id===Ue);Xe&&(Be(Xe),a({},{replace:!0}))}},[re,n]);const he=Tt({mutationFn:async Ue=>{const{data:Xe,error:et}=await H.from("template_categories").insert({name:Ue}).select().single();if(et)throw et;return Xe},onSuccess:Ue=>{r.invalidateQueries({queryKey:["template-categories"]}),m({...u,category_id:Ue.id}),$(""),Y(!1),s({title:"Category added"})},onError:Ue=>{s({title:"Error adding category",description:Ue.message,variant:"destructive"})}}),xe=Tt({mutationFn:async Ue=>{const{data:Xe,error:et}=await H.from("template_types").insert({name:Ue}).select().single();if(et)throw et;return Xe},onSuccess:Ue=>{r.invalidateQueries({queryKey:["template-types"]}),m({...u,type_id:Ue.id}),V(""),Q(!1),s({title:"Type added"})},onError:Ue=>{s({title:"Error adding type",description:Ue.message,variant:"destructive"})}}),ue=Tt({mutationFn:async Ue=>{var Ge;let Xe=Ue.existingImageUrl;if(Ue.image){const lt=Ue.image.name.split(".").pop(),He=`${Date.now()}-${Math.random().toString(36).substring(7)}.${lt}`,{error:We}=await H.storage.from("template-previews").upload(He,Ue.image);if(We)throw We;const{data:tt}=H.storage.from("template-previews").getPublicUrl(He);Xe=tt.publicUrl}const et={name:Ue.template.name,description:Ue.template.description||null,category_id:Ue.template.category_id||null,type_id:Ue.template.type_id||null,preview_image_url:Xe,video_url:Ue.videoUrl||null,publish_date:Ue.template.publish_date?new Date(Ue.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Ce=Ue.templateId;if(Ce){const{error:lt}=await H.from("canva_templates").update(et).eq("id",Ce);if(lt)throw lt;const{error:He}=await H.from("template_links").delete().eq("template_id",Ce);if(He)throw He;const We=((Ge=Ue.existingGuides)==null?void 0:Ge.map(rt=>rt.id).filter(Boolean))||[],tt=Ue.template.guides.map(rt=>rt.id).filter(Boolean),Ke=We.filter(rt=>!tt.includes(rt));Ke.length>0&&await H.from("template_guides").delete().in("id",Ke)}else{const{data:lt,error:He}=await H.from("canva_templates").insert(et).select().single();if(He)throw He;Ce=lt.id,UVt(Ue.template.name,lt.id)}const Je=Ue.template.links.filter(lt=>lt.title.trim()&<.canva_share_link.trim());if(Je.length>0){const lt=Je.map((We,tt)=>({template_id:Ce,title:We.title.trim(),canva_share_link:We.canva_share_link.trim(),sort_order:tt})),{error:He}=await H.from("template_links").insert(lt);if(He)throw He}for(let lt=0;lt0)){const{error:lt}=await H.from("resource_kit_templates").insert(Ue.linkedKitIds.map(He=>({template_id:Ce,kit_id:He})));if(lt)throw lt}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),_e(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ue=>{s({title:"Error saving template",description:Ue.message,variant:"destructive"})}}),ge=Tt({mutationFn:async Ue=>{const{error:Xe}=await H.from("canva_templates").delete().eq("id",Ue);if(Xe)throw Xe},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ue=>{s({title:"Error deleting template",description:Ue.message,variant:"destructive"})}}),_e=()=>{m({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),I(""),c(null),Y(!1),Q(!1),$(""),V(""),g(null),_(0),j(!1),O([])},Be=async Ue=>{var et;c(Ue),m({name:Ue.name,description:Ue.description||"",category_id:Ue.category_id||"",type_id:Ue.type_id||"",publish_date:Ue.publish_date?new Date(Ue.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ue.links&&Ue.links.length>0?Ue.links.map(Ce=>({id:Ce.id,title:Ce.title,canva_share_link:Ce.canva_share_link,sort_order:Ce.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((et=Ue.guides)==null?void 0:et.map(Ce=>({id:Ce.id,name:Ce.name,file_url:Ce.file_url,file_type:Ce.file_type,file_size:Ce.file_size,sort_order:Ce.sort_order})))||[],video_url:Ue.video_url||""}),I(Ue.preview_image_url||""),g(null);const{data:Xe}=await H.from("resource_kit_templates").select("kit_id").eq("template_id",Ue.id);O((Xe||[]).map(Ce=>Ce.kit_id)),l(!0)},Se=Ue=>{var et;const Xe=(et=Ue.target.files)==null?void 0:et[0];Xe&&(S(Xe),I(URL.createObjectURL(Xe)))},Ee=()=>{m({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Ae=Ue=>{if(u.links.length<=1)return;const Xe=u.links.filter((et,Ce)=>Ce!==Ue);m({...u,links:Xe})},Me=(Ue,Xe,et)=>{const Ce=[...u.links];Ce[Ue]={...Ce[Ue],[Xe]:et},m({...u,links:Ce})},ke=Ue=>{const Xe=Ue.target.files;if(!Xe)return;const et=Array.from(Xe).map((Ce,Je)=>({name:Ce.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ce.type,file_size:Ce.size,sort_order:u.guides.length+Je,file:Ce}));m({...u,guides:[...u.guides,...et]}),Ue.target.value=""},Oe=Ue=>{const Xe=u.guides.filter((et,Ce)=>Ce!==Ue);m({...u,guides:Xe})},qe=(Ue,Xe)=>{const et=[...u.guides];et[Ue]={...et[Ue],name:Xe},m({...u,guides:et})},ve=async()=>{if(!f)return null;j(!0),_(0);try{const{data:Ue,error:Xe}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(Xe)throw new Error(Xe.message);const{videoId:et,libraryId:Ce}=Ue,{data:Je,error:Ge}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(Ge)throw new Error(Ge.message);const lt=new XMLHttpRequest;return await new Promise((We,tt)=>{lt.upload.addEventListener("progress",Ke=>{if(Ke.lengthComputable){const rt=Math.round(Ke.loaded/Ke.total*100);_(rt)}}),lt.addEventListener("load",()=>{lt.status>=200&<.status<300?We():tt(new Error(`Upload failed with status ${lt.status}`))}),lt.addEventListener("error",()=>tt(new Error("Upload failed"))),lt.open("PUT",Je.uploadUrl),lt.setRequestHeader("AccessKey",Je.apiKey),lt.send(f)}),`https://player.mediadelivery.net/embed/${Ce}/${et}`}catch(Ue){return console.error("Bunny upload error:",Ue),s({title:"Video upload failed",description:Ue instanceof Error?Ue.message:"Unknown error",variant:"destructive"}),null}finally{j(!1)}},dt=Ue=>{var et;const Xe=(et=Ue.target.files)==null?void 0:et[0];Xe&&g(Xe),Ue.target.value=""},pe=async Ue=>{if(Ue.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ce=>Ce.title.trim()&&Ce.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 Ce=await ve();if(!Ce)return;et=Ce}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:P})};return e.jsx(Ms,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:ne.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:Ue=>{l(Ue),Ue||_e()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:pe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(Le,{id:"name",value:u.name,onChange:Ue=>m({...u,name:Ue.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:u.description,onChange:Ue=>m({...u,description:Ue}),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(ye,{children:"Canva Links *"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:Ee,className:"gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Ue,Xe)=>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(Le,{value:Ue.title,onChange:et=>Me(Xe,"title",et.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Le,{value:Ue.canva_share_link,onChange:et=>Me(Xe,"canva_share_link",et.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Ae(Xe),children:e.jsx(Er,{className:"h-4 w-4"})})]},Xe))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Category"}),X?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:q,onChange:Ue=>$(Ue.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(G,{type:"button",size:"sm",onClick:()=>q.trim()&&he.mutate(q.trim()),disabled:he.isPending,children:"Add"}),e.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),$("")},children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:u.category_id,onValueChange:Ue=>m({...u,category_id:Ue}),children:[e.jsx(Ls,{className:"flex-1",children:e.jsx($s,{placeholder:"Select category"})}),e.jsx(Ds,{children:ce.map(Ue=>e.jsx(ft,{value:Ue.id,children:Ue.name},Ue.id))})]}),e.jsx(G,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Template Type"}),J?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:z,onChange:Ue=>V(Ue.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(G,{type:"button",size:"sm",onClick:()=>z.trim()&&xe.mutate(z.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),V("")},children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:u.type_id,onValueChange:Ue=>m({...u,type_id:Ue}),children:[e.jsx(Ls,{className:"flex-1",children:e.jsx($s,{placeholder:"Select type"})}),e.jsx(Ds,{children:ne.map(Ue=>e.jsx(ft,{value:Ue.id,children:Ue.name},Ue.id))})]}),e.jsx(G,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:u.publish_date,onChange:Ue=>m({...u,publish_date:Ue.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(ye,{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(G,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),I("")},children:e.jsx(Er,{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(bl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Le,{type:"file",accept:"image/*",onChange:Se,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>m({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",y,"%"]})]}),e.jsx(qi,{value:y,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(G,{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(Er,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Le,{type:"file",accept:"video/*",onChange:dt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(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(ye,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Le,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:ke,className:"hidden"}),e.jsx(G,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ue,Xe)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(wn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Le,{value:Ue.name,onChange:et=>qe(Xe,et.target.value),placeholder:"Guide name",className:"flex-1"}),Ue.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ue.file_size/1024).toFixed(0)," KB"]}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Oe(Xe),children:e.jsx(Er,{className:"h-4 w-4"})})]},Ue.id||Xe))}):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(ZVt,{selectedKitIds:P,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>{l(!1),_e()},children:"Cancel"}),e.jsx(G,{type:"submit",disabled:ue.isPending,children:ue.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):re.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:re.map(Ue=>{var Xe,et,Ce,Je,Ge;return e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ue.preview_image_url?e.jsx("img",{src:Ue.preview_image_url,alt:Ue.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(ut,{className:"font-medium",children:Ue.name}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(Ye,{variant:"secondary",children:[((Xe=Ue.links)==null?void 0:Xe.length)||0," link",(((et=Ue.links)==null?void 0:et.length)||0)!==1?"s":""]}),(((Ce=Ue.guides)==null?void 0:Ce.length)||0)>0&&e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(wn,{className:"h-3 w-3"}),(Je=Ue.guides)==null?void 0:Je.length," guide",(((Ge=Ue.guides)==null?void 0:Ge.length)||0)!==1?"s":""]})]})}),e.jsx(ut,{children:Ue.category?e.jsx(Ye,{variant:"secondary",children:Ue.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{children:Ue.type?e.jsx(Ye,{variant:"outline",children:Ue.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{className:"text-muted-foreground",children:new Date(Ue.publish_date).toLocaleDateString()}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{size:"icon",variant:"ghost",onClick:()=>Be(Ue),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&ge.mutate(Ue.id)},children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},Ue.id)})})]})})})]})})};function Ftt({selectedTemplateIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=pt({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])},m=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(mS,{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(Ye,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>m(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Er,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Vo,{open:a,onOpenChange:o,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(mS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs($o,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{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(mS,{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 QVt=[{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"}],XVt=()=>{const{user:t}=Fs(),[s,r]=Ul(),{toast:n}=Ra(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=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),[y,_]=k.useState(""),[w,j]=k.useState([]),[N,S]=k.useState([]),[M,I]=k.useState([]),[P,O]=k.useState([]),[q,$]=k.useState(""),[z,V]=k.useState(!1),[X,Y]=k.useState(null),[J,Q]=k.useState(0),[ce,ne]=k.useState(!1),[re,oe]=k.useState(null),{data:he=[]}=pt({queryKey:["academy-categories"],queryFn:async()=>{const{data:pe,error:Ue}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ue)throw Ue;return pe}}),{data:xe=[],isLoading:ue}=pt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:pe,error:Ue}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ue)throw Ue;const{data:Xe,error:et}=await H.from("academy_resources").select("*").order("sort_order");if(et)throw et;return pe.map(Je=>({...Je,resources:(Xe==null?void 0:Xe.filter(Ge=>Ge.video_id===Je.id))||[]}))}});k.useEffect(()=>{const pe=s.get("edit");if(pe&&xe.length>0){const Ue=xe.find(Xe=>Xe.id===pe);Ue&&(Ae(Ue),r({},{replace:!0}))}},[xe,s]);const ge=Tt({mutationFn:async pe=>{const{data:Ue,error:Xe}=await H.from("academy_categories").insert({name:pe,sort_order:he.length}).select().single();if(Xe)throw Xe;return Ue},onSuccess:pe=>{a.invalidateQueries({queryKey:["academy-categories"]}),m({...u,category_id:pe.id}),$(""),V(!1),n({title:"Category added"})},onError:pe=>{n({title:"Error adding category",description:pe.message,variant:"destructive"})}}),_e=Tt({mutationFn:async pe=>{let Ue=pe.existingThumbnailUrl;if(pe.thumbnail){const Ce=pe.thumbnail.name.split(".").pop(),Je=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ce}`,{error:Ge}=await H.storage.from("academy-resources").upload(Je,pe.thumbnail);if(Ge)throw Ge;const{data:lt}=H.storage.from("academy-resources").getPublicUrl(Je);Ue=lt.publicUrl}const Xe={title:pe.video.title,description:pe.video.description||null,video_url:pe.video.video_url,video_type:pe.video.video_type,duration:pe.video.duration||null,thumbnail_url:Ue,category_id:pe.video.category_id||null,publish_date:pe.video.publish_date?new Date(pe.video.publish_date).toISOString():new Date().toISOString(),is_published:pe.video.is_published,created_by:t==null?void 0:t.id};let et=pe.videoId;if(et){const{error:Ce}=await H.from("academy_videos").update(Xe).eq("id",et);if(Ce)throw Ce}else{const{data:Ce,error:Je}=await H.from("academy_videos").insert(Xe).select().single();if(Je)throw Je;et=Ce.id,VVt(pe.video.title,Ce.id)}if(pe.resourcesToDelete.length>0){const{error:Ce}=await H.from("academy_resources").delete().in("id",pe.resourcesToDelete);if(Ce)throw Ce}for(let Ce=0;Ce0){const{error:Ce}=await H.from("academy_video_templates").insert(P.map(Je=>({video_id:et,template_id:Je})));if(Ce)throw Ce}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ee(),l(!1),n({title:i?"Video updated":"Video created"})},onError:pe=>{n({title:"Error saving video",description:pe.message,variant:"destructive"})}}),Be=Tt({mutationFn:async pe=>{const{error:Ue}=await H.from("academy_videos").delete().eq("id",pe);if(Ue)throw Ue},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:pe=>{n({title:"Error deleting video",description:pe.message,variant:"destructive"})}}),Se=Tt({mutationFn:async({id:pe,is_published:Ue})=>{const{error:Xe}=await H.from("academy_videos").update({is_published:Ue}).eq("id",pe);if(Xe)throw Xe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:pe=>{n({title:"Error updating video",description:pe.message,variant:"destructive"})}}),Ee=()=>{m({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),g(null),_(""),j([]),S([]),I([]),c(null),O([]),$(""),Y(null),Q(0),ne(!1),oe(null)},Ae=async pe=>{c(pe),m({title:pe.title,description:pe.description||"",video_url:pe.video_url,video_type:pe.video_type,duration:pe.duration||"",category_id:pe.category_id||"",publish_date:pe.publish_date?new Date(pe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:pe.is_published}),_(pe.thumbnail_url||""),S(pe.resources||[]),j([]),I([]);const{data:Ue}=await H.from("academy_video_templates").select("template_id").eq("video_id",pe.id);O((Ue||[]).map(Xe=>Xe.template_id)),l(!0)},Me=pe=>{var Xe;const Ue=(Xe=pe.target.files)==null?void 0:Xe[0];Ue&&(g(Ue),_(URL.createObjectURL(Ue)))},ke=pe=>{const Ue=pe.target.files;if(Ue){const Xe=Array.from(Ue).map(et=>({file:et,title:et.name.replace(/\.[^/.]+$/,"")}));j([...w,...Xe])}pe.target.value=""},Oe=pe=>{j(w.filter((Ue,Xe)=>Xe!==pe))},qe=pe=>{I([...M,pe]),S(N.filter(Ue=>Ue.id!==pe))},ve=async()=>{if(!X)return null;ne(!0),Q(0);try{const{data:pe,error:Ue}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||X.name}});if(Ue)throw new Error(Ue.message);const{videoId:Xe,libraryId:et}=pe;oe(Xe);const{data:Ce,error:Je}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Xe}});if(Je)throw new Error(Je.message);const Ge=new XMLHttpRequest;return await new Promise((He,We)=>{Ge.upload.addEventListener("progress",tt=>{if(tt.lengthComputable){const Ke=Math.round(tt.loaded/tt.total*100);Q(Ke)}}),Ge.addEventListener("load",()=>{Ge.status>=200&&Ge.status<300?He():We(new Error(`Upload failed with status ${Ge.status}`))}),Ge.addEventListener("error",()=>We(new Error("Upload failed"))),Ge.open("PUT",Ce.uploadUrl),Ge.setRequestHeader("AccessKey",Ce.apiKey),Ge.send(X)}),`https://player.mediadelivery.net/embed/${et}/${Xe}`}catch(pe){return console.error("Bunny upload error:",pe),n({title:"Video upload failed",description:pe instanceof Error?pe.message:"Unknown error",variant:"destructive"}),null}finally{ne(!1)}},dt=async pe=>{if(pe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ue=u.video_url;if(u.video_type==="bunny_stream"&&X&&!i){const Xe=await ve();if(!Xe)return;Ue=Xe}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!X&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}_e.mutate({video:{...u,video_url:Ue},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:M})};return e.jsx(Ms,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.length})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.filter(pe=>pe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:pe=>{l(pe),pe||Ee()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:dt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:u.title,onChange:pe=>m({...u,title:pe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:u.description,onChange:pe=>m({...u,description:pe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Video Type"}),e.jsxs(Rs,{value:u.video_type,onValueChange:pe=>{m({...u,video_type:pe,video_url:""}),Y(null)},disabled:ce,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:QVt.map(pe=>e.jsx(ft,{value:pe.value,children:pe.label},pe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ye,{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(Le,{type:"file",accept:"video/*",onChange:pe=>{var Xe;const Ue=(Xe=pe.target.files)==null?void 0:Xe[0];Ue&&Y(Ue)},disabled:ce}),X&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(An,{className:"h-4 w-4"}),X.name," (",(X.size/(1024*1024)).toFixed(1)," MB)"]}),ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(qi,{value:J,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[J,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Le,{id:"video_url",value:u.video_url,onChange:pe=>m({...u,video_url:pe.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(ye,{htmlFor:"duration",children:"Duration"}),e.jsx(Le,{id:"duration",value:u.duration,onChange:pe=>m({...u,duration:pe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:u.publish_date,onChange:pe=>m({...u,publish_date:pe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Category"}),z?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:q,onChange:pe=>$(pe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(G,{type:"button",size:"sm",onClick:()=>q.trim()&&ge.mutate(q.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(G,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),$("")},children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:u.category_id,onValueChange:pe=>m({...u,category_id:pe}),children:[e.jsx(Ls,{className:"flex-1",children:e.jsx($s,{placeholder:"Select category"})}),e.jsx(Ds,{children:he.map(pe=>e.jsx(ft,{value:pe.id,children:pe.name},pe.id))})]}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[y&&e.jsx("img",{src:y,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Le,{type:"file",accept:"image/*",onChange:Me,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(ye,{children:"Resource Files"}),e.jsx(G,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(ci,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:ke,className:"hidden"})]})})]}),(N.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(pe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:pe.title}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:pe.file_type}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>qe(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Er,{className:"h-4 w-4"})})]},pe.id)),w.map((pe,Ue)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:pe.title,onChange:Xe=>{const et=[...w];et[Ue].title=Xe.target.value,j(et)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>Oe(Ue),className:"text-destructive hover:text-destructive",children:e.jsx(Er,{className:"h-4 w-4"})})]},Ue))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(Ftt,{selectedTemplateIds:P,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_published",checked:u.is_published,onCheckedChange:pe=>m({...u,is_published:pe})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(Rn,{children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(G,{type:"submit",disabled:_e.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):_e.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{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"})}):xe.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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(qn,{children:xe.map(pe=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[pe.thumbnail_url?e.jsx("img",{src:pe.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:pe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:pe.video_type.replace("_"," ")})]})]})}),e.jsx(ut,{children:pe.category?e.jsx(Ye,{variant:"outline",children:pe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:pe.duration||"-"}),e.jsx(ut,{children:pe.resources&&pe.resources.length>0?e.jsxs(Ye,{variant:"secondary",children:[pe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:new Date(pe.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(qr,{checked:pe.is_published,onCheckedChange:Ue=>Se.mutate({id:pe.id,is_published:Ue})})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Ae(pe),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Be.mutate(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},pe.id))})]})})})]})})};function JVt(){var _e,Be,Se;const t=Qt(),[s,r]=Ul(),[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,m]=k.useState(null),[f,g]=k.useState(""),[y,_]=k.useState([]),[w,j]=k.useState([]),[N,S]=k.useState([]),[M,I]=k.useState(null),{data:P,isLoading:O}=pt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ee,error:Ae}=await H.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Ae)throw Ae;return Ee}}),{data:q}=pt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ee,error:Ae}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Ae)throw Ae;return Ee}}),{data:$}=pt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ee,error:Ae}=await H.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Ae)throw Ae;return Ee}});k.useEffect(()=>{const Ee=s.get("edit");if(Ee&&P&&P.length>0&&q&&$){const Ae=P.find(Me=>Me.id===Ee);Ae&&(V(Ae),r({},{replace:!0}))}},[P,q,$,s]);const z=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),m(null),g(""),_([]),j([]),S([]),l(null)},V=async Ee=>{l(Ee),c({name:Ee.name,description:Ee.description||"",publish_date:Ee.publish_date.split("T")[0],is_published:Ee.is_published}),g(Ee.featured_image_url||"");const Ae=(q==null?void 0:q.filter(Oe=>Oe.kit_id===Ee.id))||[];_(Ae.map(Oe=>({id:Oe.id,name:Oe.name,file_url:Oe.file_url,file_type:Oe.file_type,file_size:Oe.file_size,sort_order:Oe.sort_order})));const Me=($==null?void 0:$.filter(Oe=>Oe.kit_id===Ee.id))||[];j(Me.map(Oe=>({id:Oe.id,title:Oe.title,canva_share_link:Oe.canva_share_link,sort_order:Oe.sort_order})));const{data:ke}=await H.from("resource_kit_templates").select("template_id").eq("kit_id",Ee.id);S((ke||[]).map(Oe=>Oe.template_id)),a(!0)},X=Ee=>{var Me;const Ae=(Me=Ee.target.files)==null?void 0:Me[0];Ae&&(m(Ae),g(URL.createObjectURL(Ae)))},Y=()=>{_([...y,{name:"",file_url:"",sort_order:y.length}])},J=Ee=>{_(y.filter((Ae,Me)=>Me!==Ee))},Q=(Ee,Ae,Me)=>{const ke=[...y];ke[Ee]={...ke[Ee],[Ae]:Me},_(ke)},ce=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},ne=Ee=>{j(w.filter((Ae,Me)=>Me!==Ee))},re=(Ee,Ae,Me)=>{const ke=[...w];ke[Ee]={...ke[Ee],[Ae]:Me},j(ke)},oe=(Ee,Ae)=>{var ke;const Me=(ke=Ae.target.files)==null?void 0:ke[0];if(Me){const Oe=[...y],qe=Me.name.replace(/\.[^/.]+$/,"");Oe[Ee]={...Oe[Ee],file:Me,file_type:Me.type,file_size:Me.size,name:Oe[Ee].name||qe},_(Oe)}},he=Tt({mutationFn:async()=>{let Ee=(o==null?void 0:o.featured_image_url)||null;if(u){const qe=u.name.split(".").pop(),ve=`${Date.now()}.${qe}`,{error:dt}=await H.storage.from("resource-kits").upload(`featured/${ve}`,u);if(dt)throw dt;const{data:pe}=H.storage.from("resource-kits").getPublicUrl(`featured/${ve}`);Ee=pe.publicUrl}const Ae={name:i.name,description:i.description||null,featured_image_url:Ee,publish_date:i.publish_date,is_published:i.is_published};let Me;const ke=!o,Oe=(o==null?void 0:o.is_published)||!1;if(o){const{error:qe}=await H.from("resource_kits").update(Ae).eq("id",o.id);if(qe)throw qe;Me=o.id;const ve=(q==null?void 0:q.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],dt=y.filter(Ce=>Ce.id).map(Ce=>Ce.id),pe=ve.filter(Ce=>!dt.includes(Ce));pe.length>0&&await H.from("resource_kit_files").delete().in("id",pe);const Ue=($==null?void 0:$.filter(Ce=>Ce.kit_id===o.id).map(Ce=>Ce.id))||[],Xe=w.filter(Ce=>Ce.id).map(Ce=>Ce.id),et=Ue.filter(Ce=>!Xe.includes(Ce));et.length>0&&await H.from("resource_kit_links").delete().in("id",et)}else{const{data:qe,error:ve}=await H.from("resource_kits").insert(Ae).select().single();if(ve)throw ve;Me=qe.id}for(let qe=0;qe0){const{error:qe}=await H.from("resource_kit_templates").insert(N.map(ve=>({kit_id:Me,template_id:ve})));if(qe)throw qe}return{kitId:Me,kitName:i.name,isNewKit:ke,wasPublished:Oe,isPublished:i.is_published}},onSuccess:Ee=>{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"),Ee.isPublished&&(Ee.isNewKit||!Ee.wasPublished)&&GVt(Ee.kitName,Ee.kitId),a(!1),z()},onError:Ee=>{me.error("Failed to save resource kit: "+Ee.message)}}),xe=Tt({mutationFn:async Ee=>{const{error:Ae}=await H.from("resource_kits").delete().eq("id",Ee);if(Ae)throw Ae},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Ee=>{me.error("Failed to delete: "+Ee.message)}}),ue=Ee=>{if(Ee.preventDefault(),!i.name){me.error("Please enter a name");return}he.mutate()},ge=Ee=>(q==null?void 0:q.filter(Ae=>Ae.kit_id===Ee).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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(P==null?void 0:P.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(P==null?void 0:P.filter(Ee=>Ee.is_published).length)||0})})]})]}),e.jsxs(G,{onClick:()=>{z(),a(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Files"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:O?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(P==null?void 0:P.length)===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):P==null?void 0:P.map(Ee=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ee.featured_image_url?e.jsx("img",{src:Ee.featured_image_url,alt:Ee.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Al,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ee.name}),Ee.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ee.description})]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),ge(Ee.id)]})}),e.jsx(ut,{children:ds(new Date(Ee.publish_date),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ee.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ee.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{const Ae=(q==null?void 0:q.filter(ke=>ke.kit_id===Ee.id))||[],Me=($==null?void 0:$.filter(ke=>ke.kit_id===Ee.id))||[];I({...Ee,files:Ae,links:Me})},children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>V(Ee),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&xe.mutate(Ee.id)},children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},Ee.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(js,{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(ye,{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(Al,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Le,{type:"file",accept:"image/*",onChange:X})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(Le,{id:"name",value:i.name,onChange:Ee=>c({...i,name:Ee.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:i.description,onChange:Ee=>c({...i,description:Ee}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ee=>c({...i,publish_date:Ee.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:i.is_published,onCheckedChange:Ee=>c({...i,is_published:Ee})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ye,{children:"Resource Files"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:Y,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),y.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:y.map((Ee,Ae)=>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 ",Ae+1]}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>J(Ae),children:e.jsx(Er,{className:"h-4 w-4"})})]}),e.jsx(Le,{placeholder:"File name (e.g., Getting Started Guide)",value:Ee.name,onChange:Me=>Q(Ae,"name",Me.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"file",onChange:Me=>oe(Ae,Me),className:"flex-1"}),Ee.file_url&&!Ee.file&&e.jsx("a",{href:Ee.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ee.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Ae))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ye,{children:"Canva Links"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Ee,Ae)=>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 ",Ae+1]}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ne(Ae),children:e.jsx(Er,{className:"h-4 w-4"})})]}),e.jsx(Le,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ee.title,onChange:Me=>re(Ae,"title",Me.target.value)}),e.jsx(Le,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ee.canva_share_link,onChange:Me=>re(Ae,"canva_share_link",Me.target.value)})]},Ae))})]}),e.jsx(Ftt,{selectedTemplateIds:N,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(js,{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,")"]}),((Be=M==null?void 0:M.files)==null?void 0:Be.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:(Se=M==null?void 0:M.files)==null?void 0:Se.map(Ee=>e.jsxs("a",{href:Ee.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(wn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ee.name})]},Ee.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(Ee=>e.jsxs("a",{href:Ee.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Uo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ee.title})]},Ee.id))})]})]})]})})]})})}const eHt=()=>{const{user:t}=Fs(),{toast:s}=Ra(),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,m]=k.useState(null),[f,g]=k.useState(""),{data:y=[],isLoading:_}=pt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:$,error:z}=await H.from("social_swag").select("*").order("publish_date",{ascending:!1});if(z)throw z;const{data:V,error:X}=await H.from("social_swag_links").select("*").order("sort_order");if(X)throw X;return $.map(J=>({...J,links:(V==null?void 0:V.filter(Q=>Q.swag_id===J.id))||[]}))}}),w=Tt({mutationFn:async $=>{let z=$.existingImageUrl;if($.image){const ce=$.image.name.split(".").pop(),ne=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:re}=await H.storage.from("template-previews").upload(ne,$.image);if(re)throw re;const{data:oe}=H.storage.from("template-previews").getPublicUrl(ne);z=oe.publicUrl}const V={title:$.item.title,description:$.item.description||null,preview_image_url:z,publish_date:$.item.publish_date?new Date($.item.publish_date).toISOString():new Date().toISOString(),is_published:$.item.is_published,created_by:t==null?void 0:t.id};let X=$.itemId;const Y=!X,J=(o==null?void 0:o.is_published)||!1;if(X){const{error:ce}=await H.from("social_swag").update(V).eq("id",X);if(ce)throw ce;await H.from("social_swag_links").delete().eq("swag_id",X)}else{const{data:ce,error:ne}=await H.from("social_swag").insert(V).select().single();if(ne)throw ne;X=ce.id}const Q=$.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(Q.length>0){const ce=Q.map((re,oe)=>({swag_id:X,title:re.title.trim(),canva_share_link:re.canva_share_link.trim(),sort_order:oe})),{error:ne}=await H.from("social_swag_links").insert(ce);if(ne)throw ne}return{itemId:X,itemTitle:$.item.title,isNewItem:Y,wasPublished:J,isPublished:$.item.is_published}},onSuccess:$=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),$.isPublished&&($.isNewItem||!$.wasPublished)&&bbe($.itemTitle,$.itemId),a(!1),N()},onError:$=>{s({title:"Error saving item",description:$.message,variant:"destructive"})}}),j=Tt({mutationFn:async $=>{const{error:z}=await H.from("social_swag").delete().eq("id",$);if(z)throw z},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:$=>{s({title:"Error deleting item",description:$.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}]}),m(null),g(""),l(null)},S=$=>{l($),c({title:$.title,description:$.description||"",publish_date:$.publish_date?new Date($.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:$.is_published,links:$.links&&$.links.length>0?$.links.map(z=>({id:z.id,title:z.title,canva_share_link:z.canva_share_link,sort_order:z.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),g($.preview_image_url||""),a(!0)},M=$=>{var V;const z=(V=$.target.files)==null?void 0:V[0];z&&(m(z),g(URL.createObjectURL(z)))},I=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},P=$=>{if(i.links.length<=1)return;const z=i.links.filter((V,X)=>X!==$);c({...i,links:z})},O=($,z,V)=>{const X=[...i.links];X[$]={...X[$],[z]:V},c({...i,links:X})},q=$=>{if($.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ms,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:y.length})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:y.filter($=>$.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:$=>{a($),$||N()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:i.title,onChange:$=>c({...i,title:$.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:i.description,onChange:$=>c({...i,description:$}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:i.publish_date,onChange:$=>c({...i,publish_date:$.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:$=>c({...i,is_published:$})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(G,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{m(null),g("")},children:e.jsx(Er,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(bl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Le,{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(ye,{children:"Canva Links"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map(($,z)=>e.jsx(Pe,{children:e.jsxs(De,{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 ",z+1]}),i.links.length>1&&e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>P(z),children:e.jsx(Er,{className:"h-3 w-3"})})]}),e.jsx(Le,{placeholder:"Link title (e.g., Instagram Post)",value:$.title,onChange:V=>O(z,"title",V.target.value)}),e.jsx(Le,{placeholder:"Canva share link",value:$.canva_share_link,onChange:V=>O(z,"canva_share_link",V.target.value)})]})},z))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{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"})}):y.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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Links"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:y.map($=>{var z;return e.jsxs(ks,{children:[e.jsx(ut,{children:$.preview_image_url?e.jsx("img",{src:$.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(bl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(ut,{className:"font-medium",children:$.title}),e.jsxs(ut,{children:[((z=$.links)==null?void 0:z.length)||0," links"]}),e.jsx(ut,{children:new Date($.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(Ye,{variant:$.is_published?"default":"secondary",children:$.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${$.id}`,"_blank"),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>S($),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&j.mutate($.id)},children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},$.id)})})]})})})]})})};function tHt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const ihe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function CE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Jke(t){return"nodeType"in t}function Lp(t){var s,r;return t?CE(t)?t:Jke(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function e4e(t){const{Document:s}=Lp(t);return t instanceof s}function fR(t){return CE(t)?!1:t instanceof Lp(t).HTMLElement}function ztt(t){return t instanceof Lp(t).SVGElement}function ME(t){return t?CE(t)?t.document:Jke(t)?e4e(t)?t:fR(t)||ztt(t)?t.ownerDocument:document:document:document}const z0=ihe?k.useLayoutEffect:k.useEffect;function t4e(t){const s=k.useRef(t);return z0(()=>{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 RD(t,s){s===void 0&&(s=[t]);const r=k.useRef(t);return z0(()=>{r.current!==t&&(r.current=t)},s),r}function xR(t,s){const r=k.useRef();return k.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function ece(t){const s=t4e(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 _be(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Yge={};function gR(t,s){return k.useMemo(()=>{if(s)return s;const r=Yge[t]==null?0:Yge[t]+1;return Yge[t]=r,t+"-"+r},[t,s])}function Btt(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 m=o[c];m!=null&&(o[c]=m+t*u)}return o},{...s})}}const vT=Btt(1),FD=Btt(-1);function rHt(t){return"clientX"in t&&"clientY"in t}function s4e(t){if(!t)return!1;const{KeyboardEvent:s}=Lp(t.target);return s&&t instanceof s}function nHt(t){if(!t)return!1;const{TouchEvent:s}=Lp(t.target);return s&&t instanceof s}function wbe(t){if(nHt(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 rHt(t)?{x:t.clientX,y:t.clientY}:null}const u3=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[u3.Translate.toString(t),u3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),F8e="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function aHt(t){return t.matches(F8e)?t:t.querySelector(F8e)}const iHt={display:"none"};function oHt(t){let{id:s,value:r}=t;return mt.createElement("div",{id:s,style:iHt},r)}function lHt(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 mt.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function cHt(){const[t,s]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const $tt=k.createContext(null);function dHt(t){const s=k.useContext($tt);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function uHt(){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 hHt={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. `},mHt={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 pHt(t){let{announcements:s=mHt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=hHt}=t;const{announce:o,announcement:l}=cHt(),i=gR("DndLiveRegion"),[c,u]=k.useState(!1);if(k.useEffect(()=>{u(!0)},[]),dHt(k.useMemo(()=>({onDragStart(f){let{active:g}=f;o(s.onDragStart({active:g}))},onDragMove(f){let{active:g,over:y}=f;s.onDragMove&&o(s.onDragMove({active:g,over:y}))},onDragOver(f){let{active:g,over:y}=f;o(s.onDragOver({active:g,over:y}))},onDragEnd(f){let{active:g,over:y}=f;o(s.onDragEnd({active:g,over:y}))},onDragCancel(f){let{active:g,over:y}=f;o(s.onDragCancel({active:g,over:y}))}}),[o,s])),!c)return null;const m=mt.createElement(mt.Fragment,null,mt.createElement(oHt,{id:n,value:a.draggable}),mt.createElement(lHt,{id:i,announcement:l}));return r?vp.createPortal(m,r):m}var wu;(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"})(wu||(wu={}));function tce(){}function sce(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function r4e(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const my=Object.freeze({x:0,y:0});function qtt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Utt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function fHt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function z8e(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 Vtt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function B8e(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 n4e=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=B8e(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=qtt(B8e(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(Utt)},xHt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=z8e(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=z8e(c),m=a.reduce((g,y,_)=>g+qtt(u[_],y),0),f=Number((m/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(Utt)};function gHt(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=gHt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(fHt)};function vHt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Htt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:my}function bHt(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 _Ht=bHt(1);function wHt(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 jHt(t,s,r){const n=wHt(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)),m=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:m,height:f,top:u,right:c+m,bottom:u+f,left:c}}const NHt={ignoreTransform:!1};function TE(t,s){s===void 0&&(s=NHt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:m}=Lp(t).getComputedStyle(t);u&&(r=jHt(r,u,m))}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 $8e(t){return TE(t,{ignoreTransform:!0})}function kHt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function SHt(t,s){return s===void 0&&(s=Lp(t).getComputedStyle(t)),s.position==="fixed"}function CHt(t,s){s===void 0&&(s=Lp(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 ohe(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(e4e(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!fR(a)||ztt(a)||r.includes(a))return r;const o=Lp(t).getComputedStyle(a);return a!==t&&CHt(a,o)&&r.push(a),SHt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Gtt(t){const[s]=ohe(t,1);return s??null}function Qge(t){return!ihe||!t?null:CE(t)?t:Jke(t)?e4e(t)||t===ME(t).scrollingElement?window:fR(t)?t:null:null}function Wtt(t){return CE(t)?t.scrollX:t.scrollLeft}function Ktt(t){return CE(t)?t.scrollY:t.scrollTop}function jbe(t){return{x:Wtt(t),y:Ktt(t)}}var Yu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Yu||(Yu={}));function Ztt(t){return!ihe||!t?!1:t===document.scrollingElement}function Ytt(t){const s={x:0,y:0},r=Ztt(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 MHt={x:.2,y:.2};function THt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=MHt);const{isTop:u,isBottom:m,isLeft:f,isRight:g}=Ytt(t),y={x:0,y:0},_={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+w.height?(y.y=Yu.Backward,_.y=n*Math.abs((s.top+w.height-o)/w.height)):!m&&c>=s.bottom-w.height&&(y.y=Yu.Forward,_.y=n*Math.abs((s.bottom-w.height-c)/w.height)),!g&&i>=s.right-w.width?(y.x=Yu.Forward,_.x=n*Math.abs((s.right-w.width-i)/w.width)):!f&&l<=s.left+w.width&&(y.x=Yu.Backward,_.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:y,speed:_}}function AHt(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 Qtt(t){return t.reduce((s,r)=>vT(s,jbe(r)),my)}function EHt(t){return t.reduce((s,r)=>s+Wtt(r),0)}function PHt(t){return t.reduce((s,r)=>s+Ktt(r),0)}function IHt(t,s){if(s===void 0&&(s=TE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);Gtt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const LHt=[["x",["left","right"],EHt],["y",["top","bottom"],PHt]];class a4e{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=ohe(r),a=Qtt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of LHt)for(const c of l)Object.defineProperty(this,c,{get:()=>{const u=i(n),m=a[o]-u;return this.rect[c]+m},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class C8{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 DHt(t){const{EventTarget:s}=Lp(t);return t instanceof s?t:ME(t)}function Xge(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 xx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(xx||(xx={}));function q8e(t){t.preventDefault()}function OHt(t){t.stopPropagation()}var Po;(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"})(Po||(Po={}));const Xtt={start:[Po.Space,Po.Enter],cancel:[Po.Esc],end:[Po.Space,Po.Enter,Po.Tab]},RHt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case Po.Right:return{...r,x:r.x+25};case Po.Left:return{...r,x:r.x-25};case Po.Down:return{...r,y:r.y+25};case Po.Up:return{...r,y:r.y-25}}};class i4e{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 C8(ME(r)),this.windowListeners=new C8(Lp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(xx.Resize,this.handleCancel),this.windowListeners.add(xx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(xx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&IHt(n),r(my)}handleKeyDown(s){if(s4e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Xtt,coordinateGetter:l=RHt,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,m=u?{x:u.left,y:u.top}:my;this.referenceCoordinates||(this.referenceCoordinates=m);const f=l(s,{active:r,context:n.current,currentCoordinates:m});if(f){const g=FD(f,m),y={x:0,y:0},{scrollableAncestors:_}=n.current;for(const w of _){const j=s.code,{isTop:N,isRight:S,isLeft:M,isBottom:I,maxScroll:P,minScroll:O}=Ytt(w),q=AHt(w),$={x:Math.min(j===Po.Right?q.right-q.width/2:q.right,Math.max(j===Po.Right?q.left:q.left+q.width/2,f.x)),y:Math.min(j===Po.Down?q.bottom-q.height/2:q.bottom,Math.max(j===Po.Down?q.top:q.top+q.height/2,f.y))},z=j===Po.Right&&!S||j===Po.Left&&!M,V=j===Po.Down&&!I||j===Po.Up&&!N;if(z&&$.x!==f.x){const X=w.scrollLeft+g.x,Y=j===Po.Right&&X<=P.x||j===Po.Left&&X>=O.x;if(Y&&!g.y){w.scrollTo({left:X,behavior:i});return}Y?y.x=w.scrollLeft-X:y.x=j===Po.Right?w.scrollLeft-P.x:w.scrollLeft-O.x,y.x&&w.scrollBy({left:-y.x,behavior:i});break}else if(V&&$.y!==f.y){const X=w.scrollTop+g.y,Y=j===Po.Down&&X<=P.y||j===Po.Up&&X>=O.y;if(Y&&!g.x){w.scrollTo({top:X,behavior:i});return}Y?y.y=w.scrollTop-X:y.y=j===Po.Down?w.scrollTop-P.y:w.scrollTop-O.y,y.y&&w.scrollBy({top:-y.y,behavior:i});break}}this.handleMove(s,vT(FD(f,this.referenceCoordinates),y))}}}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()}}i4e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Xtt,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 U8e(t){return!!(t&&"distance"in t)}function V8e(t){return!!(t&&"delay"in t)}class o4e{constructor(s,r,n){var a;n===void 0&&(n=DHt(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=ME(l),this.documentListeners=new C8(this.document),this.listeners=new C8(n),this.windowListeners=new C8(Lp(l)),this.initialCoordinates=(a=wbe(o))!=null?a:my,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(xx.Resize,this.handleCancel),this.windowListeners.add(xx.DragStart,q8e),this.windowListeners.add(xx.VisibilityChange,this.handleCancel),this.windowListeners.add(xx.ContextMenu,q8e),this.documentListeners.add(xx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(V8e(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(U8e(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(xx.Click,OHt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(xx.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=wbe(s))!=null?r:my,u=FD(a,c);if(!n&&i){if(U8e(i)){if(i.tolerance!=null&&Xge(u,i.tolerance))return this.handleCancel();if(Xge(u,i.distance))return this.handleStart()}if(V8e(i)&&Xge(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===Po.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const FHt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class yR extends o4e{constructor(s){const{event:r}=s,n=ME(r.target);super(s,FHt,n)}}yR.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 zHt={move:{name:"mousemove"},end:{name:"mouseup"}};var Nbe;(function(t){t[t.RightClick=2]="RightClick"})(Nbe||(Nbe={}));class BHt extends o4e{constructor(s){super(s,zHt,ME(s.event.target))}}BHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===Nbe.RightClick?!1:(n==null||n({event:r}),!0)}}];const Jge={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class $Ht extends o4e{constructor(s){super(s,Jge)}static setup(){return window.addEventListener(Jge.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Jge.move.name,s)};function s(){}}}$Ht.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 M8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(M8||(M8={}));var rce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(rce||(rce={}));function qHt(t){let{acceleration:s,activator:r=M8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=rce.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:m,delta:f,threshold:g}=t;const y=VHt({delta:f,disabled:!o}),[_,w]=sHt(),j=k.useRef({x:0,y:0}),N=k.useRef({x:0,y:0}),S=k.useMemo(()=>{switch(r){case M8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case M8.DraggableRect:return a}},[r,a,c]),M=k.useRef(null),I=k.useCallback(()=>{const O=M.current;if(!O)return;const q=j.current.x*N.current.x,$=j.current.y*N.current.y;O.scrollBy(q,$)},[]),P=k.useMemo(()=>i===rce.TreeOrder?[...u].reverse():u,[i,u]);k.useEffect(()=>{if(!o||!u.length||!S){w();return}for(const O of P){if((n==null?void 0:n(O))===!1)continue;const q=u.indexOf(O),$=m[q];if(!$)continue;const{direction:z,speed:V}=THt(O,$,S,s,g);for(const X of["x","y"])y[X][z[X]]||(V[X]=0,z[X]=0);if(V.x>0||V.y>0){w(),M.current=O,_(I,l),j.current=V,N.current=z;return}}j.current={x:0,y:0},N.current={x:0,y:0},w()},[s,I,n,w,o,l,JSON.stringify(S),JSON.stringify(y),_,u,P,m,JSON.stringify(g)])}const UHt={x:{[Yu.Backward]:!1,[Yu.Forward]:!1},y:{[Yu.Backward]:!1,[Yu.Forward]:!1}};function VHt(t){let{delta:s,disabled:r}=t;const n=_be(s);return xR(a=>{if(r||!n||!a)return UHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Yu.Backward]:a.x[Yu.Backward]||o.x===-1,[Yu.Forward]:a.x[Yu.Forward]||o.x===1},y:{[Yu.Backward]:a.y[Yu.Backward]||o.y===-1,[Yu.Forward]:a.y[Yu.Forward]||o.y===1}}},[r,s,n])}function HHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return xR(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function GHt(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 zD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(zD||(zD={}));var kbe;(function(t){t.Optimized="optimized"})(kbe||(kbe={}));const H8e=new Map;function WHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=k.useState(null),{frequency:i,measure:c,strategy:u}=a,m=k.useRef(t),f=j(),g=RD(f),y=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),w=xR(N=>{if(f&&!r)return H8e;if(!N||N===H8e||m.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 I=M.node.current,P=I?new a4e(c(I),I):null;M.rect.current=P,P&&S.set(M.id,P)}return S}return N},[t,o,r,f,c]);return k.useEffect(()=>{m.current=t},[t]),k.useEffect(()=>{f||y()},[r,f]),k.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),k.useEffect(()=>{f||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{y(),_.current=null},i))},[i,f,y,...n]),{droppableRects:w,measureDroppableContainers:y,measuringScheduled:o!=null};function j(){switch(u){case zD.Always:return!1;case zD.BeforeDragging:return r;default:return!r}}}function Jtt(t,s){return xR(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function KHt(t,s){return Jtt(t,s)}function ZHt(t){let{callback:s,disabled:r}=t;const n=t4e(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 lhe(t){let{callback:s,disabled:r}=t;const n=t4e(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 YHt(t){return new a4e(TE(t),t)}function G8e(t,s,r){s===void 0&&(s=YHt);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 m=s(t);return JSON.stringify(c)===JSON.stringify(m)?c:m})}const l=ZHt({callback(c){if(t)for(const u of c){const{type:m,target:f}=u;if(m==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=lhe({callback:o});return z0(()=>{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 QHt(t){const s=Jtt(t);return Htt(t,s)}const W8e=[];function XHt(t){const s=k.useRef(t),r=xR(n=>t?n&&n!==W8e&&t&&s.current&&t.parentNode===s.current.parentNode?n:ohe(t):W8e,[t]);return k.useEffect(()=>{s.current=t},[t]),r}function JHt(t){const[s,r]=k.useState(null),n=k.useRef(t),a=k.useCallback(o=>{const l=Qge(o.target);l&&r(i=>i?(i.set(l,jbe(l)),new Map(i)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=Qge(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,jbe(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=Qge(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>vT(o,l),my):Qtt(t):my,[t,s])}function K8e(t,s){s===void 0&&(s=[]);const r=k.useRef(null);return k.useEffect(()=>{r.current=null},s),k.useEffect(()=>{const n=t!==my;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?FD(t,r.current):my}function eGt(t){k.useEffect(()=>{if(!ihe)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 tGt(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 est(t){return k.useMemo(()=>t?kHt(t):null,[t])}const Z8e=[];function sGt(t,s){s===void 0&&(s=TE);const[r]=t,n=est(r?Lp(r):null),[a,o]=k.useState(Z8e);function l(){o(()=>t.length?t.map(c=>Ztt(c)?n:new a4e(s(c),c)):Z8e)}const i=lhe({callback:l});return z0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function rGt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return fR(s)?s:t}function nGt(t){let{measure:s}=t;const[r,n]=k.useState(null),a=k.useCallback(u=>{for(const{target:m}of u)if(fR(m)){n(f=>{const g=s(m);return f?{...f,width:g.width,height:g.height}:g});break}},[s]),o=lhe({callback:a}),l=k.useCallback(u=>{const m=rGt(u);o==null||o.disconnect(),m&&(o==null||o.observe(m)),n(m?s(m):null)},[s,o]),[i,c]=ece(l);return k.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const aGt=[{sensor:yR,options:{}},{sensor:i4e,options:{}}],iGt={current:{}},Vie={draggable:{measure:$8e},droppable:{measure:$8e,strategy:zD.WhileDragging,frequency:kbe.Optimized},dragOverlay:{measure:TE}};class T8 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 oGt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new T8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:tce},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Vie,measureDroppableContainers:tce,windowRect:null,measuringScheduled:!1},lGt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:tce,draggableNodes:new Map,over:null,measureDroppableContainers:tce},che=k.createContext(lGt),tst=k.createContext(oGt);function cGt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new T8}}}function dGt(t,s){switch(s.type){case wu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case wu.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 wu.DragEnd:case wu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new T8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case wu.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 T8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case wu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new T8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function uGt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=k.useContext(che),o=_be(n),l=_be(r==null?void 0:r.id);return k.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!s4e(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 m of[c.current,u.current]){if(!m)continue;const f=aHt(m);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function hGt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function mGt(t){return k.useMemo(()=>({draggable:{...Vie.draggable,...t==null?void 0:t.draggable},droppable:{...Vie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Vie.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 pGt(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;z0(()=>{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 m=r(u),f=Htt(m,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=Gtt(u);g&&g.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const sst=k.createContext({...my,scaleX:1,scaleY:1});var o_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(o_||(o_={}));const l4e=k.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:m=aGt,collisionDetection:f=yHt,measuring:g,modifiers:y,..._}=s;const w=k.useReducer(dGt,void 0,cGt),[j,N]=w,[S,M]=uHt(),[I,P]=k.useState(o_.Uninitialized),O=I===o_.Initialized,{draggable:{active:q,nodes:$,translate:z},droppable:{containers:V}}=j,X=q!=null?$.get(q):null,Y=k.useRef({initial:null,translated:null}),J=k.useMemo(()=>{var Ln;return q!=null?{id:q,data:(Ln=X==null?void 0:X.data)!=null?Ln:iGt,rect:Y}:null},[q,X]),Q=k.useRef(null),[ce,ne]=k.useState(null),[re,oe]=k.useState(null),he=RD(_,Object.values(_)),xe=gR("DndDescribedBy",l),ue=k.useMemo(()=>V.getEnabled(),[V]),ge=mGt(g),{droppableRects:_e,measureDroppableContainers:Be,measuringScheduled:Se}=WHt(ue,{dragging:O,dependencies:[z.x,z.y],config:ge.droppable}),Ee=HHt($,q),Ae=k.useMemo(()=>re?wbe(re):null,[re]),Me=na(),ke=KHt(Ee,ge.draggable.measure);pGt({activeNode:q!=null?$.get(q):null,config:Me.layoutShiftCompensation,initialRect:ke,measure:ge.draggable.measure});const Oe=G8e(Ee,ge.draggable.measure,ke),qe=G8e(Ee?Ee.parentElement:null),ve=k.useRef({activatorEvent:null,active:null,activeNode:Ee,collisionRect:null,collisions:null,droppableRects:_e,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),dt=V.getNodeFor((r=ve.current.over)==null?void 0:r.id),pe=nGt({measure:ge.dragOverlay.measure}),Ue=(n=pe.nodeRef.current)!=null?n:Ee,Xe=O?(a=pe.rect)!=null?a:Oe:null,et=!!(pe.nodeRef.current&&pe.rect),Ce=QHt(et?null:Oe),Je=est(Ue?Lp(Ue):null),Ge=XHt(O?dt??Ee:null),lt=sGt(Ge),He=hGt(y,{transform:{x:z.x-Ce.x,y:z.y-Ce.y,scaleX:1,scaleY:1},activatorEvent:re,active:J,activeNodeRect:Oe,containerNodeRect:qe,draggingNodeRect:Xe,over:ve.current.over,overlayNodeRect:pe.rect,scrollableAncestors:Ge,scrollableAncestorRects:lt,windowRect:Je}),We=Ae?vT(Ae,z):null,tt=JHt(Ge),Ke=K8e(tt),rt=K8e(tt,[Oe]),it=vT(He,Ke),It=Xe?_Ht(Xe,He):null,Vt=J&&It?f({active:J,collisionRect:It,droppableRects:_e,droppableContainers:ue,pointerCoordinates:We}):null,hs=Vtt(Vt,"id"),[Es,Ts]=k.useState(null),cr=et?He:vT(He,rt),zr=vHt(cr,(o=Es==null?void 0:Es.rect)!=null?o:null,Oe),Ft=k.useRef(null),Ps=k.useCallback((Ln,tr)=>{let{sensor:dr,options:Sr}=tr;if(Q.current==null)return;const dn=$.get(Q.current);if(!dn)return;const Yr=Ln.nativeEvent,ui=new dr({active:Q.current,activeNode:dn,event:Yr,options:Sr,context:ve,onAbort(Wt){if(!$.get(Wt))return;const{onDragAbort:Mr}=he.current,xr={id:Wt};Mr==null||Mr(xr),S({type:"onDragAbort",event:xr})},onPending(Wt,Hr,Mr,xr){if(!$.get(Wt))return;const{onDragPending:ai}=he.current,Aa={id:Wt,constraint:Hr,initialCoordinates:Mr,offset:xr};ai==null||ai(Aa),S({type:"onDragPending",event:Aa})},onStart(Wt){const Hr=Q.current;if(Hr==null)return;const Mr=$.get(Hr);if(!Mr)return;const{onDragStart:xr}=he.current,Wn={activatorEvent:Yr,active:{id:Hr,data:Mr.data,rect:Y}};vp.unstable_batchedUpdates(()=>{xr==null||xr(Wn),P(o_.Initializing),N({type:wu.DragStart,initialCoordinates:Wt,active:Hr}),S({type:"onDragStart",event:Wn}),ne(Ft.current),oe(Yr)})},onMove(Wt){N({type:wu.DragMove,coordinates:Wt})},onEnd:ns(wu.DragEnd),onCancel:ns(wu.DragCancel)});Ft.current=ui;function ns(Wt){return async function(){const{active:Mr,collisions:xr,over:Wn,scrollAdjustedTranslate:ai}=ve.current;let Aa=null;if(Mr&&ai){const{cancelDrop:no}=he.current;Aa={activatorEvent:Yr,active:Mr,collisions:xr,delta:ai,over:Wn},Wt===wu.DragEnd&&typeof no=="function"&&await Promise.resolve(no(Aa))&&(Wt=wu.DragCancel)}Q.current=null,vp.unstable_batchedUpdates(()=>{N({type:Wt}),P(o_.Uninitialized),Ts(null),ne(null),oe(null),Ft.current=null;const no=Wt===wu.DragEnd?"onDragEnd":"onDragCancel";if(Aa){const $t=he.current[no];$t==null||$t(Aa),S({type:no,event:Aa})}})}}},[$]),yr=k.useCallback((Ln,tr)=>(dr,Sr)=>{const dn=dr.nativeEvent,Yr=$.get(Sr);if(Q.current!==null||!Yr||dn.dndKit||dn.defaultPrevented)return;const ui={active:Yr};Ln(dr,tr.options,ui)===!0&&(dn.dndKit={capturedBy:tr.sensor},Q.current=Sr,Ps(dr,tr))},[$,Ps]),Is=GHt(m,yr);eGt(m),z0(()=>{Oe&&I===o_.Initializing&&P(o_.Initialized)},[Oe,I]),k.useEffect(()=>{const{onDragMove:Ln}=he.current,{active:tr,activatorEvent:dr,collisions:Sr,over:dn}=ve.current;if(!tr||!dr)return;const Yr={active:tr,activatorEvent:dr,collisions:Sr,delta:{x:it.x,y:it.y},over:dn};vp.unstable_batchedUpdates(()=>{Ln==null||Ln(Yr),S({type:"onDragMove",event:Yr})})},[it.x,it.y]),k.useEffect(()=>{const{active:Ln,activatorEvent:tr,collisions:dr,droppableContainers:Sr,scrollAdjustedTranslate:dn}=ve.current;if(!Ln||Q.current==null||!tr||!dn)return;const{onDragOver:Yr}=he.current,ui=Sr.get(hs),ns=ui&&ui.rect.current?{id:ui.id,rect:ui.rect.current,data:ui.data,disabled:ui.disabled}:null,Wt={active:Ln,activatorEvent:tr,collisions:dr,delta:{x:dn.x,y:dn.y},over:ns};vp.unstable_batchedUpdates(()=>{Ts(ns),Yr==null||Yr(Wt),S({type:"onDragOver",event:Wt})})},[hs]),z0(()=>{ve.current={activatorEvent:re,active:J,activeNode:Ee,collisionRect:It,collisions:Vt,droppableRects:_e,draggableNodes:$,draggingNode:Ue,draggingNodeRect:Xe,droppableContainers:V,over:Es,scrollableAncestors:Ge,scrollAdjustedTranslate:it},Y.current={initial:Xe,translated:It}},[J,Ee,Vt,It,$,Ue,Xe,_e,V,Es,Ge,it]),qHt({...Me,delta:z,draggingRect:It,pointerCoordinates:We,scrollableAncestors:Ge,scrollableAncestorRects:lt});const Ar=k.useMemo(()=>({active:J,activeNode:Ee,activeNodeRect:Oe,activatorEvent:re,collisions:Vt,containerNodeRect:qe,dragOverlay:pe,draggableNodes:$,droppableContainers:V,droppableRects:_e,over:Es,measureDroppableContainers:Be,scrollableAncestors:Ge,scrollableAncestorRects:lt,measuringConfiguration:ge,measuringScheduled:Se,windowRect:Je}),[J,Ee,Oe,re,Vt,qe,pe,$,V,_e,Es,Be,Ge,lt,ge,Se,Je]),tn=k.useMemo(()=>({activatorEvent:re,activators:Is,active:J,activeNodeRect:Oe,ariaDescribedById:{draggable:xe},dispatch:N,draggableNodes:$,over:Es,measureDroppableContainers:Be}),[re,Is,J,Oe,N,xe,$,Es,Be]);return mt.createElement($tt.Provider,{value:M},mt.createElement(che.Provider,{value:tn},mt.createElement(tst.Provider,{value:Ar},mt.createElement(sst.Provider,{value:zr},u)),mt.createElement(uGt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),mt.createElement(pHt,{...i,hiddenTextDescribedById:xe}));function na(){const Ln=(ce==null?void 0:ce.autoScrollEnabled)===!1,tr=typeof c=="object"?c.enabled===!1:c===!1,dr=O&&!Ln&&!tr;return typeof c=="object"?{...c,enabled:dr}:{enabled:dr}}}),fGt=k.createContext(null),Y8e="button",xGt="Draggable";function gGt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=gR(xGt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:m,draggableNodes:f,over:g}=k.useContext(che),{role:y=Y8e,roleDescription:_="draggable",tabIndex:w=0}=a??{},j=(c==null?void 0:c.id)===s,N=k.useContext(j?sst:fGt),[S,M]=ece(),[I,P]=ece(),O=tGt(l,s),q=RD(r);z0(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:I,data:q}),()=>{const z=f.get(s);z&&z.key===o&&f.delete(s)}),[f,s]);const $=k.useMemo(()=>({role:y,tabIndex:w,"aria-disabled":n,"aria-pressed":j&&y===Y8e?!0:void 0,"aria-roledescription":_,"aria-describedby":m.draggable}),[n,y,w,j,_,m.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:$,isDragging:j,listeners:n?void 0:O,node:S,over:g,setNodeRef:M,setActivatorNodeRef:P,transform:N}}function yGt(){return k.useContext(tst)}const vGt="Droppable",bGt={timeout:25};function _Gt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=gR(vGt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=k.useContext(che),m=k.useRef({disabled:r}),f=k.useRef(!1),g=k.useRef(null),y=k.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:j}={...bGt,...a},N=RD(w??n),S=k.useCallback(()=>{if(!f.current){f.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),y.current=null},j)},[j]),M=lhe({callback:S,disabled:_||!l}),I=k.useCallback(($,z)=>{M&&(z&&(M.unobserve(z),f.current=!1),$&&M.observe($))},[M]),[P,O]=ece(I),q=RD(s);return k.useEffect(()=>{!M||!P.current||(M.disconnect(),f.current=!1,M.observe(P.current))},[P,M]),k.useEffect(()=>(i({type:wu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:P,rect:g,data:q}}),()=>i({type:wu.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{r!==m.current.disabled&&(i({type:wu.SetDroppableDisabled,id:n,key:o,disabled:r}),m.current.disabled=r)},[n,o,r,i]),{active:l,rect:g,isOver:(c==null?void 0:c.id)===n,node:P,over:c,setNodeRef:O}}function c4e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function wGt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Hz(t){return t!==null&&t>=0}function jGt(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=kGt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...Gz}:l=o?{x:i.width+c,y:0,...Gz}:{x:0,y:0,...Gz}};function kGt(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=c4e(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}},Wz={scaleX:1,scaleY:1},dEs=t=>{var s;let{activeIndex:r,activeNodeRect:n,index:a,rects:o,overIndex:l}=t;const i=(s=o[r])!=null?s:n;if(!i)return null;if(a===r){const u=o[l];return u?{x:0,y:rr&&a<=l?{x:0,y:-i.height-c,...Wz}:a=l?{x:0,y:i.height+c,...Wz}:{x:0,y:0,...Wz}};function SGt(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return n?rn.map(O=>typeof O=="object"&&"id"in O?O.id:O),[n]),_=l!=null,w=l?y.indexOf(l.id):-1,j=u?y.indexOf(u.id):-1,N=k.useRef(y),S=!jGt(y,N.current),M=j!==-1&&w===-1||S,I=NGt(o);z0(()=>{S&&_&&m(y)},[S,y,_,m]),k.useEffect(()=>{N.current=y},[y]);const P=k.useMemo(()=>({activeIndex:w,containerId:f,disabled:I,disableTransforms:M,items:y,overIndex:j,useDragOverlay:g,sortedRects:wGt(y,c),strategy:a}),[w,f,I.draggable,I.droppable,M,y,j,c,g,a]);return mt.createElement(nst.Provider,{value:P},s)}const CGt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return c4e(r,n,a).indexOf(s)},MGt=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},TGt={duration:200,easing:"ease"},ast="transform",AGt=u3.Transition.toString({property:ast,duration:0,easing:"linear"}),EGt={roleDescription:"sortable"};function PGt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=k.useState(null),i=k.useRef(r);return z0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=TE(n.current,{ignoreTransform:!0}),m={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(m.x||m.y)&&l(m)}}r!==i.current&&(i.current=r)},[s,r,n,a]),k.useEffect(()=>{o&&l(null)},[o]),o}function u4e(t){let{animateLayoutChanges:s=MGt,attributes:r,disabled:n,data:a,getNewIndex:o=CGt,id:l,strategy:i,resizeObserverConfig:c,transition:u=TGt}=t;const{items:m,containerId:f,activeIndex:g,disabled:y,disableTransforms:_,sortedRects:w,overIndex:j,useDragOverlay:N,strategy:S}=k.useContext(nst),M=IGt(n,y),I=m.indexOf(l),P=k.useMemo(()=>({sortable:{containerId:f,index:I,items:m},...a}),[f,a,I,m]),O=k.useMemo(()=>m.slice(m.indexOf(l)),[m,l]),{rect:q,node:$,isOver:z,setNodeRef:V}=_Gt({id:l,data:P,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...c}}),{active:X,activatorEvent:Y,activeNodeRect:J,attributes:Q,setNodeRef:ce,listeners:ne,isDragging:re,over:oe,setActivatorNodeRef:he,transform:xe}=gGt({id:l,data:P,attributes:{...EGt,...r},disabled:M.draggable}),ue=tHt(V,ce),ge=!!X,_e=ge&&!_&&Hz(g)&&Hz(j),Be=!N&&re,Se=Be&&_e?xe:null,Ae=_e?Se??(i??S)({rects:w,activeNodeRect:J,activeIndex:g,overIndex:j,index:I}):null,Me=Hz(g)&&Hz(j)?o({id:l,items:m,activeIndex:g,overIndex:j}):I,ke=X==null?void 0:X.id,Oe=k.useRef({activeId:ke,items:m,newIndex:Me,containerId:f}),qe=m!==Oe.current.items,ve=s({active:X,containerId:f,isDragging:re,isSorting:ge,id:l,index:I,items:m,newIndex:Oe.current.newIndex,previousItems:Oe.current.items,previousContainerId:Oe.current.containerId,transition:u,wasDragging:Oe.current.activeId!=null}),dt=PGt({disabled:!ve,index:I,node:$,rect:q});return k.useEffect(()=>{ge&&Oe.current.newIndex!==Me&&(Oe.current.newIndex=Me),f!==Oe.current.containerId&&(Oe.current.containerId=f),m!==Oe.current.items&&(Oe.current.items=m)},[ge,Me,f,m]),k.useEffect(()=>{if(ke===Oe.current.activeId)return;if(ke!=null&&Oe.current.activeId==null){Oe.current.activeId=ke;return}const Ue=setTimeout(()=>{Oe.current.activeId=ke},50);return()=>clearTimeout(Ue)},[ke]),{active:X,activeIndex:g,attributes:Q,data:P,rect:q,index:I,newIndex:Me,items:m,isOver:z,isSorting:ge,isDragging:re,listeners:ne,node:$,overIndex:j,over:oe,setNodeRef:ue,setActivatorNodeRef:he,setDroppableNodeRef:V,setDraggableNodeRef:ce,transform:dt??Ae,transition:pe()};function pe(){if(dt||qe&&Oe.current.newIndex===I)return AGt;if(!(Be&&!s4e(Y)||!u)&&(ge||ve))return u3.Transition.toString({...u,property:ast})}}function IGt(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 nce(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 LGt=[Po.Down,Po.Right,Po.Up,Po.Left],DGt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(LGt.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 Po.Down:n.topg.top&&c.push(f);break;case Po.Left:n.left>g.left&&c.push(f);break;case Po.Right:n.left1&&(m=u[1].id),m!=null){const f=o.get(r.id),g=o.get(m),y=g?a.get(g.id):null,_=g==null?void 0:g.node.current;if(_&&y&&f&&g){const j=ohe(_).some((O,q)=>i[q]!==O),N=ist(f,g),S=OGt(f,g),M=j||!N?{x:0,y:0}:{x:S?n.width-y.width:0,y:S?n.height-y.height:0},I={x:y.left,y:y.top};return M.x&&M.y?I:FD(I,M)}}}};function ist(t,s){return!nce(t)||!nce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function OGt(t,s){return!nce(t)||!nce(s)||!ist(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(Ye,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(fn,{className:"h-2.5 w-2.5"}),ds(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(De,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:Pt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"h-3 w-3"}),t.post_date?ds(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs($o,{className:"w-auto p-0",align:"start",children:[e.jsx(Nf,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ds(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(G,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const FGt=()=>{const t=Qt(),[s,r]=k.useState("all"),[n,a]=k.useState(!1),[o,l]=k.useState(ds(new Date,"yyyy-MM")),[i,c]=k.useState([]),[u,m]=k.useState(!1),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(""),[N,S]=k.useState(null),[M,I]=k.useState(!1),[P,O]=k.useState(!1),[q,$]=k.useState(ds(new Date,"yyyy-MM")),[z,V]=k.useState(null),[X,Y]=k.useState(""),[J,Q]=k.useState(""),[ce,ne]=k.useState(""),[re,oe]=k.useState(!1),he=r4e(sce(yR,{activationConstraint:{distance:5}}),sce(i4e,{coordinateGetter:DGt})),{data:xe=[],isLoading:ue}=pt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:We,error:tt}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(tt)throw tt;return We}}),{data:ge=[]}=pt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:We,error:tt}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(tt)throw tt;return We}}),{data:_e=[]}=pt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:We,error:tt}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(tt)throw tt;return We}}),Be=[...new Set(xe.map(We=>We.month))].sort((We,tt)=>tt.localeCompare(We)),Se=s==="all"?xe:xe.filter(We=>We.month===s),Ee=We=>{const tt=Lje(We,"yyyy-MM",new Date);return ds(tt,"MMMM yyyy")},Ae=We=>{_(We),j(We.caption),S(We.post_date)},Me=async()=>{if(y){I(!0);try{const{error:We}=await H.from("social_swag_2").update({caption:w,post_date:N}).eq("id",y.id);if(We)throw We;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{I(!1)}}},ke=async We=>{const{active:tt,over:Ke}=We;if(!Ke||tt.id===Ke.id)return;const rt=Se,it=rt.findIndex(hs=>hs.id===tt.id),It=rt.findIndex(hs=>hs.id===Ke.id);if(it===-1||It===-1)return;const Vt=c4e(rt,it,It);t.setQueryData(["admin-social-swag-2"],hs=>{if(!hs)return hs;const Es={};return Vt.forEach((Ts,cr)=>{Es[Ts.id]=cr}),hs.map(Ts=>Es[Ts.id]!==void 0?{...Ts,sort_order:Es[Ts.id]}:Ts).sort((Ts,cr)=>Ts.month!==cr.month?cr.month.localeCompare(Ts.month):Ts.sort_order-cr.sort_order)});try{await Promise.all(Vt.map((hs,Es)=>H.from("social_swag_2").update({sort_order:Es}).eq("id",hs.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Oe=We=>{const Ke=Array.from(We.target.files||[]).sort((rt,it)=>rt.name.localeCompare(it.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(rt=>({file:rt,preview:URL.createObjectURL(rt),caption:""}));c(rt=>[...rt,...Ke].slice(0,16))},qe=We=>{c(tt=>{const Ke=[...tt];return URL.revokeObjectURL(Ke[We].preview),Ke.splice(We,1),Ke})},ve=(We,tt)=>{c(Ke=>{const rt=[...Ke];return rt[We]={...rt[We],caption:tt},rt})},dt=async()=>{var tt;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(Ke=>!Ke.caption.trim()).length>0){me.error("Please add captions to all images");return}m(!0);try{const{data:Ke}=await H.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),rt=(((tt=Ke==null?void 0:Ke[0])==null?void 0:tt.sort_order)??-1)+1;for(let it=0;it{const tt=We.image_url.split("/social-swag-2/");tt[1]&&await H.storage.from("social-swag-2").remove([tt[1]]);const{error:Ke}=await H.from("social_swag_2").delete().eq("id",We.id);if(Ke)throw Ke},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),Ue=Tt({mutationFn:async({id:We,postDate:tt})=>{const{error:Ke}=await H.from("social_swag_2").update({post_date:tt}).eq("id",We);if(Ke)throw Ke},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")}),Xe=Tt({mutationFn:async({month:We,link:tt})=>{const{error:Ke}=await H.from("social_swag_2_months").upsert({month:We,canva_link:tt||null},{onConflict:"month"});if(Ke)throw Ke},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=We=>{var tt;return((tt=ge.find(Ke=>Ke.month===We))==null?void 0:tt.canva_link)||""},Ce=We=>_e.find(tt=>tt.month===We)||null,Je=We=>{var Ke;const tt=(Ke=We.target.files)==null?void 0:Ke[0];tt&&(V(tt),Y(URL.createObjectURL(tt)))},Ge=()=>{X&&URL.revokeObjectURL(X),V(null),Y(""),Q(""),ne("")},lt=async()=>{if(!z){me.error("Please select an image");return}oe(!0);try{const We=z.name.split(".").pop(),tt=`reels/${q}-${Date.now()}.${We}`,{error:Ke}=await H.storage.from("social-swag-2").upload(tt,z);if(Ke)throw Ke;const{data:{publicUrl:rt}}=H.storage.from("social-swag-2").getPublicUrl(tt),{error:it}=await H.from("social_swag_2_reels").upsert({month:q,image_url:rt,canva_link:ce||null,caption:J||null},{onConflict:"month"});if(it)throw it;me.success("Reel uploaded successfully!"),bbe(`${Ee(q)} Reel`,"social-swag-2"),Ge(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(We){console.error("Reel upload error:",We),me.error("Failed to upload reel")}finally{oe(!1)}},He=Tt({mutationFn:async We=>{const tt=We.image_url.split("/social-swag-2/");tt[1]&&await H.storage.from("social-swag-2").remove([tt[1]]);const{error:Ke}=await H.from("social_swag_2_reels").delete().eq("id",We.id);if(Ke)throw Ke},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(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ye,{children:"Month"}),e.jsx(Le,{type:"month",value:o,onChange:We=>l(We.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{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:Oe,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(ci,{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((We,tt)=>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:We.preview,alt:`Upload ${tt+1}`,className:"w-full h-full object-cover"}),e.jsx(G,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>qe(tt),children:e.jsx(Er,{className:"h-3 w-3"})})]}),e.jsx(Tr,{placeholder:"Caption...",value:We.caption,onChange:Ke=>ve(tt,Ke.target.value),className:"text-xs h-20"})]},tt))}),e.jsx(G,{onClick:dt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:P,onOpenChange:We=>{O(We),We||Ge()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"gap-2",children:[e.jsx(_u,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{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(ye,{children:"Month"}),e.jsx(Le,{type:"month",value:q,onChange:We=>$(We.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Reel Preview Image"}),X?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:X,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(G,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(X),V(null),Y("")},children:e.jsx(Er,{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:Je,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(_u,{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(ye,{children:"Canva Download Link"}),e.jsx(Le,{value:ce,onChange:We=>ne(We.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Caption"}),e.jsx(Tr,{value:J,onChange:We=>Q(We.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(G,{onClick:lt,disabled:re||!z,className:"w-full gap-2",children:re?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:xe.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Be.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ga,{value:s,onValueChange:r,children:e.jsxs(fa,{children:[e.jsx(ss,{value:"all",children:"All"}),Be.map(We=>e.jsx(ss,{value:We,children:Ee(We)},We))]})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Uo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ye,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ee(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Le,{value:f.link,onChange:We=>g({...f,link:We.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(G,{size:"sm",onClick:()=>Xe.mutate(f),children:"Save"}),e.jsx(G,{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(G,{size:"sm",variant:"outline",onClick:()=>g({month:s,link:et(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(_u,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ye,{className:"text-sm text-muted-foreground",children:["Reel for ",Ee(s)]}),(()=>{const We=Ce(s);return We?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:We.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:We.caption||"No caption"}),We.canva_link&&e.jsx("a",{href:We.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(G,{variant:"destructive",size:"sm",onClick:()=>He.mutate(We),children:e.jsx(kr,{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..."}):Se.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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(l4e,{sensors:he,collisionDetection:n4e,onDragEnd:ke,children:e.jsx(d4e,{items:Se.map(We=>We.id),strategy:vR,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Se.map(We=>e.jsx(RGt,{item:We,onEdit:Ae,onDelete:tt=>pe.mutate(tt),onDateChange:(tt,Ke)=>Ue.mutate({id:tt,postDate:Ke})},We.id))})})})]}),e.jsx(fs,{open:!!y,onOpenChange:We=>{We||_(null)},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(vs,{children:"Edit Image"})}),y&&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:y.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Caption"}),e.jsx(Tr,{value:w,onChange:We=>j(We.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(fn,{className:"h-4 w-4"}),N?ds(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:We=>S(We?ds(We,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Er,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>_(null),children:"Cancel"}),e.jsx(G,{onClick:Me,disabled:M,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},zGt=()=>{const{toast:t}=Ra(),s=Qt(),[r,n]=k.useState("categories"),[a,o]=k.useState(!1),[l,i]=k.useState(null),[c,u]=k.useState({name:"",description:"",icon:""}),[m,f]=k.useState(!1),[g,y]=k.useState(null),[_,w]=k.useState({name:"",description:"",icon:""}),[j,N]=k.useState(!1),[S,M]=k.useState(null),[I,P]=k.useState(""),{data:O=[],isLoading:q}=pt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:ke,error:Oe}=await H.from("community_categories").select("*").order("sort_order");if(Oe)throw Oe;return ke}}),{data:$=[],isLoading:z}=pt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:ke,error:Oe}=await H.from("community_private_groups").select("*").order("sort_order");if(Oe)throw Oe;return ke}}),{data:V=[]}=pt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:ke,error:Oe}=await H.from("community_private_group_members").select("*").eq("group_id",S.id);if(Oe)throw Oe;return ke},enabled:!!S}),{data:X=[]}=pt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Oe=[],qe=0,ve=!0;for(;ve;){const{data:dt,error:pe}=await H.from("profiles").select("id, name, email, brokerage_id").order("name").range(qe,qe+1e3-1);if(pe)throw pe;dt&&dt.length>0?(Oe=[...Oe,...dt],qe+=1e3,ve=dt.length===1e3):ve=!1}return Oe}}),{data:Y=[]}=pt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:ke,error:Oe}=await H.from("brokerages").select("*").order("name");if(Oe)throw Oe;return ke}}),J=Tt({mutationFn:async ke=>{if(ke.id){const{error:Oe}=await H.from("community_categories").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if(Oe)throw Oe}else{const Oe=Math.max(...O.map(ve=>ve.sort_order),0),{error:qe}=await H.from("community_categories").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:Oe+1});if(qe)throw qe}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),Q=Tt({mutationFn:async ke=>{const{error:Oe}=await H.from("community_categories").delete().eq("id",ke);if(Oe)throw Oe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Tt({mutationFn:async({id:ke,direction:Oe})=>{const qe=O.findIndex(ve=>ve.id===ke);if(Oe==="up"&&qe>0){const ve=O[qe-1],dt=O[qe];await H.from("community_categories").update({sort_order:dt.sort_order}).eq("id",ve.id),await H.from("community_categories").update({sort_order:ve.sort_order}).eq("id",dt.id)}else if(Oe==="down"&&qes.invalidateQueries({queryKey:["admin-community-categories"]})}),ne=Tt({mutationFn:async ke=>{if(ke.id){const{error:Oe}=await H.from("community_private_groups").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if(Oe)throw Oe}else{const Oe=Math.max(...$.map(ve=>ve.sort_order),0),{error:qe}=await H.from("community_private_groups").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:Oe+1});if(qe)throw qe}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),y(null),w({name:"",description:"",icon:""}),t({title:g?"Private group updated!":"Private group created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),re=Tt({mutationFn:async ke=>{const{error:Oe}=await H.from("community_private_groups").delete().eq("id",ke);if(Oe)throw Oe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),oe=Tt({mutationFn:async({id:ke,direction:Oe})=>{const qe=$.findIndex(ve=>ve.id===ke);if(Oe==="up"&&qe>0){const ve=$[qe-1],dt=$[qe];await H.from("community_private_groups").update({sort_order:dt.sort_order}).eq("id",ve.id),await H.from("community_private_groups").update({sort_order:ve.sort_order}).eq("id",dt.id)}else if(Oe==="down"&&qe<$.length-1){const ve=$[qe+1],dt=$[qe];await H.from("community_private_groups").update({sort_order:dt.sort_order}).eq("id",ve.id),await H.from("community_private_groups").update({sort_order:ve.sort_order}).eq("id",dt.id)}},onSuccess:()=>s.invalidateQueries({queryKey:["admin-private-groups"]})}),he=Tt({mutationFn:async({groupId:ke,userId:Oe,isMember:qe})=>{if(qe){const{error:ve}=await H.from("community_private_group_members").delete().eq("group_id",ke).eq("user_id",Oe);if(ve)throw ve}else{const{error:ve}=await H.from("community_private_group_members").insert({group_id:ke,user_id:Oe});if(ve)throw ve}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),xe=Tt({mutationFn:async({groupId:ke,brokerageId:Oe,isMember:qe})=>{if(qe){const{error:ve}=await H.from("community_private_group_members").delete().eq("group_id",ke).eq("brokerage_id",Oe);if(ve)throw ve}else{const{error:ve}=await H.from("community_private_group_members").insert({group_id:ke,brokerage_id:Oe});if(ve)throw ve}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ue=ke=>{i(ke),u({name:ke.name,description:ke.description||"",icon:ke.icon||""}),o(!0)},ge=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},_e=ke=>{y(ke),w({name:ke.name,description:ke.description||"",icon:ke.icon||""}),f(!0)},Be=()=>{y(null),w({name:"",description:"",icon:""}),f(!0)},Se=ke=>{M(ke),P(""),N(!0)},Ee=ke=>V.some(Oe=>Oe.user_id===ke),Ae=ke=>V.some(Oe=>Oe.brokerage_id===ke),Me=X.filter(ke=>ke.name.toLowerCase().includes(I.toLowerCase())||ke.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ms,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ga,{value:r,onValueChange:n,children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"categories",children:"Public Categories"}),e.jsxs(ss,{value:"private-groups",children:[e.jsx(zd,{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(G,{onClick:ge,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(qn,{children:q?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((ke,Oe)=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Oe===0,onClick:()=>ce.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Oe===O.length-1,onClick:()=>ce.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(ut,{className:"text-2xl",children:ke.icon||"📁"}),e.jsx(ut,{className:"font-medium",children:ke.name}),e.jsx(ut,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>ue(ke),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Q.mutate(ke.id)},children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},ke.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(Ta,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(G,{onClick:Be,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[50px]",children:"Order"}),e.jsx(jt,{className:"w-[80px]",children:"Icon"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"w-[120px]",children:"Members"}),e.jsx(jt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(qn,{children:z?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):$.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):$.map((ke,Oe)=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Oe===0,onClick:()=>oe.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Oe===$.length-1,onClick:()=>oe.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(ut,{className:"text-2xl",children:ke.icon||"🔒"}),e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ke.name,ke.brokerage_id?e.jsxs(Ye,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(zd,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(ut,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(ut,{children:e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>Se(ke),children:[e.jsx(ur,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[!ke.brokerage_id&&e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>_e(ke),children:e.jsx(Pa,{className:"h-4 w-4"})}),!ke.brokerage_id&&e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&re.mutate(ke.id)},children:e.jsx(kr,{className:"h-4 w-4"})}),ke.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},ke.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(js,{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(Le,{value:c.icon,onChange:ke=>u(Oe=>({...Oe,icon:ke.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Le,{value:c.name,onChange:ke=>u(Oe=>({...Oe,name:ke.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Tr,{value:c.description,onChange:ke=>u(Oe=>({...Oe,description:ke.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(G,{onClick:()=>J.mutate({...c,id:l==null?void 0:l.id}),disabled:!c.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(fs,{open:m,onOpenChange:f,children:e.jsxs(ps,{children:[e.jsx(js,{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(Le,{value:_.icon,onChange:ke=>w(Oe=>({...Oe,icon:ke.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Le,{value:_.name,onChange:ke=>w(Oe=>({...Oe,name:ke.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Tr,{value:_.description,onChange:ke=>w(Oe=>({...Oe,description:ke.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(G,{onClick:()=>ne.mutate({..._,id:g==null?void 0:g.id}),disabled:!_.name.trim(),children:g?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(fs,{open:j,onOpenChange:N,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(vs,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ga,{defaultValue:"brokerages",children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ss,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ss,{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(Li,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Y.map(ke=>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(Mo,{checked:Ae(ke.id),onCheckedChange:()=>{S&&xe.mutate({groupId:S.id,brokerageId:ke.id,isMember:Ae(ke.id)})}}),e.jsx("span",{className:"font-medium",children:ke.name})]}),e.jsxs(Ye,{variant:"secondary",children:[X.filter(Oe=>Oe.brokerage_id===ke.id).length," agents"]})]},ke.id)),Y.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search users...",value:I,onChange:ke=>P(ke.target.value),className:"pl-9"})]}),e.jsx(Li,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Me.map(ke=>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(Mo,{checked:Ee(ke.id),onCheckedChange:()=>{S&&he.mutate({groupId:S.id,userId:ke.id,isMember:Ee(ke.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ke.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ke.email})]})]})},ke.id)),Me.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(G,{onClick:()=>N(!1),children:"Done"})})]})]})})]})})},Q8e=t=>{switch(t){case"academy_video":return e.jsx(sl,{className:"h-3 w-3"});case"template":return e.jsx(wn,{className:"h-3 w-3"});case"toolbox":return e.jsx(Al,{className:"h-3 w-3"});case"newsletter":return e.jsx(x1,{className:"h-3 w-3"});case"social_swag":return e.jsx(nn,{className:"h-3 w-3"});default:return e.jsx(rn,{className:"h-3 w-3"})}},BGt=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}},$Gt=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}},qGt=()=>{const{toast:t}=Ra(),[s,r]=k.useState([]),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState(!0),[u,m]=k.useState(""),[f,g]=k.useState(null),[y,_]=k.useState([]),[w,j]=k.useState([]);k.useEffect(()=>{N()},[]);const N=async()=>{try{c(!0);const{data:V,error:X}=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(X)throw X;const{data:Y,error:J}=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(J)throw J;const Q=[...new Set((Y==null?void 0:Y.map(ue=>ue.user_id))||[])],{data:ce}=await H.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Q),ne=new Map((ce==null?void 0:ce.map(ue=>[ue.id,ue]))||[]),re=(V==null?void 0:V.map(ue=>{var ge,_e,Be,Se;return{id:ue.id,user_id:ue.user_id,app_name:ue.app_name,launched_at:ue.launched_at,user_name:((ge=ue.profiles)==null?void 0:ge.name)||"Unknown",user_email:((_e=ue.profiles)==null?void 0:_e.email)||"Unknown",brokerage_name:((Se=(Be=ue.profiles)==null?void 0:Be.brokerages)==null?void 0:Se.name)||null}}))||[],oe=(Y==null?void 0:Y.map(ue=>{var _e;const ge=ne.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:(ge==null?void 0:ge.name)||"Unknown",user_email:(ge==null?void 0:ge.email)||"Unknown",brokerage_name:((_e=ge==null?void 0:ge.brokerages)==null?void 0:_e.name)||null}}))||[];r(re),a(oe);const he=new Map;re.forEach(ue=>{if(!he.has(ue.user_id))he.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 ge=he.get(ue.user_id);ge.total_app_launches++,new Date(ue.launched_at)>new Date(ge.last_activity_at)&&(ge.last_activity_type="app",ge.last_activity_name=ue.app_name,ge.last_activity_at=ue.launched_at)}}),oe.forEach(ue=>{if(!he.has(ue.user_id))he.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 ge=he.get(ue.user_id);ge.total_content_views++,new Date(ue.created_at)>new Date(ge.last_activity_at)&&(ge.last_activity_type=ue.resource_type,ge.last_activity_name=ue.resource_title,ge.last_activity_at=ue.created_at)}});const xe=Array.from(he.values()).sort((ue,ge)=>new Date(ge.last_activity_at).getTime()-new Date(ue.last_activity_at).getTime());l(xe)}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 X=s.filter(J=>J.user_id===V.user_id),Y=n.filter(J=>J.user_id===V.user_id);_(X),j(Y)},M=()=>{g(null),_([]),j([])},{sortKey:I,sortDirection:P,handleSort:O,sortData:q}=mR("last_activity_at","desc"),$=o.filter(V=>{var Y;if(!u)return!0;const X=u.toLowerCase();return V.user_name.toLowerCase().includes(X)||V.user_email.toLowerCase().includes(X)||((Y=V.brokerage_name)==null?void 0:Y.toLowerCase().includes(X))}),z=q($,{user:V=>{var X;return((X=V.user_name)==null?void 0:X.toLowerCase())||""},brokerage:V=>{var X;return((X=V.brokerage_name)==null?void 0:X.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.total_content_views});return i?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"User Activity"}),e.jsx(vr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:V=>m(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(_l,{sortKey:"user",currentSortKey:I,currentDirection:P,onSort:O,children:"User"}),e.jsx(_l,{sortKey:"brokerage",currentSortKey:I,currentDirection:P,onSort:O,children:"Brokerage"}),e.jsx(jt,{children:"Last Activity"}),e.jsx(_l,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:P,onSort:O,children:"Last Active"}),e.jsx(_l,{sortKey:"apps",currentSortKey:I,currentDirection:P,onSort:O,className:"text-right",children:"Apps"}),e.jsx(_l,{sortKey:"content",currentSortKey:I,currentDirection:P,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(qn,{children:z.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):z.map(V=>e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(V),children:[e.jsx(ut,{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(ut,{children:V.brokerage_name?e.jsx(Ye,{variant:"outline",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:e.jsx("div",{className:"flex items-center gap-2",children:V.last_activity_type==="app"?e.jsxs(Ye,{variant:"secondary",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(Ye,{variant:"outline",className:"flex items-center gap-1",children:[Q8e(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ql(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(ut,{className:"text-right",children:e.jsx(Ye,{variant:"outline",children:V.total_app_launches})}),e.jsx(ut,{className:"text-right",children:e.jsx(Ye,{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(js,{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(ga,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ss,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(ss,{value:"apps",children:["App Launches (",y.length,")"]})]}),e.jsx(bs,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(qn,{children:w.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(V=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs(Ye,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[Q8e(V.resource_type),BGt(V.resource_type)]})}),e.jsx(ut,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(ut,{children:e.jsx(Ye,{variant:"secondary",children:$Gt(V.action_type)})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ql(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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(qn,{children:y.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):y.map(V=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx(Ye,{variant:"secondary",children:V.app_name})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ql(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},UGt=()=>{const{toast:t}=Ra(),[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:m}=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()),y=new Date;y.setMonth(y.getMonth()-1);const{count:_}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",y.toISOString()),{data:w}=await H.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),j=new Set(w==null?void 0:w.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:m||0,launchesThisWeek:g||0,launchesThisMonth:_||0,uniqueActiveThisWeek:j})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(ur,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(wi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},X8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},J8e={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 ost({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(()=>{m()},[s]);const m=async()=>{o(!0);try{let O=[];if(t&&s){const{data:Q}=await H.from("profiles").select("id").eq("brokerage_id",s);if(O=(Q==null?void 0:Q.map(ce=>ce.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:$,error:z}=await q;if(z)throw z;const V=new Set;$==null||$.forEach(Q=>{V.add(Q.sender_id),V.add(Q.recipient_id)});const{data:X}=await H.from("profiles").select("id, name, email").in("id",Array.from(V)),Y=new Map((X==null?void 0:X.map(Q=>[Q.id,Q]))||[]),J=($==null?void 0:$.map(Q=>({...Q,sender:Y.get(Q.sender_id),recipient:Y.get(Q.recipient_id)})))||[];n(J)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:g,handleSort:y,sortData:_}=mR("created_at","desc"),w=r.filter(O=>{var z,V;const q=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||((z=O.sender)==null?void 0:z.name.toLowerCase().includes(l.toLowerCase()))||((V=O.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),$=c==="all"||O.resource_type===c;return q&&$}),j=_(w,{resource:O=>{var q;return((q=O.resource_title)==null?void 0:q.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var q,$;return(($=(q=O.sender)==null?void 0:q.name)==null?void 0:$.toLowerCase())||""},recipient:O=>{var q,$;return(($=(q=O.recipient)==null?void 0:q.name)==null?void 0:$.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,I=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,P=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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(ws,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ws,{className:"h-8 w-16"})})]},q))}),e.jsx(Pe,{children:e.jsx(De,{className:"p-6",children:e.jsx(ws,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(nd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(ur,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:M})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(De,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(P).map(([O,q])=>e.jsxs(Ye,{variant:"secondary",className:J8e[O],children:[X8e[O],": ",q]},O)),Object.keys(P).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Share History"}),e.jsxs(vr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(De,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:c,onValueChange:u,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Resource type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),e.jsx(ft,{value:"event",children:"Events"}),e.jsx(ft,{value:"template",children:"Templates"}),e.jsx(ft,{value:"academy_video",children:"Academy Videos"}),e.jsx(ft,{value:"resource_kit",children:"Resource Kits"}),e.jsx(ft,{value:"newsletter",children:"Newsletters"}),e.jsx(ft,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Li,{className:"h-[400px]",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(_l,{sortKey:"resource",currentSortKey:f,currentDirection:g,onSort:y,children:"Resource"}),e.jsx(_l,{sortKey:"type",currentSortKey:f,currentDirection:g,onSort:y,children:"Type"}),e.jsx(_l,{sortKey:"sender",currentSortKey:f,currentDirection:g,onSort:y,children:"Sender"}),e.jsx(_l,{sortKey:"recipient",currentSortKey:f,currentDirection:g,onSort:y,children:"Recipient"}),e.jsx(_l,{sortKey:"status",currentSortKey:f,currentDirection:g,onSort:y,children:"Status"}),e.jsx(_l,{sortKey:"created_at",currentSortKey:f,currentDirection:g,onSort:y,children:"Date"})]})}),e.jsx(qn,{children:j.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):j.map(O=>{var q,$;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(ut,{children:e.jsx(Ye,{variant:"secondary",className:J8e[O.resource_type],children:X8e[O.resource_type]})}),e.jsx(ut,{children:((q=O.sender)==null?void 0:q.name)||"Unknown"}),e.jsx(ut,{children:(($=O.recipient)==null?void 0:$.name)||"Unknown"}),e.jsx(ut,{children:e.jsx(Ye,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(ut,{className:"text-muted-foreground",children:ds(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const eye={academy_video:{label:"Academy Videos",icon:An,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:Tn},template:{label:"Templates",icon:Hv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:kh},toolbox:{label:"Toolkit",icon:ry,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:vi},newsletter:{label:"Newsletters",icon:rr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:kh},social_swag:{label:"Social Swag",icon:$l,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:kh},event:{label:"Events",icon:fn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:kh}};function eDe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function VGt(t,s){return t==="toolbox"?s.downloads:s.clicks}function HGt(){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:m}=mR("total_views","desc");k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:q,error:$}=await H.rpc("get_admin_content_engagement");if($)throw $;s(q||[])}catch(q){console.error("Error loading content engagement:",q)}finally{n(!1)}},g=q=>{o($=>{const z=$===q?null:q;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),z})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map((q,$)=>e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(ws,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ws,{className:"h-8 w-16"})})]},$))}),e.jsx(Pe,{children:e.jsx(De,{className:"py-8",children:e.jsx(ws,{className:"h-64 w-full"})})})]});const y=t.reduce((q,$)=>q+$.total_views,0),_=t.reduce((q,$)=>q+$.total_clicks,0),w=t.reduce((q,$)=>q+$.total_downloads,0),j=t.length,N=t.reduce((q,$)=>(q[$.resource_type]||(q[$.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),q[$.resource_type].views+=$.total_views,q[$.resource_type].clicks+=$.total_clicks,q[$.resource_type].downloads+=$.total_downloads,q[$.resource_type].assets+=1,q[$.resource_type].uniqueUsers+=$.unique_users,q),{}),S=a?t.filter(q=>q.resource_type===a):t,M=m(S,{asset:q=>{var $;return(($=q.resource_title)==null?void 0:$.toLowerCase())||""},type:q=>q.resource_type,views:q=>q.total_views,actions:q=>eDe(q),unique_users:q=>q.unique_users,last_activity:q=>q.last_engaged_at?new Date(q.last_engaged_at).getTime():0}),I=a?eye[a]||{label:a,icon:Tn,actionLabel:"Actions"}:null,P=I==null?void 0:I.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:y.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(kh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[y>0?Math.round((_+w)/y*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(vr,{children:"Click a category to see individual asset performance"})]}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(N).map(([q,$])=>{const z=eye[q]||{label:q,icon:Tn,color:"bg-muted text-muted-foreground",actionIcon:kh},V=z.icon,X=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 ${X?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${z.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:z.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(Tn,{className:"h-3 w-3"})," ",$.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z.actionIcon,{className:"h-3 w-3"})," ",VGt(q,$)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ur,{className:"h-3 w-3"})," ",$.uniqueUsers]})]})]}),e.jsxs(Ye,{variant:"secondary",className:"text-[10px]",children:[$.assets," items"]})]},q)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{className:"text-sm font-medium flex items-center gap-2",children:I&&P?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(vr,{children:a?`${S.length} ${((O=I==null?void 0:I.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Ga,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(De,{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(Li,{className:"h-[400px]",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[40px]",children:"#"}),e.jsx(_l,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(_l,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(_l,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(_l,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(_l,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(_l,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(qn,{children:M.map((q,$)=>{const z=eye[q.resource_type]||{label:q.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(ks,{children:[e.jsx(ut,{className:"text-muted-foreground text-xs",children:$+1}),e.jsx(ut,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:q.resource_title})}),!a&&e.jsx(ut,{children:e.jsx(Ye,{className:`text-[10px] ${z.color}`,children:z.label})}),e.jsx(ut,{className:"text-right font-medium",children:q.total_views}),e.jsx(ut,{className:"text-right font-medium",children:eDe(q)}),e.jsx(ut,{className:"text-right",children:q.unique_users}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:q.last_engaged_at?ql(new Date(q.last_engaged_at),{addSuffix:!0}):"—"})]},`${q.resource_type}-${q.resource_id}`)})})]})})})]})})]})}var GGt=Array.isArray,Dp=GGt,WGt=typeof Jv=="object"&&Jv&&Jv.Object===Object&&Jv,lst=WGt,KGt=lst,ZGt=typeof self=="object"&&self&&self.Object===Object&&self,YGt=KGt||ZGt||Function("return this")(),K0=YGt,QGt=K0,XGt=QGt.Symbol,bR=XGt,tDe=bR,cst=Object.prototype,JGt=cst.hasOwnProperty,eWt=cst.toString,gI=tDe?tDe.toStringTag:void 0;function tWt(t){var s=JGt.call(t,gI),r=t[gI];try{t[gI]=void 0;var n=!0}catch{}var a=eWt.call(t);return n&&(s?t[gI]=r:delete t[gI]),a}var sWt=tWt,rWt=Object.prototype,nWt=rWt.toString;function aWt(t){return nWt.call(t)}var iWt=aWt,sDe=bR,oWt=sWt,lWt=iWt,cWt="[object Null]",dWt="[object Undefined]",rDe=sDe?sDe.toStringTag:void 0;function uWt(t){return t==null?t===void 0?dWt:cWt:rDe&&rDe in Object(t)?oWt(t):lWt(t)}var Z1=uWt;function hWt(t){return t!=null&&typeof t=="object"}var Y1=hWt,mWt=Z1,pWt=Y1,fWt="[object Symbol]";function xWt(t){return typeof t=="symbol"||pWt(t)&&mWt(t)==fWt}var AE=xWt,gWt=Dp,yWt=AE,vWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bWt=/^\w*$/;function _Wt(t,s){if(gWt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||yWt(t)?!0:bWt.test(t)||!vWt.test(t)||s!=null&&t in Object(s)}var h4e=_Wt;function wWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Hw=wWt;const EE=Do(Hw);var jWt=Z1,NWt=Hw,kWt="[object AsyncFunction]",SWt="[object Function]",CWt="[object GeneratorFunction]",MWt="[object Proxy]";function TWt(t){if(!NWt(t))return!1;var s=jWt(t);return s==SWt||s==CWt||s==kWt||s==MWt}var m4e=TWt;const Ai=Do(m4e);var AWt=K0,EWt=AWt["__core-js_shared__"],PWt=EWt,tye=PWt,nDe=function(){var t=/[^.]+$/.exec(tye&&tye.keys&&tye.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function IWt(t){return!!nDe&&nDe in t}var LWt=IWt,DWt=Function.prototype,OWt=DWt.toString;function RWt(t){if(t!=null){try{return OWt.call(t)}catch{}try{return t+""}catch{}}return""}var dst=RWt,FWt=m4e,zWt=LWt,BWt=Hw,$Wt=dst,qWt=/[\\^$.*+?()[\]{}|]/g,UWt=/^\[object .+?Constructor\]$/,VWt=Function.prototype,HWt=Object.prototype,GWt=VWt.toString,WWt=HWt.hasOwnProperty,KWt=RegExp("^"+GWt.call(WWt).replace(qWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ZWt(t){if(!BWt(t)||zWt(t))return!1;var s=FWt(t)?KWt:UWt;return s.test($Wt(t))}var YWt=ZWt;function QWt(t,s){return t==null?void 0:t[s]}var XWt=QWt,JWt=YWt,eKt=XWt;function tKt(t,s){var r=eKt(t,s);return JWt(r)?r:void 0}var D3=tKt,sKt=D3,rKt=sKt(Object,"create"),dhe=rKt,aDe=dhe;function nKt(){this.__data__=aDe?aDe(null):{},this.size=0}var aKt=nKt;function iKt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var oKt=iKt,lKt=dhe,cKt="__lodash_hash_undefined__",dKt=Object.prototype,uKt=dKt.hasOwnProperty;function hKt(t){var s=this.__data__;if(lKt){var r=s[t];return r===cKt?void 0:r}return uKt.call(s,t)?s[t]:void 0}var mKt=hKt,pKt=dhe,fKt=Object.prototype,xKt=fKt.hasOwnProperty;function gKt(t){var s=this.__data__;return pKt?s[t]!==void 0:xKt.call(s,t)}var yKt=gKt,vKt=dhe,bKt="__lodash_hash_undefined__";function _Kt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=vKt&&s===void 0?bKt:s,this}var wKt=_Kt,jKt=aKt,NKt=oKt,kKt=mKt,SKt=yKt,CKt=wKt;function PE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var VKt=UKt,HKt=uhe;function GKt(t,s){var r=this.__data__,n=HKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var WKt=GKt,KKt=AKt,ZKt=FKt,YKt=$Kt,QKt=VKt,XKt=WKt;function IE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},P4=function(s){return h3(s)&&s.indexOf("%")===s.length-1},pn=function(s){return yYt(s)&&!_R(s)},wYt=function(s){return Ui(s)},Cu=function(s){return pn(s)||h3(s)},jYt=0,DE=function(s){var r=++jYt;return"".concat(s||"").concat(r)},Dm=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(!pn(s)&&!h3(s))return n;var o;if(P4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return _R(o)&&(o=n),a&&o>r&&(o=r),o},g_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},NYt=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 EYt(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 Cbe(t){"@babel/helpers - typeof";return Cbe=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},Cbe(t)}var hDe={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"},j1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},mDe=null,rye=null,j4e=function t(s){if(s===mDe&&Array.isArray(rye))return rye;var r=[];return k.Children.forEach(s,function(n){Ui(n)||(mYt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),rye=r,mDe=s,r};function Sf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return j1(a)}):n=[j1(s)],j4e(t).forEach(function(a){var o=kf(a,"type.displayName")||kf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function nf(t,s){var r=Sf(t,s);return r&&r[0]}var pDe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!pn(n)||n<=0||!pn(a)||a<=0)},PYt=["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"],IYt=function(s){return s&&s.type&&h3(s.type)&&PYt.indexOf(s.type)>=0},LYt=function(s){return s&&Cbe(s)==="object"&&"clipDot"in s},DYt=function(s,r,n,a){var o,l=(o=sye==null?void 0:sye[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!Ai(s)&&(a&&l.includes(r)||CYt.includes(r))||n&&w4e.includes(r)},di=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(k.isValidElement(s)&&(a=s.props),!EE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;DYt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},Mbe=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 fDe(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 BYt(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 Abe(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=zYt(t,FYt),m=a||{width:r,height:n,x:0,y:0},f=Hi("recharts-surface",o);return mt.createElement("svg",Tbe({},di(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(m.x," ").concat(m.y," ").concat(m.width," ").concat(m.height)}),mt.createElement("title",null,i),mt.createElement("desc",null,c),s)}var $Yt=["children","className"];function Ebe(){return Ebe=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 UYt(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 Xo=mt.forwardRef(function(t,s){var r=t.children,n=t.className,a=qYt(t,$Yt),o=Hi("recharts-layer",n);return mt.createElement("g",Ebe({className:o},di(a,!0),{ref:s}),r)}),ay=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:GYt(t,s,r)}var KYt=WYt,ZYt="\\ud800-\\udfff",YYt="\\u0300-\\u036f",QYt="\\ufe20-\\ufe2f",XYt="\\u20d0-\\u20ff",JYt=YYt+QYt+XYt,eQt="\\ufe0e\\ufe0f",tQt="\\u200d",sQt=RegExp("["+tQt+ZYt+JYt+eQt+"]");function rQt(t){return sQt.test(t)}var bst=rQt;function nQt(t){return t.split("")}var aQt=nQt,_st="\\ud800-\\udfff",iQt="\\u0300-\\u036f",oQt="\\ufe20-\\ufe2f",lQt="\\u20d0-\\u20ff",cQt=iQt+oQt+lQt,dQt="\\ufe0e\\ufe0f",uQt="["+_st+"]",Pbe="["+cQt+"]",Ibe="\\ud83c[\\udffb-\\udfff]",hQt="(?:"+Pbe+"|"+Ibe+")",wst="[^"+_st+"]",jst="(?:\\ud83c[\\udde6-\\uddff]){2}",Nst="[\\ud800-\\udbff][\\udc00-\\udfff]",mQt="\\u200d",kst=hQt+"?",Sst="["+dQt+"]?",pQt="(?:"+mQt+"(?:"+[wst,jst,Nst].join("|")+")"+Sst+kst+")*",fQt=Sst+kst+pQt,xQt="(?:"+[wst+Pbe+"?",Pbe,jst,Nst,uQt].join("|")+")",gQt=RegExp(Ibe+"(?="+Ibe+")|"+xQt+fQt,"g");function yQt(t){return t.match(gQt)||[]}var vQt=yQt,bQt=aQt,_Qt=bst,wQt=vQt;function jQt(t){return _Qt(t)?wQt(t):bQt(t)}var NQt=jQt,kQt=KYt,SQt=bst,CQt=NQt,MQt=pst;function TQt(t){return function(s){s=MQt(s);var r=SQt(s)?CQt(s):void 0,n=r?r[0]:s.charAt(0),a=r?kQt(r,1).join(""):s.slice(1);return n[t]()+a}}var AQt=TQt,EQt=AQt,PQt=EQt("toUpperCase"),IQt=PQt;const khe=Do(IQt);function Jl(t){return function(){return t}}const Cst=Math.cos,oce=Math.sin,gy=Math.sqrt,lce=Math.PI,She=2*lce,Lbe=Math.PI,Dbe=2*Lbe,u4=1e-6,LQt=Dbe-u4;function Mst(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return Mst;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;au4)if(!(Math.abs(f*c-u*m)>u4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let y=n-l,_=a-i,w=c*c+u*u,j=y*y+_*_,N=Math.sqrt(w),S=Math.sqrt(g),M=o*Math.tan((Lbe-Math.acos((w+g-j)/(2*N*S)))/2),I=M/S,P=M/N;Math.abs(I-1)>u4&&this._append`L${s+I*m},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*y>m*_)},${this._x1=s+P*c},${this._y1=r+P*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,m=r+c,f=1^l,g=l?a-o:o-a;this._x1===null?this._append`M${u},${m}`:(Math.abs(this._x1-u)>u4||Math.abs(this._y1-m)>u4)&&this._append`L${u},${m}`,n&&(g<0&&(g=g%Dbe+Dbe),g>LQt?this._append`A${n},${n},0,1,${f},${s-i},${r-c}A${n},${n},0,1,${f},${this._x1=u},${this._y1=m}`:g>u4&&this._append`A${n},${n},0,${+(g>=Lbe)},${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 N4e(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 OQt(s)}function k4e(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 Che(t){return new Tst(t)}function Ast(t){return t[0]}function Est(t){return t[1]}function Pst(t,s){var r=Jl(!0),n=null,a=Che,o=null,l=N4e(i);t=typeof t=="function"?t:t===void 0?Ast:Jl(t),s=typeof s=="function"?s:s===void 0?Est:Jl(s);function i(c){var u,m=(c=k4e(c)).length,f,g=!1,y;for(n==null&&(o=a(y=l())),u=0;u<=m;++u)!(u=y;--_)i.point(M[_],I[_]);i.lineEnd(),i.areaEnd()}N&&(M[g]=+t(j,g,f),I[g]=+s(j,g,f),i.point(n?+n(j,g,f):M[g],r?+r(j,g,f):I[g]))}if(S)return i=null,S+""||null}function m(){return Pst().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Jl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Jl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Jl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Jl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Jl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Jl(+f),u):r},u.lineX0=u.lineY0=function(){return m().x(t).y(s)},u.lineY1=function(){return m().x(t).y(r)},u.lineX1=function(){return m().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Jl(!!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 Ist{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 RQt(t){return new Ist(t,!0)}function FQt(t){return new Ist(t,!1)}const S4e={draw(t,s){const r=gy(s/lce);t.moveTo(r,0),t.arc(0,0,r,0,She)}},zQt={draw(t,s){const r=gy(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()}},Lst=gy(1/3),BQt=Lst*2,$Qt={draw(t,s){const r=gy(s/BQt),n=r*Lst;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},qQt={draw(t,s){const r=gy(s),n=-r/2;t.rect(n,n,r,r)}},UQt=.8908130915292852,Dst=oce(lce/10)/oce(7*lce/10),VQt=oce(She/10)*Dst,HQt=-Cst(She/10)*Dst,GQt={draw(t,s){const r=gy(s*UQt),n=VQt*r,a=HQt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=She*o/5,i=Cst(l),c=oce(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},nye=gy(3),WQt={draw(t,s){const r=-gy(s/(nye*3));t.moveTo(0,r*2),t.lineTo(-nye*r,-r),t.lineTo(nye*r,-r),t.closePath()}},rx=-.5,nx=gy(3)/2,Obe=1/gy(12),KQt=(Obe/2+1)*3,ZQt={draw(t,s){const r=gy(s/KQt),n=r/2,a=r*Obe,o=n,l=r*Obe+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(rx*n-nx*a,nx*n+rx*a),t.lineTo(rx*o-nx*l,nx*o+rx*l),t.lineTo(rx*i-nx*c,nx*i+rx*c),t.lineTo(rx*n+nx*a,rx*a-nx*n),t.lineTo(rx*o+nx*l,rx*l-nx*o),t.lineTo(rx*i+nx*c,rx*c-nx*i),t.closePath()}};function YQt(t,s){let r=null,n=N4e(a);t=typeof t=="function"?t:Jl(t||S4e),s=typeof s=="function"?s:Jl(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:Jl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Jl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function cce(){}function dce(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 Ost(t){this._context=t}Ost.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:dce(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:dce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function QQt(t){return new Ost(t)}function Rst(t){this._context=t}Rst.prototype={areaStart:cce,areaEnd:cce,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:dce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function XQt(t){return new Rst(t)}function Fst(t){this._context=t}Fst.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:dce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function JQt(t){return new Fst(t)}function zst(t){this._context=t}zst.prototype={areaStart:cce,areaEnd:cce,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 eXt(t){return new zst(t)}function gDe(t){return t<0?-1:1}function yDe(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(gDe(o)+gDe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function vDe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function aye(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 uce(t){this._context=t}uce.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:aye(this,this._t0,vDe(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,aye(this,vDe(this,r=yDe(this,t,s)),r);break;default:aye(this,this._t0,r=yDe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function Bst(t){this._context=new $st(t)}(Bst.prototype=Object.create(uce.prototype)).point=function(t,s){uce.prototype.point.call(this,s,t)};function $st(t){this._context=t}$st.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 tXt(t){return new uce(t)}function sXt(t){return new Bst(t)}function qst(t){this._context=t}qst.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=bDe(t),a=bDe(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 nXt(t){return new Mhe(t,.5)}function aXt(t){return new Mhe(t,0)}function iXt(t){return new Mhe(t,1)}function mA(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 oXt(t,s){return t[s]}function lXt(t){const s=[];return s.key=t,s}function cXt(){var t=Jl([]),s=Rbe,r=mA,n=oXt;function a(o){var l=Array.from(t.apply(this,arguments),lXt),i,c=l.length,u=-1,m;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 yXt(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 Ust={symbolCircle:S4e,symbolCross:zQt,symbolDiamond:$Qt,symbolSquare:qQt,symbolStar:GQt,symbolTriangle:WQt,symbolWye:ZQt},vXt=Math.PI/180,bXt=function(s){var r="symbol".concat(khe(s));return Ust[r]||S4e},_Xt=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*vXt;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}},wXt=function(s,r){Ust["symbol".concat(khe(s))]=r},C4e=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=gXt(s,mXt),u=wDe(wDe({},c),{},{type:n,size:o,sizeType:i}),m=function(){var j=bXt(n),N=YQt().type(j).size(_Xt(o,i,n));return N()},f=u.className,g=u.cx,y=u.cy,_=di(u,!0);return g===+g&&y===+y&&o===+o?mt.createElement("path",Fbe({},_,{className:Hi("recharts-symbols",f),transform:"translate(".concat(g,", ").concat(y,")"),d:m()})):null};C4e.registerSymbol=wXt;function pA(t){"@babel/helpers - typeof";return pA=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},pA(t)}function zbe(){return zbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=y.inactive?u:y.color;return mt.createElement("li",zbe({className:j,style:f,key:"legend-item-".concat(_)},m3(n.props,y,_)),mt.createElement(Abe,{width:l,height:l,viewBox:m,style:g},n.renderIcon(y)),mt.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(N,y,_):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 mt.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(k.PureComponent);$D(M4e,"displayName","Legend");$D(M4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var PXt=hhe;function IXt(){this.__data__=new PXt,this.size=0}var LXt=IXt;function DXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var OXt=DXt;function RXt(t){return this.__data__.get(t)}var FXt=RXt;function zXt(t){return this.__data__.has(t)}var BXt=zXt,$Xt=hhe,qXt=f4e,UXt=x4e,VXt=200;function HXt(t,s){var r=this.__data__;if(r instanceof $Xt){var n=r.__data__;if(!qXt||n.lengthi))return!1;var u=o.get(t),m=o.get(s);if(u&&m)return u==s&&m==t;var f=-1,g=!0,y=r&mJt?new cJt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=ges}var P4e=yes,ves=Z1,bes=P4e,_es=Y1,wes="[object Arguments]",jes="[object Array]",Nes="[object Boolean]",kes="[object Date]",Ses="[object Error]",Ces="[object Function]",Mes="[object Map]",Tes="[object Number]",Aes="[object Object]",Ees="[object RegExp]",Pes="[object Set]",Ies="[object String]",Les="[object WeakMap]",Des="[object ArrayBuffer]",Oes="[object DataView]",Res="[object Float32Array]",Fes="[object Float64Array]",zes="[object Int8Array]",Bes="[object Int16Array]",$es="[object Int32Array]",qes="[object Uint8Array]",Ues="[object Uint8ClampedArray]",Ves="[object Uint16Array]",Hes="[object Uint32Array]",bc={};bc[Res]=bc[Fes]=bc[zes]=bc[Bes]=bc[$es]=bc[qes]=bc[Ues]=bc[Ves]=bc[Hes]=!0;bc[wes]=bc[jes]=bc[Des]=bc[Nes]=bc[Oes]=bc[kes]=bc[Ses]=bc[Ces]=bc[Mes]=bc[Tes]=bc[Aes]=bc[Ees]=bc[Pes]=bc[Ies]=bc[Les]=!1;function Ges(t){return _es(t)&&bes(t.length)&&!!bc[ves(t)]}var Wes=Ges;function Kes(t){return function(s){return t(s)}}var ert=Kes,fce={exports:{}};fce.exports;(function(t,s){var r=lst,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})(fce,fce.exports);var Zes=fce.exports,Yes=Wes,Qes=ert,TDe=Zes,ADe=TDe&&TDe.isTypedArray,Xes=ADe?Qes(ADe):Yes,trt=Xes,Jes=ses,ets=A4e,tts=Dp,sts=Jst,rts=E4e,nts=trt,ats=Object.prototype,its=ats.hasOwnProperty;function ots(t,s){var r=tts(t),n=!r&&ets(t),a=!r&&!n&&sts(t),o=!r&&!n&&!a&&nts(t),l=r||n||a||o,i=l?Jes(t.length,String):[],c=i.length;for(var u in t)(s||its.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||rts(u,c)))&&i.push(u);return i}var lts=ots,cts=Object.prototype;function dts(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||cts;return t===r}var uts=dts;function hts(t,s){return function(r){return t(s(r))}}var srt=hts,mts=srt,pts=mts(Object.keys,Object),fts=pts,xts=uts,gts=fts,yts=Object.prototype,vts=yts.hasOwnProperty;function bts(t){if(!xts(t))return gts(t);var s=[];for(var r in Object(t))vts.call(t,r)&&r!="constructor"&&s.push(r);return s}var _ts=bts,wts=m4e,jts=P4e;function Nts(t){return t!=null&&jts(t.length)&&!wts(t)}var wR=Nts,kts=lts,Sts=_ts,Cts=wR;function Mts(t){return Cts(t)?kts(t):Sts(t)}var The=Mts,Tts=VJt,Ats=ees,Ets=The;function Pts(t){return Tts(t,Ets,Ats)}var Its=Pts,EDe=Its,Lts=1,Dts=Object.prototype,Ots=Dts.hasOwnProperty;function Rts(t,s,r,n,a,o){var l=r&Lts,i=EDe(t),c=i.length,u=EDe(s),m=u.length;if(c!=m&&!l)return!1;for(var f=c;f--;){var g=i[f];if(!(l?g in s:Ots.call(s,g)))return!1}var y=o.get(t),_=o.get(s);if(y&&_)return y==s&&_==t;var w=!0;o.set(t,s),o.set(s,t);for(var j=l;++f-1}var Drs=Lrs;function Ors(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=Qrs){var u=s?null:Zrs(t);if(u)return Yrs(u);l=!1,a=Krs,c=new Hrs}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function mns(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 pns(t){return t.value}function fns(t,s){if(mt.isValidElement(t))return mt.cloneElement(t,s);if(typeof t=="function")return mt.createElement(t,s);s.ref;var r=hns(s,nns);return mt.createElement(M4e,r)}var WDe=1,_T=function(t){function s(){var r;ans(this,s);for(var n=arguments.length,a=new Array(n),o=0;oWDe||Math.abs(a.height-this.lastBoundingBox.height)>WDe)&&(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?Iv({},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,m=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 y=this.getBBoxSnapshot();f={left:((u||0)-y.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:((m||0)-_.height)/2}}else g=i==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Iv(Iv({},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,m=a.payload,f=Iv(Iv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return mt.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(y){n.wrapperNode=y}},fns(o,Iv(Iv({},this.props),{},{payload:crt(m,u,pns)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Iv(Iv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&pn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(k.PureComponent);Ahe(_T,"displayName","Legend");Ahe(_T,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var KDe=bR,xns=A4e,gns=Dp,ZDe=KDe?KDe.isConcatSpreadable:void 0;function yns(t){return gns(t)||xns(t)||!!(ZDe&&t&&t[ZDe])}var vns=yns,bns=Qst,_ns=vns;function hrt(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=_ns),a||(a=[]);++o0&&r(i)?s>1?hrt(i,s-1,r,n,a):bns(a,i):n||(a[a.length]=i)}return a}var mrt=hrt;function wns(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 jns=wns,Nns=jns,kns=Nns(),Sns=kns,Cns=Sns,Mns=The;function Tns(t,s){return t&&Cns(t,s,Mns)}var prt=Tns,Ans=wR;function Ens(t,s){return function(r,n){if(r==null)return r;if(!Ans(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 Hns=Vns,cye=y4e,Gns=v4e,Wns=Z0,Kns=frt,Zns=Bns,Yns=ert,Qns=Hns,Xns=FE,Jns=Dp;function eas(t,s,r){s.length?s=cye(s,function(o){return Jns(o)?function(l){return Gns(l,o.length===1?o[0]:o)}:o}):s=[Xns];var n=-1;s=cye(s,Yns(Wns));var a=Kns(t,function(o,l,i){var c=cye(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return Zns(a,function(o,l){return Qns(o,l,r)})}var tas=eas;function sas(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 ras=sas,nas=ras,QDe=Math.max;function aas(t,s,r){return s=QDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=QDe(n.length-s,0),l=Array(o);++a0){if(++s>=fas)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var vas=yas,bas=pas,_as=vas,was=_as(bas),jas=was,Nas=FE,kas=ias,Sas=jas;function Cas(t,s){return Sas(kas(t,s,Nas),t+"")}var Mas=Cas,Tas=p4e,Aas=wR,Eas=E4e,Pas=Hw;function Ias(t,s,r){if(!Pas(r))return!1;var n=typeof s;return(n=="number"?Aas(r)&&Eas(s,r.length):n=="string"&&s in r)?Tas(r[s],t):!1}var Ehe=Ias,Las=mrt,Das=tas,Oas=Mas,JDe=Ehe,Ras=Oas(function(t,s){if(t==null)return[];var r=s.length;return r>1&&JDe(t,s[0],s[1])?s=[]:r>2&&JDe(s[0],s[1],s[2])&&(s=[s[0]]),Das(t,Las(s,1),[])}),Fas=Ras;const D4e=Do(Fas);function qD(t){"@babel/helpers - typeof";return qD=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},qD(t)}function Wbe(){return Wbe=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(yI,"-left"),pn(r)&&s&&pn(s.x)&&r=s.y),"".concat(yI,"-top"),pn(n)&&s&&pn(s.y)&&nw?Math.max(m,c[n]):Math.max(f,c[n])}function Jas(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 eis(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,m,f;return l.height>0&&l.width>0&&r?(m=sOe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),f=sOe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),u=Jas({translateX:m,translateY:f,useTranslate3d:i})):u=Qas,{cssProperties:u,cssClasses:Xas({translateX:m,translateY:f,coordinate:r})}}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 rOe(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 nOe(t){for(var s=1;saOe||Math.abs(n.height-this.state.lastBoundingBox.height)>aOe)&&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,m=a.coordinate,f=a.hasPayload,g=a.isAnimationActive,y=a.offset,_=a.position,w=a.reverseDirection,j=a.useTranslate3d,N=a.viewBox,S=a.wrapperStyle,M=eis({allowEscapeViewBox:l,coordinate:m,offsetTopLeft:y,position:_,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:N}),I=M.cssClasses,P=M.cssProperties,O=nOe(nOe({transition:g&&o?"transform ".concat(i,"ms ").concat(c):void 0},P),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return mt.createElement("div",{tabIndex:-1,className:I,style:O,ref:function($){n.wrapperNode=$}},u)}}])}(k.PureComponent),dis=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},O3={isSsr:dis()};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 iOe(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 oOe(t){for(var s=1;s0;return mt.createElement(cis,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:g,active:o,coordinate:m,hasPayload:O,offset:y,position:j,reverseDirection:N,useTranslate3d:S,viewBox:M,wrapperStyle:I},bis(u,oOe(oOe({},this.props),{},{payload:P})))}}])}(k.PureComponent);O4e(mp,"displayName","Tooltip");O4e(mp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!O3.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 _is=K0,wis=function(){return _is.Date.now()},jis=wis,Nis=/\s/;function kis(t){for(var s=t.length;s--&&Nis.test(t.charAt(s)););return s}var Sis=kis,Cis=Sis,Mis=/^\s+/;function Tis(t){return t&&t.slice(0,Cis(t)+1).replace(Mis,"")}var Ais=Tis,Eis=Ais,lOe=Hw,Pis=AE,cOe=NaN,Iis=/^[-+]0x[0-9a-f]+$/i,Lis=/^0b[01]+$/i,Dis=/^0o[0-7]+$/i,Ois=parseInt;function Ris(t){if(typeof t=="number")return t;if(Pis(t))return cOe;if(lOe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=lOe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Eis(t);var r=Lis.test(t);return r||Dis.test(t)?Ois(t.slice(2),r?2:8):Iis.test(t)?cOe:+t}var _rt=Ris,Fis=Hw,uye=jis,dOe=_rt,zis="Expected a function",Bis=Math.max,$is=Math.min;function qis(t,s,r){var n,a,o,l,i,c,u=0,m=!1,f=!1,g=!0;if(typeof t!="function")throw new TypeError(zis);s=dOe(s)||0,Fis(r)&&(m=!!r.leading,f="maxWait"in r,o=f?Bis(dOe(r.maxWait)||0,s):o,g="trailing"in r?!!r.trailing:g);function y(O){var q=n,$=a;return n=a=void 0,u=O,l=t.apply($,q),l}function _(O){return u=O,i=setTimeout(N,s),m?y(O):l}function w(O){var q=O-c,$=O-u,z=s-q;return f?$is(z,o-$):z}function j(O){var q=O-c,$=O-u;return c===void 0||q>=s||q<0||f&&$>=o}function N(){var O=uye();if(j(O))return S(O);i=setTimeout(N,w(O))}function S(O){return i=void 0,g&&n?y(O):(n=a=void 0,l)}function M(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function I(){return i===void 0?l:S(uye())}function P(){var O=uye(),q=j(O);if(n=arguments,a=this,c=O,q){if(i===void 0)return _(c);if(f)return clearTimeout(i),i=setTimeout(N,s),y(c)}return i===void 0&&(i=setTimeout(N,s)),l}return P.cancel=M,P.flush=I,P}var Uis=qis,Vis=Uis,His=Hw,Gis="Expected a function";function Wis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(Gis);return His(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Vis(t,s,{leading:n,maxWait:s,trailing:a})}var Kis=Wis;const wrt=Do(Kis);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 uOe(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 Qz(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(J=wrt(J,w,{trailing:!0,leading:!1}));var Q=new ResizeObserver(J),ce=P.current.getBoundingClientRect(),ne=ce.width,re=ce.height;return X(ne,re),Q.observe(P.current),function(){Q.disconnect()}},[X,w]);var Y=k.useMemo(function(){var J=z.containerWidth,Q=z.containerHeight;if(J<0||Q<0)return null;ay(P4(l)||P4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),ay(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=P4(l)?J:l,ne=P4(c)?Q:c;r&&r>0&&(ce?ne=ce/r:ne&&(ce=ne*r),g&&ne>g&&(ne=g)),ay(ce>0||ne>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.`,ce,ne,l,c,m,f,r);var re=!Array.isArray(y)&&j1(y.type).endsWith("Chart");return mt.Children.map(y,function(oe){return mt.isValidElement(oe)?k.cloneElement(oe,Qz({width:ce,height:ne},re?{style:Qz({height:"100%",width:"100%",maxHeight:ne,maxWidth:ce},oe.props.style)}:{})):oe})},[r,y,c,g,f,m,z,l]);return mt.createElement("div",{id:j?"".concat(j):void 0,className:Hi("recharts-responsive-container",N),style:Qz(Qz({},I),{},{width:l,height:c,minWidth:m,minHeight:f,maxHeight:g}),ref:P},Y)}),jR=function(s){return null};jR.displayName="Cell";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 mOe(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 Qbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||O3.isSsr)return{width:0,height:0};var n=los(r),a=JSON.stringify({text:s,copyStyle:n});if(U5.widthCache[a])return U5.widthCache[a];try{var o=document.getElementById(pOe);o||(o=document.createElement("span"),o.setAttribute("id",pOe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Qbe(Qbe({},oos),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return U5.widthCache[a]=c,++U5.cacheCount>ios&&(U5.cacheCount=0,U5.widthCache={}),c}catch{return{width:0,height:0}}},cos=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function GD(t){"@babel/helpers - typeof";return GD=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},GD(t)}function vce(t,s){return mos(t)||hos(t,s)||uos(t,s)||dos()}function dos(){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 uos(t,s){if(t){if(typeof t=="string")return fOe(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 fOe(t,s)}}function fOe(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 Cos(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 _Oe(t,s){return Eos(t)||Aos(t,s)||Tos(t,s)||Mos()}function Mos(){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 Tos(t,s){if(t){if(typeof t=="string")return wOe(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 wOe(t,s)}}function wOe(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 ce.reduce(function(ne,re){var oe=re.word,he=re.width,xe=ne[ne.length-1];if(xe&&(a==null||o||xe.width+he+nre.width?ne:re})};if(!m)return y;for(var w="…",j=function(ce){var ne=f.slice(0,ce),re=Srt({breakAll:u,style:c,children:ne+w}).wordsWithComputedWidth,oe=g(re),he=oe.length>l||_(oe).width>Number(a);return[he,oe]},N=0,S=f.length-1,M=0,I;N<=S&&M<=f.length-1;){var P=Math.floor((N+S)/2),O=P-1,q=j(O),$=_Oe(q,2),z=$[0],V=$[1],X=j(P),Y=_Oe(X,1),J=Y[0];if(!z&&!J&&(N=P+1),z&&J&&(S=P-1),!z&&J){I=V;break}M++}return I||y},jOe=function(s){var r=Ui(s)?[]:s.toString().split(krt);return[{words:r}]},Ios=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!O3.isSsr){var c,u,m=Srt({breakAll:l,children:a,style:o});if(m){var f=m.wordsWithComputedWidth,g=m.spaceWidth;c=f,u=g}else return jOe(a);return Pos({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return jOe(a)},NOe="#808080",p3=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,m=s.scaleToFit,f=m===void 0?!1:m,g=s.textAnchor,y=g===void 0?"start":g,_=s.verticalAnchor,w=_===void 0?"end":_,j=s.fill,N=j===void 0?NOe:j,S=bOe(s,kos),M=k.useMemo(function(){return Ios({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:f,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,f,S.style,S.width]),I=S.dx,P=S.dy,O=S.angle,q=S.className,$=S.breakAll,z=bOe(S,Sos);if(!Cu(n)||!Cu(o))return null;var V=n+(pn(I)?I:0),X=o+(pn(P)?P:0),Y;switch(w){case"start":Y=hye("calc(".concat(u,")"));break;case"middle":Y=hye("calc(".concat((M.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Y=hye("calc(".concat(M.length-1," * -").concat(i,")"));break}var J=[];if(f){var Q=M[0].width,ce=S.width;J.push("scale(".concat((pn(ce)?ce/Q:1)/Q,")"))}return O&&J.push("rotate(".concat(O,", ").concat(V,", ").concat(X,")")),J.length&&(z.transform=J.join(" ")),mt.createElement("text",Xbe({},di(z,!0),{x:V,y:X,className:Hi("recharts-text",q),textAnchor:y,fill:N.includes("url")?NOe:N}),M.map(function(ne,re){var oe=ne.words.join($?"":" ");return mt.createElement("tspan",{x:V,dy:re===0?Y:i,key:"".concat(oe,"-").concat(re)},oe)}))};function dw(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function Los(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function R4e(t){let s,r,n;t.length!==2?(s=dw,r=(i,c)=>dw(t(i),c),n=(i,c)=>t(i)-c):(s=t===dw||t===Los?t:Dos,r=t,n=t);function a(i,c,u=0,m=i.length){if(u>>1;r(i[f],c)<0?u=f+1:m=f}while(u>>1;r(i[f],c)<=0?u=f+1:m=f}while(uu&&n(i[f-1],c)>-n(i[f],c)?f-1:f}return{left:a,center:l,right:o}}function Dos(){return 0}function Crt(t){return t===null?NaN:+t}function*Oos(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const Ros=R4e(dw),NR=Ros.right;R4e(Crt).center;class kOe extends Map{constructor(s,r=Bos){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(SOe(this,s))}has(s){return super.has(SOe(this,s))}set(s,r){return super.set(Fos(this,s),r)}delete(s){return super.delete(zos(this,s))}}function SOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function Fos({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function zos({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function Bos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function $os(t=dw){if(t===dw)return Mrt;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 Mrt(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const qos=Math.sqrt(50),Uos=Math.sqrt(10),Vos=Math.sqrt(2);function bce(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>=qos?10:o>=Uos?5:o>=Vos?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 MOe(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?Mrt:$os(a);n>r;){if(n-r>600){const c=n-r+1,u=s-r+1,m=Math.log(c),f=.5*Math.exp(2*m/3),g=.5*Math.sqrt(m*f*(c-f)/c)*(u-c/2<0?-1:1),y=Math.max(r,Math.floor(s-u*f/c+g)),_=Math.min(n,Math.floor(s+(c-u)*f/c+g));Trt(t,s,y,_,a)}const o=t[s];let l=r,i=n;for(vI(t,r,s),a(t[n],o)>0&&vI(t,r,n);l0;)--i}a(t[r],o)===0?vI(t,r,i):(++i,vI(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function vI(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Hos(t,s,r){if(t=Float64Array.from(Oos(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return MOe(t);if(s>=1)return COe(t);var n,a=(n-1)*s,o=Math.floor(a),l=COe(Trt(t,o).subarray(0,o+1)),i=MOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Gos(t,s,r=Crt){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 Wos(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?Jz(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Jz(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=Zos.exec(t))?new wp(s[1],s[2],s[3],1):(s=Yos.exec(t))?new wp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Qos.exec(t))?Jz(s[1],s[2],s[3],s[4]):(s=Xos.exec(t))?Jz(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Jos.exec(t))?DOe(s[1],s[2]/100,s[3]/100,1):(s=els.exec(t))?DOe(s[1],s[2]/100,s[3]/100,s[4]):TOe.hasOwnProperty(t)?POe(TOe[t]):t==="transparent"?new wp(NaN,NaN,NaN,0):null}function POe(t){return new wp(t>>16&255,t>>8&255,t&255,1)}function Jz(t,s,r,n){return n<=0&&(t=s=r=NaN),new wp(t,s,r,n)}function rls(t){return t instanceof kR||(t=YD(t)),t?(t=t.rgb(),new wp(t.r,t.g,t.b,t.opacity)):new wp}function r_e(t,s,r,n){return arguments.length===1?rls(t):new wp(t,s,r,n??1)}function wp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}z4e(wp,r_e,Ert(kR,{brighter(t){return t=t==null?_ce:Math.pow(_ce,t),new wp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?KD:Math.pow(KD,t),new wp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new wp(RS(this.r),RS(this.g),RS(this.b),wce(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:IOe,formatHex:IOe,formatHex8:nls,formatRgb:LOe,toString:LOe}));function IOe(){return`#${I4(this.r)}${I4(this.g)}${I4(this.b)}`}function nls(){return`#${I4(this.r)}${I4(this.g)}${I4(this.b)}${I4((isNaN(this.opacity)?1:this.opacity)*255)}`}function LOe(){const t=wce(this.opacity);return`${t===1?"rgb(":"rgba("}${RS(this.r)}, ${RS(this.g)}, ${RS(this.b)}${t===1?")":`, ${t})`}`}function wce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function RS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function I4(t){return t=RS(t),(t<16?"0":"")+t.toString(16)}function DOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Kg(t,s,r,n)}function Prt(t){if(t instanceof Kg)return new Kg(t.h,t.s,t.l,t.opacity);if(t instanceof kR||(t=YD(t)),!t)return new Kg;if(t instanceof Kg)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 Kg(l,i,c,t.opacity)}function als(t,s,r,n){return arguments.length===1?Prt(t):new Kg(t,s,r,n??1)}function Kg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}z4e(Kg,als,Ert(kR,{brighter(t){return t=t==null?_ce:Math.pow(_ce,t),new Kg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?KD:Math.pow(KD,t),new Kg(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 wp(mye(t>=240?t-240:t+120,a,n),mye(t,a,n),mye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Kg(OOe(this.h),e9(this.s),e9(this.l),wce(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=wce(this.opacity);return`${t===1?"hsl(":"hsla("}${OOe(this.h)}, ${e9(this.s)*100}%, ${e9(this.l)*100}%${t===1?")":`, ${t})`}`}}));function OOe(t){return t=(t||0)%360,t<0?t+360:t}function e9(t){return Math.max(0,Math.min(1,t||0))}function mye(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 B4e=t=>()=>t;function ils(t,s){return function(r){return t+r*s}}function ols(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 lls(t){return(t=+t)==1?Irt:function(s,r){return r-s?ols(s,r,t):B4e(isNaN(s)?r:s)}}function Irt(t,s){var r=s-t;return r?ils(t,r):B4e(isNaN(t)?s:t)}const ROe=function t(s){var r=lls(s);function n(a,o){var l=r((a=r_e(a)).r,(o=r_e(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=Irt(a.opacity,o.opacity);return function(m){return a.r=l(m),a.g=i(m),a.b=c(m),a.opacity=u(m),a+""}}return n.gamma=t,n}(1);function cls(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:jce(n,a)})),r=pye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function bls(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?_ls:bls,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),jce)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,Nce),m()):t.slice()},f.range=function(g){return arguments.length?(s=Array.from(g),m()):s.slice()},f.rangeRound=function(g){return s=Array.from(g),r=$4e,m()},f.clamp=function(g){return arguments.length?(l=g?!0:Om,m()):l!==Om},f.interpolate=function(g){return arguments.length?(r=g,m()):r},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,y){return n=g,a=y,m()}}function q4e(){return Phe()(Om,Om)}function wls(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function kce(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 yA(t){return t=kce(Math.abs(t)),t?t[1]:NaN}function jls(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 Nls(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var kls=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function QD(t){if(!(s=kls.exec(t)))throw new Error("invalid format: "+t);var s;return new U4e({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]})}QD.prototype=U4e.prototype;function U4e(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+""}U4e.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 Sls(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 Lrt;function Cls(t,s){var r=kce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(Lrt=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")+kce(t,Math.max(0,s+o-1))[0]}function zOe(t,s){var r=kce(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 BOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:wls,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)=>zOe(t*100,s),r:zOe,s:Cls,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function $Oe(t){return t}var qOe=Array.prototype.map,UOe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Mls(t){var s=t.grouping===void 0||t.thousands===void 0?$Oe:jls(qOe.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?$Oe:Nls(qOe.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=QD(f);var g=f.fill,y=f.align,_=f.sign,w=f.symbol,j=f.zero,N=f.width,S=f.comma,M=f.precision,I=f.trim,P=f.type;P==="n"?(S=!0,P="g"):BOe[P]||(M===void 0&&(M=12),I=!0,P="g"),(j||g==="0"&&y==="=")&&(j=!0,g="0",y="=");var O=w==="$"?r:w==="#"&&/[boxX]/.test(P)?"0"+P.toLowerCase():"",q=w==="$"?n:/[%p]/.test(P)?l:"",$=BOe[P],z=/[defgprs%]/.test(P);M=M===void 0?6:/[gprs]/.test(P)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function V(X){var Y=O,J=q,Q,ce,ne;if(P==="c")J=$(X)+J,X="";else{X=+X;var re=X<0||1/X<0;if(X=isNaN(X)?c:$(Math.abs(X),M),I&&(X=Sls(X)),re&&+X==0&&_!=="+"&&(re=!1),Y=(re?_==="("?_:i:_==="-"||_==="("?"":_)+Y,J=(P==="s"?UOe[8+Lrt/3]:"")+J+(re&&_==="("?")":""),z){for(Q=-1,ce=X.length;++Qne||ne>57){J=(ne===46?a+X.slice(Q+1):X.slice(Q))+J,X=X.slice(0,Q);break}}}S&&!j&&(X=s(X,1/0));var oe=Y.length+X.length+J.length,he=oe>1)+Y+X+J+he.slice(oe);break;default:X=he+Y+X+J;break}return o(X)}return V.toString=function(){return f+""},V}function m(f,g){var y=u((f=QD(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(yA(g)/3)))*3,w=Math.pow(10,-_),j=UOe[8+_/3];return function(N){return y(w*N)+j}}return{format:u,formatPrefix:m}}var t9,V4e,Drt;Tls({thousands:",",grouping:[3],currency:["$",""]});function Tls(t){return t9=Mls(t),V4e=t9.format,Drt=t9.formatPrefix,t9}function Als(t){return Math.max(0,-yA(Math.abs(t)))}function Els(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(yA(s)/3)))*3-yA(Math.abs(t)))}function Pls(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,yA(s)-yA(t))+1}function Ort(t,s,r,n){var a=t_e(t,s,r),o;switch(n=QD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=Els(a,l))&&(n.precision=o),Drt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Pls(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Als(a))&&(n.precision=o-(n.type==="%")*2);break}}return V4e(n)}function Gw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Jbe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return Ort(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,m=10;for(i0;){if(u=e_e(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 Sce(){var t=q4e();return t.copy=function(){return SR(t,Sce())},Yx.apply(t,arguments),Gw(t)}function Rrt(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,Nce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return Rrt(t).unknown(s)},t=arguments.length?Array.from(t,Nce):[0,1],Gw(r)}function Frt(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 Rls(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 GOe(t){return(s,r)=>-t(-s,r)}function H4e(t){const s=t(VOe,HOe),r=s.domain;let n=10,a,o;function l(){return a=Rls(n),o=Ols(n),r()[0]<0?(a=GOe(a),o=GOe(o),t(Ils,Lls)):t(VOe,HOe),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],m=c[c.length-1];const f=m0){for(;g<=y;++g)for(_=1;_m)break;N.push(w)}}else for(;g<=y;++g)for(_=n-1;_>=1;--_)if(w=g>0?_/o(-g):_*o(g),!(wm)break;N.push(w)}N.length*2{if(i==null&&(i=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=QD(c)).precision==null&&(c.trim=!0),c=V4e(c)),i===1/0)return c;const u=Math.max(1,n*i/s.ticks().length);return m=>{let f=m/o(Math.round(a(m)));return f*nr(Frt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function zrt(){const t=H4e(Phe()).domain([1,10]);return t.copy=()=>SR(t,zrt()).base(t.base()),Yx.apply(t,arguments),t}function WOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function KOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function G4e(t){var s=1,r=t(WOe(s),KOe(s));return r.constant=function(n){return arguments.length?t(WOe(s=+n),KOe(s)):s},Gw(r)}function Brt(){var t=G4e(Phe());return t.copy=function(){return SR(t,Brt()).constant(t.constant())},Yx.apply(t,arguments)}function ZOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function Fls(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function zls(t){return t<0?-t*t:t*t}function W4e(t){var s=t(Om,Om),r=1;function n(){return r===1?t(Om,Om):r===.5?t(Fls,zls):t(ZOe(r),ZOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Gw(s)}function K4e(){var t=W4e(Phe());return t.copy=function(){return SR(t,K4e()).exponent(t.exponent())},Yx.apply(t,arguments),t}function Bls(){return K4e.apply(null,arguments).exponent(.5)}function YOe(t){return Math.sign(t)*t*t}function $ls(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function $rt(){var t=q4e(),s=[0,1],r=!1,n;function a(o){var l=$ls(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(YOe(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,Nce)).map(YOe)),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 $rt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Yx.apply(a,arguments),Gw(a)}function qrt(){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 Urt().domain([t,s]).range(a).unknown(o)},Yx.apply(Gw(l),arguments)}function Vrt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[NR(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 Vrt().domain(t).range(s).unknown(r)},Yx.apply(a,arguments)}const fye=new Date,xye=new Date;function Fu(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(uFu(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)=>(fye.setTime(+o),xye.setTime(+l),t(fye),t(xye),Math.floor(r(fye,xye))),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 Cce=Fu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);Cce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Fu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):Cce);Cce.range;const n1=1e3,Cx=n1*60,a1=Cx*60,R1=a1*24,Z4e=R1*7,QOe=R1*30,gye=R1*365,L4=Fu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*n1)},(t,s)=>(s-t)/n1,t=>t.getUTCSeconds());L4.range;const Y4e=Fu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*n1)},(t,s)=>{t.setTime(+t+s*Cx)},(t,s)=>(s-t)/Cx,t=>t.getMinutes());Y4e.range;const Q4e=Fu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*Cx)},(t,s)=>(s-t)/Cx,t=>t.getUTCMinutes());Q4e.range;const X4e=Fu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*n1-t.getMinutes()*Cx)},(t,s)=>{t.setTime(+t+s*a1)},(t,s)=>(s-t)/a1,t=>t.getHours());X4e.range;const J4e=Fu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*a1)},(t,s)=>(s-t)/a1,t=>t.getUTCHours());J4e.range;const CR=Fu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*Cx)/R1,t=>t.getDate()-1);CR.range;const Ihe=Fu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/R1,t=>t.getUTCDate()-1);Ihe.range;const Hrt=Fu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/R1,t=>Math.floor(t/R1));Hrt.range;function R3(t){return Fu(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())*Cx)/Z4e)}const Lhe=R3(0),Mce=R3(1),qls=R3(2),Uls=R3(3),vA=R3(4),Vls=R3(5),Hls=R3(6);Lhe.range;Mce.range;qls.range;Uls.range;vA.range;Vls.range;Hls.range;function F3(t){return Fu(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)/Z4e)}const Dhe=F3(0),Tce=F3(1),Gls=F3(2),Wls=F3(3),bA=F3(4),Kls=F3(5),Zls=F3(6);Dhe.range;Tce.range;Gls.range;Wls.range;bA.range;Kls.range;Zls.range;const eSe=Fu(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());eSe.range;const tSe=Fu(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());tSe.range;const F1=Fu(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());F1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Fu(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)});F1.range;const z1=Fu(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());z1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Fu(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)});z1.range;function Grt(t,s,r,n,a,o){const l=[[L4,1,n1],[L4,5,5*n1],[L4,15,15*n1],[L4,30,30*n1],[o,1,Cx],[o,5,5*Cx],[o,15,15*Cx],[o,30,30*Cx],[a,1,a1],[a,3,3*a1],[a,6,6*a1],[a,12,12*a1],[n,1,R1],[n,2,2*R1],[r,1,Z4e],[s,1,QOe],[s,3,3*QOe],[t,1,gye]];function i(u,m,f){const g=mj).right(l,g);if(y===l.length)return t.every(t_e(u/gye,m/gye,f));if(y===0)return Cce.every(Math.max(t_e(u,m,f),1));const[_,w]=l[g/l[y-1][2]53)return null;"w"in ve||(ve.w=1),"Z"in ve?(pe=vye(bI(ve.y,0,1)),Ue=pe.getUTCDay(),pe=Ue>4||Ue===0?Tce.ceil(pe):Tce(pe),pe=Ihe.offset(pe,(ve.V-1)*7),ve.y=pe.getUTCFullYear(),ve.m=pe.getUTCMonth(),ve.d=pe.getUTCDate()+(ve.w+6)%7):(pe=yye(bI(ve.y,0,1)),Ue=pe.getDay(),pe=Ue>4||Ue===0?Mce.ceil(pe):Mce(pe),pe=CR.offset(pe,(ve.V-1)*7),ve.y=pe.getFullYear(),ve.m=pe.getMonth(),ve.d=pe.getDate()+(ve.w+6)%7)}else("W"in ve||"U"in ve)&&("w"in ve||(ve.w="u"in ve?ve.u%7:"W"in ve?1:0),Ue="Z"in ve?vye(bI(ve.y,0,1)).getUTCDay():yye(bI(ve.y,0,1)).getDay(),ve.m=0,ve.d="W"in ve?(ve.w+6)%7+ve.W*7-(Ue+5)%7:ve.w+ve.U*7-(Ue+6)%7);return"Z"in ve?(ve.H+=ve.Z/100|0,ve.M+=ve.Z%100,vye(ve)):yye(ve)}}function $(ke,Oe,qe,ve){for(var dt=0,pe=Oe.length,Ue=qe.length,Xe,et;dt=Ue)return-1;if(Xe=Oe.charCodeAt(dt++),Xe===37){if(Xe=Oe.charAt(dt++),et=P[Xe in XOe?Oe.charAt(dt++):Xe],!et||(ve=et(ke,qe,ve))<0)return-1}else if(Xe!=qe.charCodeAt(ve++))return-1}return ve}function z(ke,Oe,qe){var ve=u.exec(Oe.slice(qe));return ve?(ke.p=m.get(ve[0].toLowerCase()),qe+ve[0].length):-1}function V(ke,Oe,qe){var ve=y.exec(Oe.slice(qe));return ve?(ke.w=_.get(ve[0].toLowerCase()),qe+ve[0].length):-1}function X(ke,Oe,qe){var ve=f.exec(Oe.slice(qe));return ve?(ke.w=g.get(ve[0].toLowerCase()),qe+ve[0].length):-1}function Y(ke,Oe,qe){var ve=N.exec(Oe.slice(qe));return ve?(ke.m=S.get(ve[0].toLowerCase()),qe+ve[0].length):-1}function J(ke,Oe,qe){var ve=w.exec(Oe.slice(qe));return ve?(ke.m=j.get(ve[0].toLowerCase()),qe+ve[0].length):-1}function Q(ke,Oe,qe){return $(ke,s,Oe,qe)}function ce(ke,Oe,qe){return $(ke,r,Oe,qe)}function ne(ke,Oe,qe){return $(ke,n,Oe,qe)}function re(ke){return l[ke.getDay()]}function oe(ke){return o[ke.getDay()]}function he(ke){return c[ke.getMonth()]}function xe(ke){return i[ke.getMonth()]}function ue(ke){return a[+(ke.getHours()>=12)]}function ge(ke){return 1+~~(ke.getMonth()/3)}function _e(ke){return l[ke.getUTCDay()]}function Be(ke){return o[ke.getUTCDay()]}function Se(ke){return c[ke.getUTCMonth()]}function Ee(ke){return i[ke.getUTCMonth()]}function Ae(ke){return a[+(ke.getUTCHours()>=12)]}function Me(ke){return 1+~~(ke.getUTCMonth()/3)}return{format:function(ke){var Oe=O(ke+="",M);return Oe.toString=function(){return ke},Oe},parse:function(ke){var Oe=q(ke+="",!1);return Oe.toString=function(){return ke},Oe},utcFormat:function(ke){var Oe=O(ke+="",I);return Oe.toString=function(){return ke},Oe},utcParse:function(ke){var Oe=q(ke+="",!0);return Oe.toString=function(){return ke},Oe}}}var XOe={"-":"",_:" ",0:"0"},uh=/^\s*\d+/,tcs=/^%/,scs=/[\\^$*+?|[\]().{}]/g;function rl(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function ncs(t,s,r){var n=uh.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function acs(t,s,r){var n=uh.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function ics(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function ocs(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function lcs(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function JOe(t,s,r){var n=uh.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function eRe(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function ccs(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 dcs(t,s,r){var n=uh.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function ucs(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function tRe(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function hcs(t,s,r){var n=uh.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function sRe(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function mcs(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function pcs(t,s,r){var n=uh.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function fcs(t,s,r){var n=uh.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function xcs(t,s,r){var n=uh.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function gcs(t,s,r){var n=tcs.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function ycs(t,s,r){var n=uh.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function vcs(t,s,r){var n=uh.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function rRe(t,s){return rl(t.getDate(),s,2)}function bcs(t,s){return rl(t.getHours(),s,2)}function _cs(t,s){return rl(t.getHours()%12||12,s,2)}function wcs(t,s){return rl(1+CR.count(F1(t),t),s,3)}function Wrt(t,s){return rl(t.getMilliseconds(),s,3)}function jcs(t,s){return Wrt(t,s)+"000"}function Ncs(t,s){return rl(t.getMonth()+1,s,2)}function kcs(t,s){return rl(t.getMinutes(),s,2)}function Scs(t,s){return rl(t.getSeconds(),s,2)}function Ccs(t){var s=t.getDay();return s===0?7:s}function Mcs(t,s){return rl(Lhe.count(F1(t)-1,t),s,2)}function Krt(t){var s=t.getDay();return s>=4||s===0?vA(t):vA.ceil(t)}function Tcs(t,s){return t=Krt(t),rl(vA.count(F1(t),t)+(F1(t).getDay()===4),s,2)}function Acs(t){return t.getDay()}function Ecs(t,s){return rl(Mce.count(F1(t)-1,t),s,2)}function Pcs(t,s){return rl(t.getFullYear()%100,s,2)}function Ics(t,s){return t=Krt(t),rl(t.getFullYear()%100,s,2)}function Lcs(t,s){return rl(t.getFullYear()%1e4,s,4)}function Dcs(t,s){var r=t.getDay();return t=r>=4||r===0?vA(t):vA.ceil(t),rl(t.getFullYear()%1e4,s,4)}function Ocs(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+rl(s/60|0,"0",2)+rl(s%60,"0",2)}function nRe(t,s){return rl(t.getUTCDate(),s,2)}function Rcs(t,s){return rl(t.getUTCHours(),s,2)}function Fcs(t,s){return rl(t.getUTCHours()%12||12,s,2)}function zcs(t,s){return rl(1+Ihe.count(z1(t),t),s,3)}function Zrt(t,s){return rl(t.getUTCMilliseconds(),s,3)}function Bcs(t,s){return Zrt(t,s)+"000"}function $cs(t,s){return rl(t.getUTCMonth()+1,s,2)}function qcs(t,s){return rl(t.getUTCMinutes(),s,2)}function Ucs(t,s){return rl(t.getUTCSeconds(),s,2)}function Vcs(t){var s=t.getUTCDay();return s===0?7:s}function Hcs(t,s){return rl(Dhe.count(z1(t)-1,t),s,2)}function Yrt(t){var s=t.getUTCDay();return s>=4||s===0?bA(t):bA.ceil(t)}function Gcs(t,s){return t=Yrt(t),rl(bA.count(z1(t),t)+(z1(t).getUTCDay()===4),s,2)}function Wcs(t){return t.getUTCDay()}function Kcs(t,s){return rl(Tce.count(z1(t)-1,t),s,2)}function Zcs(t,s){return rl(t.getUTCFullYear()%100,s,2)}function Ycs(t,s){return t=Yrt(t),rl(t.getUTCFullYear()%100,s,2)}function Qcs(t,s){return rl(t.getUTCFullYear()%1e4,s,4)}function Xcs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?bA(t):bA.ceil(t),rl(t.getUTCFullYear()%1e4,s,4)}function Jcs(){return"+0000"}function aRe(){return"%"}function iRe(t){return+t}function oRe(t){return Math.floor(+t/1e3)}var V5,Qrt,Xrt;eds({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 eds(t){return V5=ecs(t),Qrt=V5.format,V5.parse,Xrt=V5.utcFormat,V5.utcParse,V5}function tds(t){return new Date(t)}function sds(t){return t instanceof Date?+t:+new Date(+t)}function sSe(t,s,r,n,a,o,l,i,c,u){var m=q4e(),f=m.invert,g=m.domain,y=u(".%L"),_=u(":%S"),w=u("%I:%M"),j=u("%I %p"),N=u("%a %d"),S=u("%b %d"),M=u("%B"),I=u("%Y");function P(O){return(c(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Hos(t,o/n))},r.copy=function(){return snt(s).domain(t)},Q1.apply(r,arguments)}function Rhe(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=Om,m,f=!1,g;function y(w){return isNaN(w=+w)?g:(w=.5+((w=+m(w))-o)*(n*ws}var int=cds,dds=Fhe,uds=int,hds=FE;function mds(t){return t&&t.length?dds(t,hds,uds):void 0}var pds=mds;const zhe=Do(pds);function fds(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};ca.decimalPlaces=ca.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*jc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};ca.dividedBy=ca.div=function(t){return N1(this,new this.constructor(t))};ca.dividedToIntegerBy=ca.idiv=function(t){var s=this,r=s.constructor;return Bl(N1(s,new r(t),0,1),r.precision)};ca.equals=ca.eq=function(t){return!this.cmp(t)};ca.exponent=function(){return lu(this)};ca.greaterThan=ca.gt=function(t){return this.cmp(t)>0};ca.greaterThanOrEqualTo=ca.gte=function(t){return this.cmp(t)>=0};ca.isInteger=ca.isint=function(){return this.e>this.d.length-2};ca.isNegative=ca.isneg=function(){return this.s<0};ca.isPositive=ca.ispos=function(){return this.s>0};ca.isZero=function(){return this.s===0};ca.lessThan=ca.lt=function(t){return this.cmp(t)<0};ca.lessThanOrEqualTo=ca.lte=function(t){return this.cmp(t)<1};ca.logarithm=ca.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(mf))throw Error(Hx+"NaN");if(r.s<1)throw Error(Hx+(r.s?"NaN":"-Infinity"));return r.eq(mf)?new n(0):(qc=!1,s=N1(XD(r,o),XD(t,o),o),qc=!0,Bl(s,a))};ca.minus=ca.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?unt(s,t):cnt(s,(t.s=-t.s,t))};ca.modulo=ca.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Hx+"NaN");return r.s?(qc=!1,s=N1(r,t,0,1).times(t),qc=!0,r.minus(s)):Bl(new n(r),a)};ca.naturalExponential=ca.exp=function(){return dnt(this)};ca.naturalLogarithm=ca.ln=function(){return XD(this)};ca.negated=ca.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};ca.plus=ca.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?cnt(s,t):unt(s,(t.s=-t.s,t))};ca.precision=ca.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(FS+t);if(s=lu(a)+1,n=a.d.length-1,r=n*jc+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};ca.squareRoot=ca.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(Hx+"NaN")}for(t=lu(i),qc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=h0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=$E((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(N1(i,o,l+2)).times(.5),h0(o.d).slice(0,l)===(s=h0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(Bl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return qc=!0,Bl(n,r)};ca.times=ca.mul=function(t){var s,r,n,a,o,l,i,c,u,m=this,f=m.constructor,g=m.d,y=(t=new f(t)).d;if(!m.s||!t.s)return new f(0);for(t.s*=m.s,r=m.e+t.e,c=g.length,u=y.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+y[n]*g[a-n-1]+s,o[a--]=i%Ku|0,s=i/Ku|0;o[a]=(o[a]+s)%Ku|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,qc?Bl(t,f.precision):t};ca.toDecimalPlaces=ca.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(B0(t,0,BE),s===void 0?s=n.rounding:B0(s,0,8),Bl(r,t+lu(r)+1,s))};ca.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=f3(n,!0):(B0(t,0,BE),s===void 0?s=a.rounding:B0(s,0,8),n=Bl(new a(n),t+1,s),r=f3(n,!0,t+1)),r};ca.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?f3(a):(B0(t,0,BE),s===void 0?s=o.rounding:B0(s,0,8),n=Bl(new o(a),t+lu(a)+1,s),r=f3(n.abs(),!1,t+lu(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};ca.toInteger=ca.toint=function(){var t=this,s=t.constructor;return Bl(new s(t),lu(t)+1,s.rounding)};ca.toNumber=function(){return+this};ca.toPower=ca.pow=function(t){var s,r,n,a,o,l,i=this,c=i.constructor,u=12,m=+(t=new c(t));if(!t.s)return new c(mf);if(i=new c(i),!i.s){if(t.s<1)throw Error(Hx+"Infinity");return i}if(i.eq(mf))return i;if(n=c.precision,t.eq(mf))return Bl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=m<0?-m:m)<=lnt){for(a=new c(mf),s=Math.ceil(n/jc+4),qc=!1;r%2&&(a=a.times(i),dRe(a.d,s)),r=$E(r/2),r!==0;)i=i.times(i),dRe(i.d,s);return qc=!0,t.s<0?new c(mf).div(a):Bl(a,n)}}else if(o<0)throw Error(Hx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,qc=!1,a=t.times(XD(i,n+u)),qc=!0,a=dnt(a),a.s=o,a};ca.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=lu(a),n=f3(a,r<=o.toExpNeg||r>=o.toExpPos)):(B0(t,1,BE),s===void 0?s=o.rounding:B0(s,0,8),a=Bl(new o(a),t,s),r=lu(a),n=f3(a,t<=r||r<=o.toExpNeg,t)),n};ca.toSignificantDigits=ca.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(B0(t,1,BE),s===void 0?s=n.rounding:B0(s,0,8)),Bl(new n(r),t,s)};ca.toString=ca.valueOf=ca.val=ca.toJSON=ca[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=lu(t),r=t.constructor;return f3(t,s<=r.toExpNeg||s>=r.toExpPos)};function cnt(t,s){var r,n,a,o,l,i,c,u,m=t.constructor,f=m.precision;if(!t.s||!s.s)return s.s||(s=new m(t)),qc?Bl(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/jc),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)/Ku|0,c[o]%=Ku;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,qc?Bl(s,f):s}function B0(t,s,r){if(t!==~~t||tr)throw Error(FS+t)}function h0(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,m,f,g,y,_,w,j,N,S,M,I,P,O,q,$,z=n.constructor,V=n.s==a.s?1:-1,X=n.d,Y=a.d;if(!n.s)return new z(n);if(!a.s)throw Error(Hx+"Division by zero");for(c=n.e-a.e,q=Y.length,P=X.length,y=new z(V),_=y.d=[],u=0;Y[u]==(X[u]||0);)++u;if(Y[u]>(X[u]||0)&&--c,o==null?S=o=z.precision:l?S=o+(lu(n)-lu(a))+1:S=o,S<0)return new z(0);if(S=S/jc+2|0,u=0,q==1)for(m=0,Y=Y[0],S++;(u1&&(Y=t(Y,m),X=t(X,m),q=Y.length,P=X.length),I=q,w=X.slice(0,q),j=w.length;j=Ku/2&&++O;do m=0,i=s(Y,w,q,j),i<0?(N=w[0],q!=j&&(N=N*Ku+(w[1]||0)),m=N/O|0,m>1?(m>=Ku&&(m=Ku-1),f=t(Y,m),g=f.length,j=w.length,i=s(f,w,g,j),i==1&&(m--,r(f,q16)throw Error(aSe+lu(t));if(!t.s)return new m(mf);for(qc=!1,i=f,l=new m(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(m4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new m(mf),m.precision=i;;){if(a=Bl(a.times(t),i),r=r.times(++c),l=o.plus(N1(a,r,i)),h0(l.d).slice(0,i)===h0(o.d).slice(0,i)){for(;u--;)o=Bl(o.times(o),i);return m.precision=f,s==null?(qc=!0,Bl(o,f)):o}o=l}}function lu(t){for(var s=t.e*jc,r=t.d[0];r>=10;r/=10)s++;return s}function bye(t,s,r){if(s>t.LN10.sd())throw qc=!0,r&&(t.precision=r),Error(Hx+"LN10 precision limit exceeded");return Bl(new t(t.LN10),s)}function l_(t){for(var s="";t--;)s+="0";return s}function XD(t,s){var r,n,a,o,l,i,c,u,m,f=1,g=10,y=t,_=y.d,w=y.constructor,j=w.precision;if(y.s<1)throw Error(Hx+(y.s?"NaN":"-Infinity"));if(y.eq(mf))return new w(0);if(s==null?(qc=!1,u=j):u=s,y.eq(10))return s==null&&(qc=!0),bye(w,u);if(u+=g,w.precision=u,r=h0(_),n=r.charAt(0),o=lu(y),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)y=y.times(t),r=h0(y.d),n=r.charAt(0),f++;o=lu(y),n>1?(y=new w("0."+r),o++):y=new w(n+"."+r.slice(1))}else return c=bye(w,u+2,j).times(o+""),y=XD(new w(n+"."+r.slice(1)),u-g).plus(c),w.precision=j,s==null?(qc=!0,Bl(y,j)):y;for(i=l=y=N1(y.minus(mf),y.plus(mf),u),m=Bl(y.times(y),u),a=3;;){if(l=Bl(l.times(m),u),c=i.plus(N1(l,new w(a),u)),h0(c.d).slice(0,u)===h0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(bye(w,u+2,j).times(o+""))),i=N1(i,new w(f),u),w.precision=j,s==null?(qc=!0,Bl(i,j)):i;i=c,a+=2}}function cRe(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=$E(r/jc),t.d=[],n=(r+1)%jc,r<0&&(n+=jc),nAce||t.e<-Ace))throw Error(aSe+r)}else t.s=0,t.e=0,t.d=[0];return t}function Bl(t,s,r){var n,a,o,l,i,c,u,m,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=jc,a=s,u=f[m=0];else{if(m=Math.ceil((n+1)/jc),o=f.length,m>=o)return t;for(u=o=f[m],l=1;o>=10;o/=10)l++;n%=jc,a=n-jc+l}if(r!==void 0&&(o=m4(10,l-a-1),i=u/o%10|0,c=s<0||f[m+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/m4(10,l-a):0:f[m-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=lu(t),f.length=1,s=s-o-1,f[0]=m4(10,(jc-s%jc)%jc),t.e=$E(-s/jc)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=m,o=1,m--):(f.length=m+1,o=m4(10,jc-n),f[m]=a>0?(u/m4(10,l-a)%m4(10,a)|0)*o:0),c)for(;;)if(m==0){(f[0]+=o)==Ku&&(f[0]=1,++t.e);break}else{if(f[m]+=o,f[m]!=Ku)break;f[m--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(qc&&(t.e>Ace||t.e<-Ace))throw Error(aSe+lu(t));return t}function unt(t,s){var r,n,a,o,l,i,c,u,m,f,g=t.constructor,y=g.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new g(t),qc?Bl(s,y):s;if(c=t.d,f=s.d,n=s.e,u=t.e,c=c.slice(),l=u-n,l){for(m=l<0,m?(r=c,l=-l,i=f.length):(r=f,n=u,i=c.length),a=Math.max(Math.ceil(y/jc),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,m=a0;--a)c[i++]=0;for(a=f.length;a>l;){if(c[--a]0?o=o.charAt(0)+"."+o.slice(1)+l_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+l_(-a-1)+o,r&&(n=r-l)>0&&(o+=l_(n))):a>=l?(o+=l_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+l_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=l_(n))),t.s<0?"-"+o:o}function dRe(t,s){if(t.length>s)return t.length=s,!0}function hnt(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(FS+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 cRe(l,o.toString())}else if(typeof o!="string")throw Error(FS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,Ods.test(o))cRe(l,o);else throw Error(FS+o)}if(a.prototype=ca,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=hnt,a.config=a.set=Rds,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(FS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(FS+r+": "+n);return this}var iSe=hnt(Dds);mf=new iSe(1);const Cl=iSe;function Fds(t){return qds(t)||$ds(t)||Bds(t)||zds()}function zds(){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 Bds(t,s){if(t){if(typeof t=="string")return i_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 i_e(t,s)}}function $ds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function qds(t){if(Array.isArray(t))return i_e(t)}function i_e(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,uRe(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 rus(t){if(Array.isArray(t))return t}function gnt(t){var s=JD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function ynt(t,s,r){if(t.lte(0))return new Cl(0);var n=qhe.getDigitCount(t.toNumber()),a=new Cl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new Cl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new Cl(Math.ceil(c))}function nus(t,s,r){var n=1,a=new Cl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new Cl(10).pow(qhe.getDigitCount(t)-1),a=new Cl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Cl(Math.floor(t)))}else t===0?a=new Cl(Math.floor((s-1)/2)):r||(a=new Cl(Math.floor(t)));var l=Math.floor((s-1)/2),i=Gds(Hds(function(c){return a.add(new Cl(c-l).mul(n)).toNumber()}),o_e);return i(0,s)}function vnt(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 Cl(0),tickMin:new Cl(0),tickMax:new Cl(0)};var o=ynt(new Cl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new Cl(0):(l=new Cl(t).add(s).div(2),l=l.sub(new Cl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new Cl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?vnt(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new Cl(i).mul(o)),tickMax:l.add(new Cl(c).mul(o))})}function aus(t){var s=JD(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=gnt([r,n]),c=JD(i,2),u=c[0],m=c[1];if(u===-1/0||m===1/0){var f=m===1/0?[u].concat(c_e(o_e(0,a-1).map(function(){return 1/0}))):[].concat(c_e(o_e(0,a-1).map(function(){return-1/0})),[m]);return r>n?l_e(f):f}if(u===m)return nus(u,a,o);var g=vnt(u,m,l,o),y=g.step,_=g.tickMin,w=g.tickMax,j=qhe.rangeStep(_,w.add(new Cl(.1).mul(y)),y);return r>n?l_e(j):j}function ius(t,s){var r=JD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=gnt([n,a]),i=JD(l,2),c=i[0],u=i[1];if(c===-1/0||u===1/0)return[n,a];if(c===u)return[c];var m=Math.max(s,2),f=ynt(new Cl(u).sub(c).div(m-1),o,0),g=[].concat(c_e(qhe.rangeStep(new Cl(c),new Cl(u).sub(new Cl(.99).mul(f)),f)),[u]);return n>a?l_e(g):g}var ous=fnt(aus),lus=fnt(ius),cus="Invariant failed";function x3(t,s){throw new Error(cus)}var dus=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function _A(t){"@babel/helpers - typeof";return _A=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},_A(t)}function Ece(){return Ece=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 gus(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 yus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function vus(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,y=void 0;if(Lm(f-m)!==Lm(g-f)){var _=[];if(Lm(g-f)===Lm(c[1]-c[0])){y=g;var w=f+c[1]-c[0];_[0]=Math.min(w,(w+m)/2),_[1]=Math.max(w,(w+m)/2)}else{y=m;var j=g+c[1]-c[0];_[0]=Math.min(f,(j+f)/2),_[1]=Math.max(f,(j+f)/2)}var N=[Math.min(f,(y+f)/2),Math.max(f,(y+f)/2)];if(s>N[0]&&s<=N[1]||s>=_[0]&&s<=_[1]){l=a[u].index;break}}else{var S=Math.min(m,g),M=Math.max(m,g);if(s>(S+f)/2&&s<=(M+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},oSe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?xd(xd({},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},Ous=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?xd(xd({},S),N[0].props):N[0].props,I=M.barSize,P=M[j];l[P]||(l[P]=[]);var O=Ui(I)?r:I;l[P].push({item:N[0],stackList:N.slice(1),barSize:Ui(O)?void 0:Dm(O,n,0)})}}return l},Rus=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=Dm(r,a,0,!0),m,f=[];if(l[0].barSize===+l[0].barSize){var g=!1,y=a/c,_=l.reduce(function(I,P){return I+P.barSize||0},0);_+=(c-1)*u,_>=a&&(_-=(c-1)*u,u=0),_>=a&&y>0&&(g=!0,y*=.9,_=c*y);var w=(a-_)/2>>0,j={offset:w-u,size:0};m=l.reduce(function(I,P){var O={item:P.item,position:{offset:j.offset+j.size+u,size:g?y:P.barSize}},q=[].concat(pRe(I),[O]);return j=q[q.length-1].position,P.stackList&&P.stackList.length&&P.stackList.forEach(function($){q.push({item:$,position:j})}),q},f)}else{var N=Dm(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;m=l.reduce(function(I,P,O){var q=[].concat(pRe(I),[{item:P.item,position:{offset:N+(S+u)*O+(S-M)/2,size:M}}]);return P.stackList&&P.stackList.length&&P.stackList.forEach(function($){q.push({item:$,position:q[q.length-1].position})}),q},f)}return m},Fus=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=jnt({children:o,legendWidth:c});if(u){var m=a||{},f=m.width,g=m.height,y=u.align,_=u.verticalAlign,w=u.layout;if((w==="vertical"||w==="horizontal"&&_==="middle")&&y!=="center"&&pn(s[y]))return xd(xd({},s),{},NT({},y,s[y]+(f||0)));if((w==="horizontal"||w==="vertical"&&y==="center")&&_!=="middle"&&pn(s[_]))return xd(xd({},s),{},NT({},_,s[_]+(g||0)))}return s},zus=function(s,r,n){return Ui(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Nnt=function(s,r,n,a,o){var l=r.props.children,i=Sf(l,TR).filter(function(u){return zus(a,o,u.props.direction)});if(i&&i.length){var c=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,m){var f=ku(m,n);if(Ui(f))return u;var g=Array.isArray(f)?[Bhe(f),zhe(f)]:[f,f],y=c.reduce(function(_,w){var j=ku(m,w,0),N=g[0]-Math.abs(Array.isArray(j)?j[0]:j),S=g[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(N,_[0]),Math.max(S,_[1])]},[1/0,-1/0]);return[Math.min(y[0],u[0]),Math.max(y[1],u[1])]},[1/0,-1/0])}return null},Bus=function(s,r,n,a,o){var l=r.map(function(i){return Nnt(s,i,n,o,a)}).filter(function(i){return!Ui(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},knt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&Nnt(s,c,u,a)||P8(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 m=0,f=u.length;m=2?Lm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var m=(s.ticks||s.niceTicks).map(function(f){var g=o?o.indexOf(f):f;return{coordinate:a(g)+u,value:f,offset:u}});return m.filter(function(f){return!_R(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}})},_ye=new WeakMap,s9=function(s,r){if(typeof r!="function")return s;_ye.has(s)||_ye.set(s,new WeakMap);var n=_ye.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},Mnt=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:WD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Sce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:E8(),realScaleType:"point"}:o==="category"?{scale:WD(),realScaleType:"band"}:{scale:Sce(),realScaleType:"linear"};if(h3(a)){var c="scale".concat(khe(a));return{scale:(lRe[c]||E8)(),realScaleType:lRe[c]?c:"point"}}return Ai(a)?{scale:a}:{scale:E8(),realScaleType:"point"}},xRe=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])-xRe,l=Math.max(a[0],a[1])+xRe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},$us=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])}},Vus=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)}},Hus={sign:Uus,expand:dXt,none:mA,silhouette:uXt,wiggle:hXt,positive:Vus},Gus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Hus[n],l=cXt().keys(a).value(function(i,c){return+ku(i,c,0)}).order(Rbe).offset(o);return l(s)},Wus=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 y,_=(y=g.type)!==null&&y!==void 0&&y.defaultProps?xd(xd({},g.type.defaultProps),g.props):g.props,w=_.stackId,j=_.hide;if(j)return f;var N=_[n],S=f[N]||{hasStack:!1,stackGroups:{}};if(Cu(w)){var M=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};M.items.push(g),S.hasStack=!0,S.stackGroups[w]=M}else S.stackGroups[DE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return xd(xd({},f),{},NT({},N,S))},c),m={};return Object.keys(u).reduce(function(f,g){var y=u[g];if(y.hasStack){var _={};y.stackGroups=Object.keys(y.stackGroups).reduce(function(w,j){var N=y.stackGroups[j];return xd(xd({},w),{},NT({},j,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:Gus(s,N.items,o)}))},_)}return xd(xd({},f),{},NT({},g,y))},m)},Ant=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 m=ous(u,o,i);return s.domain([Bhe(m),zhe(m)]),{niceTicks:m}}if(o&&a==="number"){var f=s.domain(),g=lus(f,o,i);return{niceTicks:g}}return null};function gRe(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&&!Ui(a[s.dataKey])){var i=ace(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=ku(a,Ui(l)?s.dataKey:l);return Ui(c)?null:s.scale(c)}var yRe=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=ku(l,r.dataKey,r.domain[i]);return Ui(c)?null:r.scale(c)-o/2+a},Kus=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]},Zus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?xd(xd({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Cu(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},Yus=function(s){return s.reduce(function(r,n){return[Bhe(n.concat([r[0]]).filter(pn)),zhe(n.concat([r[1]]).filter(pn))]},[1/0,-1/0])},Ent=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,c=i.reduce(function(u,m){var f=Yus(m.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})},vRe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,bRe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,m_e=function(s,r,n){if(Ai(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(pn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(vRe.test(s[0])){var o=+vRe.exec(s[0])[1];a[0]=r[0]-o}else Ai(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(pn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(bRe.test(s[1])){var l=+bRe.exec(s[1])[1];a[1]=r[1]+l}else Ai(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},Ice=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=D4e(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},ahs=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,m=Dm(s.cx,l,l/2),f=Dm(s.cy,i,i/2),g=Lnt(l,i,n),y=Dm(s.innerRadius,g,0),_=Dm(s.outerRadius,g,g*.8),w=Object.keys(r);return w.reduce(function(j,N){var S=r[N],M=S.domain,I=S.reversed,P;if(Ui(S.range))a==="angleAxis"?P=[c,u]:a==="radiusAxis"&&(P=[y,_]),I&&(P=[P[1],P[0]]);else{P=S.range;var O=P,q=Jus(O,2);c=q[0],u=q[1]}var $=Mnt(S,o),z=$.realScaleType,V=$.scale;V.domain(M).range(P),Tnt(V);var X=Ant(V,$v($v({},S),{},{realScaleType:z})),Y=$v($v($v({},S),X),{},{range:P,radius:_,realScaleType:z,scale:V,cx:m,cy:f,innerRadius:y,outerRadius:_,startAngle:c,endAngle:u});return $v($v({},j),{},Int({},N,Y))},{})},ihs=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))},ohs=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=ihs({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:nhs(u),angleInRadian:u}},lhs=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}},chs=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},NRe=function(s,r){var n=s.x,a=s.y,o=ohs({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 m=lhs(r),f=m.startAngle,g=m.endAngle,y=i,_;if(f<=g){for(;y>g;)y-=360;for(;y=f&&y<=g}else{for(;y>f;)y-=360;for(;y=g&&y<=f}return _?$v($v({},r),{},{radius:l,angle:chs(y,r)}):null},Dnt=function(s){return!k.isValidElement(s)&&!Ai(s)&&typeof s!="boolean"?s.className:""};function rO(t){"@babel/helpers - typeof";return rO=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},rO(t)}var dhs=["offset"];function uhs(t){return fhs(t)||phs(t)||mhs(t)||hhs()}function hhs(){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 mhs(t,s){if(t){if(typeof t=="string")return p_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 p_e(t,s)}}function phs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function fhs(t){if(Array.isArray(t))return p_e(t)}function p_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 ghs(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 kRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function xu(t){for(var s=1;s=0?1:-1,M,I;a==="insideStart"?(M=y+S*l,I=w):a==="insideEnd"?(M=_-S*l,I=!w):a==="end"&&(M=_+S*l,I=w),I=N<=0?I:!I;var P=dc(u,m,j,M),O=dc(u,m,j,M+(I?1:-1)*359),q="M".concat(P.x,",").concat(P.y,` A`).concat(j,",").concat(j,",0,1,").concat(I?0:1,`, `).concat(O.x,",").concat(O.y),$=Ui(s.id)?DE("recharts-radial-line-"):s.id;return mt.createElement("text",nO({},n,{dominantBaseline:"central",className:Hi("recharts-radial-bar-label",i)}),mt.createElement("defs",null,mt.createElement("path",{id:$,d:q})),mt.createElement("textPath",{xlinkHref:"#".concat($)},r))},Nhs=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,m=o.startAngle,f=o.endAngle,g=(m+f)/2;if(a==="outside"){var y=dc(l,i,u+n,g),_=y.x,w=y.y;return{x:_,y:w,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 j=(c+u)/2,N=dc(l,i,j,g),S=N.x,M=N.y;return{x:S,y:M,textAnchor:"middle",verticalAnchor:"middle"}},khs=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,m=l.height,f=m>=0?1:-1,g=f*a,y=f>0?"end":"start",_=f>0?"start":"end",w=u>=0?1:-1,j=w*a,N=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var M={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:y};return xu(xu({},M),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:c+m+g,textAnchor:"middle",verticalAnchor:_};return xu(xu({},I),n?{height:Math.max(n.y+n.height-(c+m),0),width:u}:{})}if(o==="left"){var P={x:i-j,y:c+m/2,textAnchor:N,verticalAnchor:"middle"};return xu(xu({},P),n?{width:Math.max(P.x-n.x,0),height:m}:{})}if(o==="right"){var O={x:i+u+j,y:c+m/2,textAnchor:S,verticalAnchor:"middle"};return xu(xu({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:m}:{})}var q=n?{width:u,height:m}:{};return o==="insideLeft"?xu({x:i+j,y:c+m/2,textAnchor:S,verticalAnchor:"middle"},q):o==="insideRight"?xu({x:i+u-j,y:c+m/2,textAnchor:N,verticalAnchor:"middle"},q):o==="insideTop"?xu({x:i+u/2,y:c+g,textAnchor:"middle",verticalAnchor:_},q):o==="insideBottom"?xu({x:i+u/2,y:c+m-g,textAnchor:"middle",verticalAnchor:y},q):o==="insideTopLeft"?xu({x:i+j,y:c+g,textAnchor:S,verticalAnchor:_},q):o==="insideTopRight"?xu({x:i+u-j,y:c+g,textAnchor:N,verticalAnchor:_},q):o==="insideBottomLeft"?xu({x:i+j,y:c+m-g,textAnchor:S,verticalAnchor:y},q):o==="insideBottomRight"?xu({x:i+u-j,y:c+m-g,textAnchor:N,verticalAnchor:y},q):EE(o)&&(pn(o.x)||P4(o.x))&&(pn(o.y)||P4(o.y))?xu({x:i+Dm(o.x,u),y:c+Dm(o.y,m),textAnchor:"end",verticalAnchor:"end"},q):xu({x:i+u/2,y:c+m/2,textAnchor:"middle",verticalAnchor:"middle"},q)},Shs=function(s){return"cx"in s&&pn(s.cx)};function Ju(t){var s=t.offset,r=s===void 0?5:s,n=xhs(t,dhs),a=xu({offset:r},n),o=a.viewBox,l=a.position,i=a.value,c=a.children,u=a.content,m=a.className,f=m===void 0?"":m,g=a.textBreakAll;if(!o||Ui(i)&&Ui(c)&&!k.isValidElement(u)&&!Ai(u))return null;if(k.isValidElement(u))return k.cloneElement(u,a);var y;if(Ai(u)){if(y=k.createElement(u,a),k.isValidElement(y))return y}else y=_hs(a);var _=Shs(o),w=di(a,!0);if(_&&(l==="insideStart"||l==="insideEnd"||l==="end"))return jhs(a,y,w);var j=_?Nhs(a):khs(a);return mt.createElement(p3,nO({className:Hi("recharts-label",f)},w,j,{breakAll:g}),y)}Ju.displayName="Label";var Ont=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,m=s.outerRadius,f=s.x,g=s.y,y=s.top,_=s.left,w=s.width,j=s.height,N=s.clockWise,S=s.labelViewBox;if(S)return S;if(pn(w)&&pn(j)){if(pn(f)&&pn(g))return{x:f,y:g,width:w,height:j};if(pn(y)&&pn(_))return{x:y,y:_,width:w,height:j}}return pn(f)&&pn(g)?{x:f,y:g,width:0,height:0}:pn(r)&&pn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:m||c||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},Chs=function(s,r){return s?s===!0?mt.createElement(Ju,{key:"label-implicit",viewBox:r}):Cu(s)?mt.createElement(Ju,{key:"label-implicit",viewBox:r,value:s}):k.isValidElement(s)?s.type===Ju?k.cloneElement(s,{key:"label-implicit",viewBox:r}):mt.createElement(Ju,{key:"label-implicit",content:s,viewBox:r}):Ai(s)?mt.createElement(Ju,{key:"label-implicit",content:s,viewBox:r}):EE(s)?mt.createElement(Ju,nO({viewBox:r},s,{key:"label-implicit"})):null:null},Mhs=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=Ont(s),l=Sf(a,Ju).map(function(c,u){return k.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Chs(s.label,r||o);return[i].concat(uhs(l))};Ju.parseViewBox=Ont;Ju.renderCallByParent=Mhs;function Ths(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Ahs=Ths;const Ehs=Do(Ahs);function aO(t){"@babel/helpers - typeof";return aO=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},aO(t)}var Phs=["valueAccessor"],Ihs=["data","dataKey","clockWise","id","textBreakAll"];function Lhs(t){return Fhs(t)||Rhs(t)||Ohs(t)||Dhs()}function Dhs(){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 Ohs(t,s){if(t){if(typeof t=="string")return f_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 f_e(t,s)}}function Rhs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Fhs(t){if(Array.isArray(t))return f_e(t)}function f_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 qhs(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 Uhs=function(s){return Array.isArray(s.value)?Ehs(s.value):s.value};function k1(t){var s=t.valueAccessor,r=s===void 0?Uhs:s,n=MRe(t,Phs),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=MRe(n,Ihs);return!a||!a.length?null:mt.createElement(Xo,{className:"recharts-label-list"},a.map(function(m,f){var g=Ui(o)?r(m,f):ku(m&&m.payload,o),y=Ui(i)?{}:{id:"".concat(i,"-").concat(f)};return mt.createElement(Ju,Dce({},di(m,!0),u,y,{parentViewBox:m.parentViewBox,value:g,textBreakAll:c,viewBox:Ju.parseViewBox(Ui(l)?m:CRe(CRe({},m),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}k1.displayName="LabelList";function Vhs(t,s){return t?t===!0?mt.createElement(k1,{key:"labelList-implicit",data:s}):mt.isValidElement(t)||Ai(t)?mt.createElement(k1,{key:"labelList-implicit",data:s,content:t}):EE(t)?mt.createElement(k1,Dce({data:s},t,{key:"labelList-implicit"})):null:null}function Hhs(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=Sf(n,k1).map(function(l,i){return k.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Vhs(t.label,s);return[o].concat(Lhs(a))}k1.renderCallByParent=Hhs;function iO(t){"@babel/helpers - typeof";return iO=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},iO(t)}function x_e(){return x_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 y=dc(r,n,a,l),_=dc(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(y.x,",").concat(y.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},Yhs=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,m=s.endAngle,f=Lm(m-u),g=r9({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),y=g.circleTangency,_=g.lineTangency,w=g.theta,j=r9({cx:r,cy:n,radius:o,angle:m,sign:-f,cornerRadius:l,cornerIsExternal:c}),N=j.circleTangency,S=j.lineTangency,M=j.theta,I=c?Math.abs(u-m):Math.abs(u-m)-w-M;if(I<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 `):Rnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:m});var P="M ".concat(_.x,",").concat(_.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(y.x,",").concat(y.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>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=r9({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),q=O.circleTangency,$=O.lineTangency,z=O.theta,V=r9({cx:r,cy:n,radius:a,angle:m,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),X=V.circleTangency,Y=V.lineTangency,J=V.theta,Q=c?Math.abs(u-m):Math.abs(u-m)-z-J;if(Q<0&&l===0)return"".concat(P,"L").concat(r,",").concat(n,"Z");P+="L".concat(Y.x,",").concat(Y.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(X.x,",").concat(X.y,` A`).concat(a,",").concat(a,",0,").concat(+(Q>180),",").concat(+(f>0),",").concat(q.x,",").concat(q.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat($.x,",").concat($.y,"Z")}else P+="L".concat(r,",").concat(n,"Z");return P},Qhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Fnt=function(s){var r=ARe(ARe({},Qhs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,m=r.startAngle,f=r.endAngle,g=r.className;if(l0&&Math.abs(m-f)<360?j=Yhs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,_/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:m,endAngle:f}):j=Rnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:m,endAngle:f}),mt.createElement("path",x_e({},di(r,!0),{className:y,d:j,role:"img"}))};function oO(t){"@babel/helpers - typeof";return oO=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},oO(t)}function g_e(){return g_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 xms(t,s){return z3(t.getTime(),s.getTime())}function gms(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function yms(t,s){return t===s}function FRe(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(),m=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var g=l.value,y=i.value;if(r.equals(g[0],y[0],c,f,t,s,r)&&r.equals(g[1],y[1],g[0],y[0],t,s,r)){m=a[f]=!0;break}f++}if(!m)return!1;c++}return!0}var vms=z3;function bms(t,s,r){var n=RRe(t),a=n.length;if(RRe(s).length!==a)return!1;for(;a-- >0;)if(!qnt(t,s,r,n[a]))return!1;return!0}function kI(t,s,r){var n=DRe(t),a=n.length;if(DRe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!qnt(t,s,r,o)||(l=ORe(t,o),i=ORe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function _ms(t,s){return z3(t.valueOf(),s.valueOf())}function wms(t,s){return t.source===s.source&&t.flags===s.flags}function zRe(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,m=0;(i=c.next())&&!i.done;){if(!a[m]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[m]=!0;break}m++}if(!u)return!1}return!0}function jms(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 Nms(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 qnt(t,s,r,n){return(n===pms||n===mms||n===hms)&&(t.$$typeof||s.$$typeof)?!0:ums(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var kms="[object Arguments]",Sms="[object Boolean]",Cms="[object Date]",Mms="[object Error]",Tms="[object Map]",Ams="[object Number]",Ems="[object Object]",Pms="[object RegExp]",Ims="[object Set]",Lms="[object String]",Dms="[object URL]",Oms=Array.isArray,BRe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,$Re=Object.assign,Rms=Object.prototype.toString.call.bind(Object.prototype.toString);function Fms(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,m=t.areSetsEqual,f=t.areTypedArraysEqual,g=t.areUrlsEqual;return function(_,w,j){if(_===w)return!0;if(_==null||w==null)return!1;var N=typeof _;if(N!==typeof w)return!1;if(N!=="object")return N==="number"?l(_,w,j):N==="function"?a(_,w,j):!1;var S=_.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(_,w,j);if(Oms(_))return s(_,w,j);if(BRe!=null&&BRe(_))return f(_,w,j);if(S===Date)return r(_,w,j);if(S===RegExp)return u(_,w,j);if(S===Map)return o(_,w,j);if(S===Set)return m(_,w,j);var M=Rms(_);return M===Cms?r(_,w,j):M===Pms?u(_,w,j):M===Tms?o(_,w,j):M===Ims?m(_,w,j):M===Ems?typeof _.then!="function"&&typeof w.then!="function"&&i(_,w,j):M===Dms?g(_,w,j):M===Mms?n(_,w,j):M===kms?i(_,w,j):M===Sms||M===Ams||M===Lms?c(_,w,j):!1}}function zms(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?kI:fms,areDatesEqual:xms,areErrorsEqual:gms,areFunctionsEqual:yms,areMapsEqual:n?LRe(FRe,kI):FRe,areNumbersEqual:vms,areObjectsEqual:n?kI:bms,arePrimitiveWrappersEqual:_ms,areRegExpsEqual:wms,areSetsEqual:n?LRe(zRe,kI):zRe,areTypedArraysEqual:n?kI:jms,areUrlsEqual:Nms};if(r&&(a=$Re({},a,r(a))),s){var o=a9(a.areArraysEqual),l=a9(a.areMapsEqual),i=a9(a.areObjectsEqual),c=a9(a.areSetsEqual);a=$Re({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function Bms(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function $ms(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(c,u){var m=n(),f=m.cache,g=f===void 0?s?new WeakMap:void 0:f,y=m.meta;return r(c,u,{cache:g,equals:a,meta:y,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 qms=Kw();Kw({strict:!0});Kw({circular:!0});Kw({circular:!0,strict:!0});Kw({createInternalComparator:function(){return z3}});Kw({strict:!0,createInternalComparator:function(){return z3}});Kw({circular:!0,createInternalComparator:function(){return z3}});Kw({circular:!0,createInternalComparator:function(){return z3},strict:!0});function Kw(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=zms(t),c=Fms(i),u=n?n(c):Bms(c);return $ms({circular:r,comparator:c,createState:a,equals:u,strict:l})}function Ums(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function qRe(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):Ums(a)};requestAnimationFrame(n)}function y_e(t){"@babel/helpers - typeof";return y_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},y_e(t)}function Vms(t){return Kms(t)||Wms(t)||Gms(t)||Hms()}function Hms(){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 Gms(t,s){if(t){if(typeof t=="string")return URe(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 URe(t,s)}}function URe(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},w=function(N){for(var S=N>1?1:N,M=S,I=0;I<8;++I){var P=f(M)-S,O=y(M);if(Math.abs(P-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(m,f,g){var y=-(m-f)*n,_=g*o,w=g+(y-_)*i/1e3,j=g*i/1e3+m;return Math.abs(j-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function kps(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 wye(t){return Tps(t)||Mps(t)||Cps(t)||Sps()}function Sps(){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 Cps(t,s){if(t){if(typeof t=="string")return j_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 j_e(t,s)}}function Mps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Tps(t){if(Array.isArray(t))return j_e(t)}function j_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 zce(t){return zce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},zce(t)}var $0=function(t){Lps(r,t);var s=Dps(r);function r(n,a){var o;Aps(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,c=l.attributeName,u=l.from,m=l.to,f=l.steps,g=l.children,y=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(S_e(o)),o.changeStyle=o.changeStyle.bind(S_e(o)),!i||y<=0)return o.state={style:{}},typeof g=="function"&&(o.state={style:m}),k_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof g=="function")return o.state={style:u},k_e(o);o.state={style:c?KI({},c,u):u}}else o.state={style:{}};return o}return Pps(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,m=o.to,f=o.from,g=this.state.style;if(i){if(!l){var y={style:c?KI({},c,m):m};this.state&&g&&(c&&g[c]!==m||!c&&g!==m)&&this.setState(y);return}if(!(qms(a.to,m)&&a.canBegin&&a.isActive)){var _=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=_||u?f:a.to;if(this.state&&g){var j={style:c?KI({},c,w):w};(c&&g[c]!==w||!c&&g!==w)&&this.setState(j)}this.runAnimation(Tg(Tg({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,c=a.duration,u=a.easing,m=a.begin,f=a.onAnimationEnd,g=a.onAnimationStart,y=wps(l,i,ups(u),c,this.changeStyle),_=function(){o.stopJSAnimation=y()};this.manager.start([g,m,_,c,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,c=a.onAnimationStart,u=l[0],m=u.style,f=u.duration,g=f===void 0?0:f,y=function(w,j,N){if(N===0)return w;var S=j.duration,M=j.easing,I=M===void 0?"ease":M,P=j.style,O=j.properties,q=j.onAnimationEnd,$=N>0?l[N-1]:j,z=O||Object.keys(P);if(typeof I=="function"||I==="spring")return[].concat(wye(w),[o.runJSAnimation.bind(o,{from:$.style,to:P,duration:S,easing:I}),S]);var V=GRe(z,S,I),X=Tg(Tg(Tg({},$.style),P),{},{transition:V});return[].concat(wye(w),[X,S,q]).filter(Jms)};return this.manager.start([c].concat(wye(l.reduce(y,[m,Math.max(g,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Zms());var o=a.begin,l=a.duration,i=a.attributeName,c=a.to,u=a.easing,m=a.onAnimationStart,f=a.onAnimationEnd,g=a.steps,y=a.children,_=this.manager;if(this.unSubscribe=_.subscribe(this.handleStyleChange),typeof u=="function"||typeof y=="function"||u==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var w=i?KI({},i,c):c,j=GRe(Object.keys(w),l,u);_.start([m,o,Tg(Tg({},w),{},{transition:j}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=Nps(a,jps),u=k.Children.count(o),m=this.state.style;if(typeof o=="function")return o(m);if(!i||u===0||l<=0)return o;var f=function(y){var _=y.props,w=_.style,j=w===void 0?{}:w,N=_.className,S=k.cloneElement(y,Tg(Tg({},c),{},{style:Tg(Tg({},j),m),className:N}));return S};return u===1?f(k.Children.only(o)):mt.createElement("div",null,k.Children.map(o,function(g){return f(g)}))}}]),r}(k.PureComponent);$0.displayName="Animate";$0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};$0.propTypes={from:dl.oneOfType([dl.object,dl.string]),to:dl.oneOfType([dl.object,dl.string]),attributeName:dl.string,duration:dl.number,begin:dl.number,easing:dl.oneOfType([dl.string,dl.func]),steps:dl.arrayOf(dl.shape({duration:dl.number.isRequired,style:dl.object.isRequired,easing:dl.oneOfType([dl.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),dl.func]),properties:dl.arrayOf("string"),onAnimationEnd:dl.func})),children:dl.oneOfType([dl.node,dl.func]),isActive:dl.bool,canBegin:dl.bool,onAnimationEnd:dl.func,shouldReAnimate:dl.bool,onAnimationStart:dl.func,onAnimationReStart:dl.func};function dO(t){"@babel/helpers - typeof";return dO=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},dO(t)}function Bce(){return Bce=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,m;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],g=0,y=4;gl?l:o[g];m="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(m+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+c*f[0],",").concat(r)),m+="L ".concat(s+n-c*f[1],",").concat(r),f[1]>0&&(m+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),m+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(m+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-c*f[2],",").concat(r+a)),m+="L ".concat(s+c*f[3],",").concat(r+a),f[3]>0&&(m+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),m+="Z"}else if(l>0&&o===+o&&o>0){var _=Math.min(l,o);m="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 m="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return m},Hps=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),m=Math.max(o,o+i),f=Math.min(l,l+c),g=Math.max(l,l+c);return n>=u&&n<=m&&a>=f&&a<=g}return!1},Gps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},lSe=function(s){var r=eFe(eFe({},Gps),s),n=k.useRef(),a=k.useState(-1),o=Rps(a,2),l=o[0],i=o[1];k.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var c=r.x,u=r.y,m=r.width,f=r.height,g=r.radius,y=r.className,_=r.animationEasing,w=r.animationDuration,j=r.animationBegin,N=r.isAnimationActive,S=r.isUpdateAnimationActive;if(c!==+c||u!==+u||m!==+m||f!==+f||m===0||f===0)return null;var M=Hi("recharts-rectangle",y);return S?mt.createElement($0,{canBegin:l>0,from:{width:m,height:f,x:c,y:u},to:{width:m,height:f,x:c,y:u},duration:w,animationEasing:_,isActive:S},function(I){var P=I.width,O=I.height,q=I.x,$=I.y;return mt.createElement($0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,isActive:N,easing:_},mt.createElement("path",Bce({},di(r,!0),{className:M,d:tFe(q,$,P,O,g),ref:n})))}):mt.createElement("path",Bce({},di(r,!0),{className:M,d:tFe(c,u,m,f,g)}))},Wps=["points","className","baseLinePoints","connectNulls"];function CM(){return CM=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 Zps(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 sFe(t){return Jps(t)||Xps(t)||Qps(t)||Yps()}function Yps(){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 Qps(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 Xps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Jps(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);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){rFe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),rFe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},L8=function(s,r){var n=efs(s);r&&(n=[n.reduce(function(o,l){return[].concat(sFe(o),sFe(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},tfs=function(s,r,n){var a=L8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(L8(r.reverse(),n).slice(1))},sfs=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=Kps(s,Wps);if(!r||!r.length)return null;var i=Hi("recharts-polygon",n);if(a&&a.length){var c=l.stroke&&l.stroke!=="none",u=tfs(r,a,o);return mt.createElement("g",{className:i},mt.createElement("path",CM({},di(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?mt.createElement("path",CM({},di(l,!0),{fill:"none",d:L8(r,o)})):null,c?mt.createElement("path",CM({},di(l,!0),{fill:"none",d:L8(a,o)})):null)}var m=L8(r,o);return mt.createElement("path",CM({},di(l,!0),{fill:m.slice(-1)==="Z"?l.fill:"none",className:i,d:m}))};function M_e(){return M_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 cfs(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 dfs=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},ufs=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,m=s.width,f=m===void 0?0:m,g=s.height,y=g===void 0?0:g,_=s.className,w=lfs(s,rfs),j=nfs({x:n,y:o,top:i,left:u,width:f,height:y},w);return!pn(n)||!pn(o)||!pn(f)||!pn(y)||!pn(i)||!pn(u)?null:mt.createElement("path",T_e({},di(j,!0),{className:Hi("recharts-cross",_),d:dfs(n,o,f,y,i,u)}))},hfs=Fhe,mfs=int,pfs=Z0;function ffs(t,s){return t&&t.length?hfs(t,pfs(s),mfs):void 0}var xfs=ffs;const gfs=Do(xfs);var yfs=Fhe,vfs=Z0,bfs=ont;function _fs(t,s){return t&&t.length?yfs(t,vfs(s),bfs):void 0}var wfs=_fs;const jfs=Do(wfs);var Nfs=["cx","cy","angle","ticks","axisLine"],kfs=["ticks","tick","angle","tickFormatter","stroke"];function jA(t){"@babel/helpers - typeof";return jA=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},jA(t)}function D8(){return D8=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 Sfs(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 Cfs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function oFe(t,s){for(var r=0;rdFe?l=a==="outer"?"start":"end":o<-dFe?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=K2(K2({},di(this.props,!1)),{},{fill:"none"},di(i,!1));if(c==="circle")return mt.createElement(Uhe,y4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var m=this.props.ticks,f=m.map(function(g){return dc(a,o,l,g.coordinate)});return mt.createElement(sfs,y4({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,m=di(this.props,!1),f=di(l,!1),g=K2(K2({},m),{},{fill:"none"},di(i,!1)),y=o.map(function(_,w){var j=n.getTickLineCoord(_),N=n.getTickTextAnchor(_),S=K2(K2(K2({textAnchor:N},m),{},{stroke:"none",fill:u},f),{},{index:w,payload:_,x:j.x2,y:j.y2});return mt.createElement(Xo,y4({className:Hi("recharts-polar-angle-axis-tick",Dnt(l)),key:"tick-".concat(_.coordinate)},m3(n.props,_,w)),i&&mt.createElement("line",y4({className:"recharts-polar-angle-axis-tick-line"},g,j)),l&&s.renderTickItem(l,S,c?c(_.value,w):_.value))});return mt.createElement(Xo,{className:"recharts-polar-angle-axis-ticks"},y)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:mt.createElement(Xo,{className:Hi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return mt.isValidElement(n)?l=mt.cloneElement(n,a):Ai(n)?l=n(a):l=mt.createElement(p3,y4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(k.PureComponent);Ghe(Whe,"displayName","PolarAngleAxis");Ghe(Whe,"axisType","angleAxis");Ghe(Whe,"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 qfs=srt,Ufs=qfs(Object.getPrototypeOf,Object),Vfs=Ufs,Hfs=Z1,Gfs=Vfs,Wfs=Y1,Kfs="[object Object]",Zfs=Function.prototype,Yfs=Object.prototype,Jnt=Zfs.toString,Qfs=Yfs.hasOwnProperty,Xfs=Jnt.call(Object);function Jfs(t){if(!Wfs(t)||Hfs(t)!=Kfs)return!1;var s=Gfs(t);if(s===null)return!0;var r=Qfs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Jnt.call(r)==Xfs}var exs=Jfs;const txs=Do(exs);var sxs=Z1,rxs=Y1,nxs="[object Boolean]";function axs(t){return t===!0||t===!1||rxs(t)&&sxs(t)==nxs}var ixs=axs;const oxs=Do(ixs);function hO(t){"@babel/helpers - typeof";return hO=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},hO(t)}function Uce(){return Uce=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:m,lowerWidth:f,height:g,x:c,y:u},duration:w,animationEasing:_,isActive:N},function(M){var I=M.upperWidth,P=M.lowerWidth,O=M.height,q=M.x,$=M.y;return mt.createElement($0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,easing:_},mt.createElement("path",Uce({},di(r,!0),{className:S,d:pFe(q,$,I,P,O),ref:n})))}):mt.createElement("g",null,mt.createElement("path",Uce({},di(r,!0),{className:S,d:pFe(c,u,m,f,g)})))},yxs=["option","shapeType","propTransformer","activeClassName","isActive"];function mO(t){"@babel/helpers - typeof";return mO=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},mO(t)}function vxs(t,s){if(t==null)return{};var r=bxs(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 bxs(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 fFe(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 Vce(t){for(var s=1;s0?kf(M,"paddingAngle",0):0;if(P){var q=lf(P.endAngle-P.startAngle,M.endAngle-M.startAngle),$=Xl(Xl({},M),{},{startAngle:S+O,endAngle:S+q(w)+O});j.push($),S=$.endAngle}else{var z=M.endAngle,V=M.startAngle,X=lf(0,z-V),Y=X(w),J=Xl(Xl({},M),{},{startAngle:S+O,endAngle:S+Y+O});j.push(J),S=J.endAngle}}),mt.createElement(Xo,null,n.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!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,m=a.cy,f=a.innerRadius,g=a.outerRadius,y=a.isAnimationActive,_=this.state.isAnimationFinished;if(o||!l||!l.length||!pn(u)||!pn(m)||!pn(f)||!pn(g))return null;var w=Hi("recharts-pie",i);return mt.createElement(Xo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(N){n.pieRef=N}},this.renderSectors(),c&&this.renderLabels(l),Ju.renderCallByParent(this.props,null,!1),(!y||_)&&k1.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,I=j-S*y-M,P=a.reduce(function($,z){var V=ku(z,N,0);return $+(pn(V)?V:0)},0),O;if(P>0){var q;O=a.map(function($,z){var V=ku($,N,0),X=ku($,m,z),Y=(pn(V)?V:0)/P,J;z?J=q.endAngle+Lm(w)*c*(V!==0?1:0):J=l;var Q=J+Lm(w)*((V!==0?y:0)+Y*I),ce=(J+Q)/2,ne=(_.innerRadius+_.outerRadius)/2,re=[{name:X,value:V,payload:$,dataKey:N,type:g}],oe=dc(_.cx,_.cy,ne,ce);return q=Xl(Xl(Xl({percent:Y,cornerRadius:o,name:X,tooltipPayload:re,midAngle:ce,middleRadius:ne,tooltipPosition:oe},$),_),{},{value:ku($,N),startAngle:J,endAngle:Q,payload:$,paddingAngle:Lm(w)*c}),q})}return Xl(Xl({},_),{},{sectors:O,data:a})});var $xs=Math.ceil,qxs=Math.max;function Uxs(t,s,r,n){for(var a=-1,o=qxs($xs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Vxs=Uxs,Hxs=_rt,vFe=1/0,Gxs=17976931348623157e292;function Wxs(t){if(!t)return t===0?t:0;if(t=Hxs(t),t===vFe||t===-vFe){var s=t<0?-1:1;return s*Gxs}return t===t?t:0}var rat=Wxs,Kxs=Vxs,Zxs=Ehe,jye=rat;function Yxs(t){return function(s,r,n){return n&&typeof n!="number"&&Zxs(s,r,n)&&(r=n=void 0),s=jye(s),r===void 0?(r=s,s=0):r=jye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),sf(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()}),sf(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),sf(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),sf(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),sf(n,"handleSlideDragStart",function(a){var o=NFe(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 dgs(s,t),igs(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,m=u.length-1,f=Math.min(a,o),g=Math.max(a,o),y=s.getIndexInRange(l,f),_=s.getIndexInRange(l,g);return{startIndex:y-y%c,endIndex:_===m?m:_-_%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=ku(o[n],i,n);return Ai(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,m=c.width,f=c.travellerWidth,g=c.startIndex,y=c.endIndex,_=c.onChange,w=n.pageX-o;w>0?w=Math.min(w,u+m-f-i,u+m-f-l):w<0&&(w=Math.max(w,u-l,u-i));var j=this.getIndex({startX:l+w,endX:i+w});(j.startIndex!==g||j.endIndex!==y)&&_&&_(j),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=NFe(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],m=this.props,f=m.x,g=m.width,y=m.travellerWidth,_=m.onChange,w=m.gap,j=m.data,N={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+g-y-u):S<0&&(S=Math.max(S,f-u)),N[l]=u+S;var M=this.getIndex(N),I=M.startIndex,P=M.endIndex,O=function(){var $=j.length-1;return l==="startX"&&(i>c?I%w===0:P%w===0)||ic?P%w===0:I%w===0)||i>c&&P===$};this.setState(sf(sf({},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,m=this.state[a],f=i.indexOf(m);if(f!==-1){var g=f+n;if(!(g===-1||g>=i.length)){var y=i[g];a==="startX"&&y>=u||a==="endX"&&y<=c||this.setState(sf({},a,y),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 mt.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,m=n.padding,f=k.Children.only(u);return f?mt.cloneElement(f,{x:a,y:o,width:l,height:i,margin:m,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,c=this.props,u=c.y,m=c.travellerWidth,f=c.height,g=c.traveller,y=c.ariaLabel,_=c.data,w=c.startIndex,j=c.endIndex,N=Math.max(n,this.props.x),S=Nye(Nye({},di(this.props,!1)),{},{x:N,y:u,width:m,height:f}),M=y||"Min value: ".concat((o=_[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=_[j])===null||l===void 0?void 0:l.name);return mt.createElement(Xo,{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(P){["ArrowLeft","ArrowRight"].includes(P.key)&&(P.preventDefault(),P.stopPropagation(),i.handleTravellerMoveKeyboard(P.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,m=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return mt.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:m,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,m=this.state,f=m.startX,g=m.endX,y=5,_={pointerEvents:"none",fill:u};return mt.createElement(Xo,{className:"recharts-brush-texts"},mt.createElement(p3,Wce({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,g)-y,y:l+i/2},_),this.getTextOfTick(a)),mt.createElement(p3,Wce({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,g)+c+y,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,m=n.height,f=n.alwaysShowText,g=this.state,y=g.startX,_=g.endX,w=g.isTextActive,j=g.isSlideMoving,N=g.isTravellerMoving,S=g.isTravellerFocused;if(!a||!a.length||!pn(i)||!pn(c)||!pn(u)||!pn(m)||u<=0||m<=0)return null;var M=Hi("recharts-brush",o),I=mt.Children.count(l)===1,P=ngs("userSelect","none");return mt.createElement(Xo,{className:M,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:P},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(y,_),this.renderTravellerLayer(y,"startX"),this.renderTravellerLayer(_,"endX"),(w||j||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 mt.createElement(mt.Fragment,null,mt.createElement("rect",{x:a,y:o,width:l,height:i,fill:c,stroke:"none"}),mt.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),mt.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 mt.isValidElement(n)?o=mt.cloneElement(n,a):Ai(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,m=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return Nye({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?hgs({data:o,width:l,x:i,travellerWidth:c,startIndex:m,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(y){return a.scale(y)});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);sf(CA,"displayName","Brush");sf(CA,"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 mgs=L4e;function pgs(t,s){var r;return mgs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var fgs=pgs,xgs=Kst,ggs=Z0,ygs=fgs,vgs=Dp,bgs=Ehe;function _gs(t,s,r){var n=vgs(t)?xgs:ygs;return r&&bgs(t,s,r)&&(s=void 0),n(t,ggs(s))}var wgs=_gs;const jgs=Do(wgs);var P0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},kFe=xrt;function Ngs(t,s,r){s=="__proto__"&&kFe?kFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var kgs=Ngs,Sgs=kgs,Cgs=prt,Mgs=Z0;function Tgs(t,s){var r={};return s=Mgs(s),Cgs(t,function(n,a,o){Sgs(r,a,s(n,a,o))}),r}var Ags=Tgs;const Egs=Do(Ags);function Pgs(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 Zgs(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 Ygs(t,s){var r=t.x,n=t.y,a=Kgs(t,Vgs),o="".concat(r),l=parseInt(o,10),i="".concat(n),c=parseInt(i,10),u="".concat(s.height||a.height),m=parseInt(u,10),f="".concat(s.width||a.width),g=parseInt(f,10);return SI(SI(SI(SI(SI({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:m,width:g,name:s.name,radius:s.radius})}function CFe(t){return mt.createElement(eat,L_e({shapeType:"rectangle",propTransformer:Ygs,activeClassName:"recharts-active-bar"},t))}var Qgs=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=pn(n)||wYt(n);return o?s(n,a):(o||x3(),r)}},Xgs=["value","background"],lat;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 Jgs(t,s){if(t==null)return{};var r=eys(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 eys(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 Zce(){return Zce=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(Q)0&&(J=Math.min((Be||0)-(Q[Se-1]||0),J))}),Number.isFinite(J)){var ce=J/Y,ne=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&(q=ce*ne/2),w.padding==="no-gap"){var re=Dm(s.barCategoryGap,ce*ne),oe=ce*ne/2;q=oe-re-(oe-re)/ne*re}}}a==="xAxis"?$=[n.left+(M.left||0)+(q||0),n.left+n.width-(M.right||0)-(q||0)]:a==="yAxis"?$=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)]:$=w.range,P&&($=[$[1],$[0]]);var he=Mnt(w,o,g),xe=he.scale,ue=he.realScaleType;xe.domain(N).range($),Tnt(xe);var ge=Ant(xe,qg(qg({},w),{},{realScaleType:ue}));a==="xAxis"?(X=j==="top"&&!I||j==="bottom"&&I,z=n.left,V=f[O]-X*w.height):a==="yAxis"&&(X=j==="left"&&!I||j==="right"&&I,z=f[O]-X*w.width,V=n.top);var _e=qg(qg(qg({},w),ge),{},{realScaleType:ue,x:z,y:V,scale:xe,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return _e.bandSize=Ice(_e,ge),!w.hide&&a==="xAxis"?f[O]+=(X?-1:1)*_e.height:w.hide||(f[O]+=(X?-1:1)*_e.width),qg(qg({},y),{},Yhe({},_,_e))},{})},mat=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)}},uys=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return mat({x:r,y:n},{x:a,y:o})},pat=function(){function t(s){lys(this,t),this.scale=s}return cys(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)}}])}();Yhe(pat,"EPS",1e-4);var cSe=function(s){var r=Object.keys(s).reduce(function(n,a){return qg(qg({},n),{},Yhe({},a,pat.create(s[a])))},{});return qg(qg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Egs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return oat(a,function(o,l){return r[l].isInRange(o)})}})};function hys(t){return(t%180+180)%180}var mys=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=hys(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var yys=gys,vys=rat;function bys(t){var s=vys(t),r=s%1;return s===s?r?s-r:s:0}var _ys=bys,wys=lrt,jys=Z0,Nys=_ys,kys=Math.max;function Sys(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Nys(r);return a<0&&(a=kys(n+a,0)),wys(t,jys(s),a)}var Cys=Sys,Mys=yys,Tys=Cys,Ays=Mys(Tys),Eys=Ays;const Pys=Do(Eys);var Iys=MZt(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("")}),dSe=k.createContext(void 0),uSe=k.createContext(void 0),fat=k.createContext(void 0),xat=k.createContext({}),gat=k.createContext(void 0),yat=k.createContext(0),vat=k.createContext(0),PFe=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,m=Iys(o);return mt.createElement(dSe.Provider,{value:n},mt.createElement(uSe.Provider,{value:a},mt.createElement(xat.Provider,{value:o},mt.createElement(fat.Provider,{value:m},mt.createElement(gat.Provider,{value:l},mt.createElement(yat.Provider,{value:u},mt.createElement(vat.Provider,{value:c},i)))))))},Lys=function(){return k.useContext(gat)},bat=function(s){var r=k.useContext(dSe);r==null&&x3();var n=r[s];return n==null&&x3(),n},Dys=function(){var s=k.useContext(dSe);return g_(s)},Oys=function(){var s=k.useContext(uSe),r=Pys(s,function(n){return oat(n.domain,Number.isFinite)});return r||g_(s)},_at=function(s){var r=k.useContext(uSe);r==null&&x3();var n=r[s];return n==null&&x3(),n},Rys=function(){var s=k.useContext(fat);return s},Fys=function(){return k.useContext(xat)},hSe=function(){return k.useContext(vat)},mSe=function(){return k.useContext(yat)};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 zys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Bys(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 _0s(t,s){return Mat(t,s+1)}function w0s(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,c=0,u=1,m=l,f=function(){var _=n==null?void 0:n[c];if(_===void 0)return{v:Mat(n,u)};var w=c,j,N=function(){return j===void 0&&(j=r(_,w)),j},S=_.coordinate,M=c===0||ede(t,S,N,m,i);M||(c=0,m=l,u+=1),M&&(m=S+t*(N()/2+a),c+=u)},g;u<=o.length;)if(g=f(),g)return g.v;return[]}function yO(t){"@babel/helpers - typeof";return yO=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},yO(t)}function BFe(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 Hh(t){for(var s=1;s0?y.coordinate-j*t:y.coordinate})}else o[g]=y=Hh(Hh({},y),{},{tickCoord:y.coordinate});var N=ede(t,y.tickCoord,w,i,c);N&&(c=y.tickCoord-t*(w()/2+a),o[g]=Hh(Hh({},y),{},{isShow:!0}))},m=l-1;m>=0;m--)u(m);return o}function C0s(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,c=s.start,u=s.end;if(o){var m=n[i-1],f=r(m,i-1),g=t*(m.coordinate+t*f/2-u);l[i-1]=m=Hh(Hh({},m),{},{tickCoord:g>0?m.coordinate-g*t:m.coordinate});var y=ede(t,m.tickCoord,function(){return f},c,u);y&&(u=m.tickCoord-t*(f/2+a),l[i-1]=Hh(Hh({},m),{},{isShow:!0}))}for(var _=o?i-1:i,w=function(S){var M=l[S],I,P=function(){return I===void 0&&(I=r(M,S)),I};if(S===0){var O=t*(M.coordinate-t*P()/2-c);l[S]=M=Hh(Hh({},M),{},{tickCoord:O<0?M.coordinate-O*t:M.coordinate})}else l[S]=M=Hh(Hh({},M),{},{tickCoord:M.coordinate});var q=ede(t,M.tickCoord,P,c,u);q&&(c=M.tickCoord+t*(P()/2+a),l[S]=Hh(Hh({},M),{},{isShow:!0}))},j=0;j<_;j++)w(j);return l}function xSe(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,m=t.unit,f=t.angle;if(!a||!a.length||!n)return[];if(pn(c)||O3.isSsr)return _0s(a,typeof c=="number"&&pn(c)?c:0);var g=[],y=i==="top"||i==="bottom"?"width":"height",_=m&&y==="width"?A8(m,{fontSize:s,letterSpacing:r}):{width:0,height:0},w=function(M,I){var P=Ai(u)?u(M.value,I):M.value;return y==="width"?v0s(A8(P,{fontSize:s,letterSpacing:r}),_,f):A8(P,{fontSize:s,letterSpacing:r})[y]},j=a.length>=2?Lm(a[1].coordinate-a[0].coordinate):1,N=b0s(o,j,y);return c==="equidistantPreserveStart"?w0s(j,N,w,a,l):(c==="preserveStart"||c==="preserveStartEnd"?g=C0s(j,N,w,a,l,c==="preserveStartEnd"):g=S0s(j,N,w,a,l),g.filter(function(S){return S.isShow}))}var M0s=["viewBox"],T0s=["viewBox"],A0s=["ticks"];function PA(t){"@babel/helpers - typeof";return PA=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},PA(t)}function TM(){return TM=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 E0s(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 P0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function qFe(t,s){for(var r=0;r0?c(this.props):c(y)),l<=0||i<=0||!_||!_.length?null:mt.createElement(Xo,{className:Hi("recharts-cartesian-axis",u),ref:function(j){n.layerReference=j}},o&&this.renderAxisLine(),this.renderTicks(_,this.state.fontSize,this.state.letterSpacing),Ju.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Hi(a.className,"recharts-cartesian-axis-tick-value");return mt.isValidElement(n)?l=mt.cloneElement(n,fu(fu({},a),{},{className:i})):Ai(n)?l=n(fu(fu({},a),{},{className:i})):l=mt.createElement(p3,TM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(k.Component);gSe(qE,"displayName","CartesianAxis");gSe(qE,"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 z0s=["x1","y1","x2","y2","key"],B0s=["offset"];function g3(t){"@babel/helpers - typeof";return g3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},g3(t)}function UFe(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 Kh(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function V0s(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 H0s=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 mt.createElement("rect",{x:a,y:o,ry:c,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Eat(t,s){var r;if(mt.isValidElement(t))r=mt.cloneElement(t,s);else if(Ai(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=VFe(s,z0s),u=di(c,!1);u.offset;var m=VFe(u,B0s);r=mt.createElement("line",D4({},m,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function G0s(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=Kh(Kh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return Eat(a,u)});return mt.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function W0s(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=Kh(Kh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return Eat(a,u)});return mt.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function K0s(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 m=i.map(function(g){return Math.round(g+a-a)}).sort(function(g,y){return g-y});a!==m[0]&&m.unshift(0);var f=m.map(function(g,y){var _=!m[y+1],w=_?a+l-g:m[y+1]-g;if(w<=0)return null;var j=y%s.length;return mt.createElement("rect",{key:"react-".concat(y),y:g,x:n,height:w,width:o,stroke:"none",fill:s[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return mt.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function Z0s(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 m=u.map(function(g){return Math.round(g+o-o)}).sort(function(g,y){return g-y});o!==m[0]&&m.unshift(0);var f=m.map(function(g,y){var _=!m[y+1],w=_?o+i-g:m[y+1]-g;if(w<=0)return null;var j=y%n.length;return mt.createElement("rect",{key:"react-".concat(y),x:g,y:l,width:w,height:c,stroke:"none",fill:n[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return mt.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var Y0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Cnt(xSe(Kh(Kh(Kh({},qE.defaultProps),n),{},{ticks:i1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},Q0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Cnt(xSe(Kh(Kh(Kh({},qE.defaultProps),n),{},{ticks:i1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},H5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Pat(t){var s,r,n,a,o,l,i=hSe(),c=mSe(),u=Fys(),m=Kh(Kh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:H5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:H5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:H5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:H5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:H5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:H5.verticalFill,x:pn(t.x)?t.x:u.left,y:pn(t.y)?t.y:u.top,width:pn(t.width)?t.width:u.width,height:pn(t.height)?t.height:u.height}),f=m.x,g=m.y,y=m.width,_=m.height,w=m.syncWithTicks,j=m.horizontalValues,N=m.verticalValues,S=Dys(),M=Oys();if(!pn(y)||y<=0||!pn(_)||_<=0||!pn(f)||f!==+f||!pn(g)||g!==+g)return null;var I=m.verticalCoordinatesGenerator||Y0s,P=m.horizontalCoordinatesGenerator||Q0s,O=m.horizontalPoints,q=m.verticalPoints;if((!O||!O.length)&&Ai(P)){var $=j&&j.length,z=P({yAxis:M?Kh(Kh({},M),{},{ticks:$?j:M.ticks}):void 0,width:i,height:c,offset:u},$?!0:w);ay(Array.isArray(z),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(g3(z),"]")),Array.isArray(z)&&(O=z)}if((!q||!q.length)&&Ai(I)){var V=N&&N.length,X=I({xAxis:S?Kh(Kh({},S),{},{ticks:V?N:S.ticks}):void 0,width:i,height:c,offset:u},V?!0:w);ay(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(g3(X),"]")),Array.isArray(X)&&(q=X)}return mt.createElement("g",{className:"recharts-cartesian-grid"},mt.createElement(H0s,{fill:m.fill,fillOpacity:m.fillOpacity,x:m.x,y:m.y,width:m.width,height:m.height,ry:m.ry}),mt.createElement(G0s,D4({},m,{offset:u,horizontalPoints:O,xAxis:S,yAxis:M})),mt.createElement(W0s,D4({},m,{offset:u,verticalPoints:q,xAxis:S,yAxis:M})),mt.createElement(K0s,D4({},m,{horizontalPoints:O})),mt.createElement(Z0s,D4({},m,{verticalPoints:q})))}Pat.displayName="CartesianGrid";var X0s=["type","layout","connectNulls","ref"],J0s=["key"];function IA(t){"@babel/helpers - typeof";return IA=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},IA(t)}function HFe(t,s){if(t==null)return{};var r=evs(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 evs(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 O8(){return O8=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){y=[].concat(G5(c.slice(0,_)),[f-w]);break}var j=y.length%2===0?[0,g]:[g];return[].concat(G5(s.repeat(c,m)),G5(y),j).map(function(N){return"".concat(N,"px")}).join(", ")}),Ug(r,"id",DE("recharts-line-")),Ug(r,"pathRef",function(l){r.mainCurve=l}),Ug(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Ug(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return dvs(s,t),ivs(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,m=o.children,f=Sf(m,TR);if(!f)return null;var g=function(w,j){return{x:w.x,y:w.y,value:w.value,errorVal:ku(w.payload,j)}},y={clipPath:n?"url(#clipPath-".concat(a,")"):null};return mt.createElement(Xo,y,f.map(function(_){return mt.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,m=i.dataKey,f=di(this.props,!1),g=di(c,!0),y=u.map(function(w,j){var N=ef(ef(ef({key:"dot-".concat(j),r:3},f),g),{},{index:j,cx:w.x,cy:w.y,value:w.value,dataKey:m,payload:w.payload,points:u});return s.renderDotItem(c,N)}),_={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return mt.createElement(Xo,O8({className:"recharts-line-dots",key:"dots"},_),y)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,c=i.type,u=i.layout,m=i.connectNulls;i.ref;var f=HFe(i,X0s),g=ef(ef(ef({},di(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:c,layout:u,connectNulls:m});return mt.createElement(Oce,O8({},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,m=l.animationBegin,f=l.animationDuration,g=l.animationEasing,y=l.animationId,_=l.animateNewValues,w=l.width,j=l.height,N=this.state,S=N.prevPoints,M=N.totalLength;return mt.createElement($0,{begin:m,duration:f,isActive:u,easing:g,from:{t:0},to:{t:1},key:"line-".concat(y),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var P=I.t;if(S){var O=S.length/i.length,q=i.map(function(Y,J){var Q=Math.floor(J*O);if(S[Q]){var ce=S[Q],ne=lf(ce.x,Y.x),re=lf(ce.y,Y.y);return ef(ef({},Y),{},{x:ne(P),y:re(P)})}if(_){var oe=lf(w*2,Y.x),he=lf(j/2,Y.y);return ef(ef({},Y),{},{x:oe(P),y:he(P)})}return ef(ef({},Y),{},{x:Y.x,y:Y.y})});return o.renderCurveStatically(q,n,a)}var $=lf(0,M),z=$(P),V;if(c){var X="".concat(c).split(/[,\s]+/gim).map(function(Y){return parseFloat(Y)});V=o.getStrokeDasharray(z,M,X)}else V=o.generateSimpleStrokeDasharray(M,z);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,m=c.totalLength;return i&&l&&l.length&&(!u&&m>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,m=a.yAxis,f=a.top,g=a.left,y=a.width,_=a.height,w=a.isAnimationActive,j=a.id;if(o||!i||!i.length)return null;var N=this.state.isAnimationFinished,S=i.length===1,M=Hi("recharts-line",c),I=u&&u.allowDataOverflow,P=m&&m.allowDataOverflow,O=I||P,q=Ui(j)?this.id:j,$=(n=di(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},z=$.r,V=z===void 0?3:z,X=$.strokeWidth,Y=X===void 0?2:X,J=LYt(l)?l:{},Q=J.clipDot,ce=Q===void 0?!0:Q,ne=V*2+Y;return mt.createElement(Xo,{className:M},I||P?mt.createElement("defs",null,mt.createElement("clipPath",{id:"clipPath-".concat(q)},mt.createElement("rect",{x:I?g:g-y/2,y:P?f:f-_/2,width:I?y:y*2,height:P?_:_*2})),!ce&&mt.createElement("clipPath",{id:"clipPath-dots-".concat(q)},mt.createElement("rect",{x:g-ne/2,y:f-ne/2,width:y+ne,height:_+ne}))):null,!S&&this.renderCurve(O,q),this.renderErrorBar(O,q),(S||l)&&this.renderDots(O,ce,q),(!w||N)&&k1.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(G5(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 Jvs(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 e1s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function t1s(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&pn(a)&&pn(o)?s.slice(a,o+1):[]};function Kat(t){return t==="number"?[0,"auto"]:void 0}var J_e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=tme(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(c,u){var m,f=(m=u.props.data)!==null&&m!==void 0?m: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 y=f===void 0?i:f;g=ace(y,l.dataKey,a)}else g=f&&f[n]||i[n];return g?[].concat(RA(c),[Pnt(u,g)]):c},[])},JFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=m1s(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,m=Dus(l,i,u,c);if(m>=0&&u){var f=u[m]&&u[m].value,g=J_e(s,r,m,f),y=p1s(n,i,m,o);return{activeTooltipIndex:m,activeLabel:f,activePayload:g,activeCoordinate:y}}return null},f1s=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,m=s.layout,f=s.children,g=s.stackOffset,y=Snt(m,o);return n.reduce(function(_,w){var j,N=w.type.defaultProps!==void 0?Nr(Nr({},w.type.defaultProps),w.props):w.props,S=N.type,M=N.dataKey,I=N.allowDataOverflow,P=N.allowDuplicatedCategory,O=N.scale,q=N.ticks,$=N.includeHidden,z=N[l];if(_[z])return _;var V=tme(s.data,{graphicalItems:a.filter(function(ge){var _e,Be=l in ge.props?ge.props[l]:(_e=ge.type.defaultProps)===null||_e===void 0?void 0:_e[l];return Be===z}),dataStartIndex:c,dataEndIndex:u}),X=V.length,Y,J,Q;$vs(N.domain,I,S)&&(Y=m_e(N.domain,null,I),y&&(S==="number"||O!=="auto")&&(Q=P8(V,M,"category")));var ce=Kat(S);if(!Y||Y.length===0){var ne,re=(ne=N.domain)!==null&&ne!==void 0?ne:ce;if(M){if(Y=P8(V,M,S),S==="category"&&y){var oe=NYt(Y);P&&oe?(J=Y,Y=Gce(0,X)):P||(Y=_Re(re,Y,w).reduce(function(ge,_e){return ge.indexOf(_e)>=0?ge:[].concat(RA(ge),[_e])},[]))}else if(S==="category")P?Y=Y.filter(function(ge){return ge!==""&&!Ui(ge)}):Y=_Re(re,Y,w).reduce(function(ge,_e){return ge.indexOf(_e)>=0||_e===""||Ui(_e)?ge:[].concat(RA(ge),[_e])},[]);else if(S==="number"){var he=Bus(V,a.filter(function(ge){var _e,Be,Se=l in ge.props?ge.props[l]:(_e=ge.type.defaultProps)===null||_e===void 0?void 0:_e[l],Ee="hide"in ge.props?ge.props.hide:(Be=ge.type.defaultProps)===null||Be===void 0?void 0:Be.hide;return Se===z&&($||!Ee)}),M,o,m);he&&(Y=he)}y&&(S==="number"||O!=="auto")&&(Q=P8(V,M,"category"))}else y?Y=Gce(0,X):i&&i[z]&&i[z].hasStack&&S==="number"?Y=g==="expand"?[0,1]:Ent(i[z].stackGroups,c,u):Y=knt(V,a.filter(function(ge){var _e=l in ge.props?ge.props[l]:ge.type.defaultProps[l],Be="hide"in ge.props?ge.props.hide:ge.type.defaultProps.hide;return _e===z&&($||!Be)}),S,m,!0);if(S==="number")Y=Y_e(f,Y,z,o,q),re&&(Y=m_e(re,Y,I));else if(S==="category"&&re){var xe=re,ue=Y.every(function(ge){return xe.indexOf(ge)>=0});ue&&(Y=xe)}}return Nr(Nr({},_),{},gi({},z,Nr(Nr({},N),{},{axisType:o,domain:Y,categoricalDomain:Q,duplicateDomain:J,originalDomain:(j=N.domain)!==null&&j!==void 0?j:ce,isCategorical:y,layout:m})))},{})},x1s=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,m=s.layout,f=s.children,g=tme(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),y=g.length,_=Snt(m,o),w=-1;return n.reduce(function(j,N){var S=N.type.defaultProps!==void 0?Nr(Nr({},N.type.defaultProps),N.props):N.props,M=S[l],I=Kat("number");if(!j[M]){w++;var P;return _?P=Gce(0,y):i&&i[M]&&i[M].hasStack?(P=Ent(i[M].stackGroups,c,u),P=Y_e(f,P,M,o)):(P=m_e(I,knt(g,n.filter(function(O){var q,$,z=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:($=O.type.defaultProps)===null||$===void 0?void 0:$.hide;return z===M&&!V}),"number",m),a.defaultProps.allowDataOverflow),P=Y_e(f,P,M,o)),Nr(Nr({},j),{},gi({},M,Nr(Nr({axisType:o},a.defaultProps),{},{hide:!0,orientation:kf(u1s,"".concat(o,".").concat(w%2),null),domain:P,originalDomain:I,isCategorical:_,layout:m})))}return j},{})},g1s=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,m=s.children,f="".concat(a,"Id"),g=Sf(m,o),y={};return g&&g.length?y=f1s(s,{axes:g,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(y=x1s(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),y},y1s=function(s){var r=g_(s),n=i1(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:D4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Ice(r,n)}},e7e=function(s){var r=s.children,n=s.defaultShowTooltip,a=nf(r,CA),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}},v1s=function(s){return!s||!s.length?!1:s.some(function(r){var n=j1(r&&r.type);return n&&n.indexOf("Bar")>=0})},t7e=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"}},b1s=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,m=n.height,f=n.children,g=n.margin||{},y=nf(f,CA),_=nf(f,_T),w=Object.keys(c).reduce(function(P,O){var q=c[O],$=q.orientation;return!q.mirror&&!q.hide?Nr(Nr({},P),{},gi({},$,P[$]+q.width)):P},{left:g.left||0,right:g.right||0}),j=Object.keys(l).reduce(function(P,O){var q=l[O],$=q.orientation;return!q.mirror&&!q.hide?Nr(Nr({},P),{},gi({},$,kf(P,"".concat($))+q.height)):P},{top:g.top||0,bottom:g.bottom||0}),N=Nr(Nr({},j),w),S=N.bottom;y&&(N.bottom+=y.props.height||CA.defaultProps.height),_&&r&&(N=Fus(N,a,n,r));var M=u-N.left-N.right,I=m-N.top-N.bottom;return Nr(Nr({brushBottom:S},N),{},{width:Math.max(M,0),height:Math.max(I,0)})},_1s=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},ySe=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,m=s.formatAxisMap,f=s.defaultProps,g=function(N,S){var M=S.graphicalItems,I=S.stackGroups,P=S.offset,O=S.updateId,q=S.dataStartIndex,$=S.dataEndIndex,z=N.barSize,V=N.layout,X=N.barGap,Y=N.barCategoryGap,J=N.maxBarSize,Q=t7e(V),ce=Q.numericAxisName,ne=Q.cateAxisName,re=v1s(M),oe=[];return M.forEach(function(he,xe){var ue=tme(N.data,{graphicalItems:[he],dataStartIndex:q,dataEndIndex:$}),ge=he.type.defaultProps!==void 0?Nr(Nr({},he.type.defaultProps),he.props):he.props,_e=ge.dataKey,Be=ge.maxBarSize,Se=ge["".concat(ce,"Id")],Ee=ge["".concat(ne,"Id")],Ae={},Me=c.reduce(function(lt,He){var We=S["".concat(He.axisType,"Map")],tt=ge["".concat(He.axisType,"Id")];We&&We[tt]||He.axisType==="zAxis"||x3();var Ke=We[tt];return Nr(Nr({},lt),{},gi(gi({},He.axisType,Ke),"".concat(He.axisType,"Ticks"),i1(Ke)))},Ae),ke=Me[ne],Oe=Me["".concat(ne,"Ticks")],qe=I&&I[Se]&&I[Se].hasStack&&Zus(he,I[Se].stackGroups),ve=j1(he.type).indexOf("Bar")>=0,dt=Ice(ke,Oe),pe=[],Ue=re&&Ous({barSize:z,stackGroups:I,totalSize:_1s(Me,ne)});if(ve){var Xe,et,Ce=Ui(Be)?J:Be,Je=(Xe=(et=Ice(ke,Oe,!0))!==null&&et!==void 0?et:Ce)!==null&&Xe!==void 0?Xe:0;pe=Rus({barGap:X,barCategoryGap:Y,bandSize:Je!==dt?Je:dt,sizeList:Ue[Ee],maxBarSize:Ce}),Je!==dt&&(pe=pe.map(function(lt){return Nr(Nr({},lt),{},{position:Nr(Nr({},lt.position),{},{offset:lt.position.offset-Je/2})})}))}var Ge=he&&he.type&&he.type.getComposedData;Ge&&oe.push({props:Nr(Nr({},Ge(Nr(Nr({},Me),{},{displayedData:ue,props:N,dataKey:_e,item:he,bandSize:dt,barPosition:pe,offset:P,stackedData:qe,layout:V,dataStartIndex:q,dataEndIndex:$}))),{},gi(gi(gi({key:he.key||"item-".concat(xe)},ce,Me[ce]),ne,Me[ne]),"animationId",O)),childIndex:RYt(he,N.children),item:he})}),oe},y=function(N,S){var M=N.props,I=N.dataStartIndex,P=N.dataEndIndex,O=N.updateId;if(!pDe({props:M}))return null;var q=M.children,$=M.layout,z=M.stackOffset,V=M.data,X=M.reverseStackOrder,Y=t7e($),J=Y.numericAxisName,Q=Y.cateAxisName,ce=Sf(q,n),ne=Wus(V,ce,"".concat(J,"Id"),"".concat(Q,"Id"),z,X),re=c.reduce(function(ge,_e){var Be="".concat(_e.axisType,"Map");return Nr(Nr({},ge),{},gi({},Be,g1s(M,Nr(Nr({},_e),{},{graphicalItems:ce,stackGroups:_e.axisType===J&&ne,dataStartIndex:I,dataEndIndex:P}))))},{}),oe=b1s(Nr(Nr({},re),{},{props:M,graphicalItems:ce}),S==null?void 0:S.legendBBox);Object.keys(re).forEach(function(ge){re[ge]=m(M,re[ge],oe,ge.replace("Map",""),r)});var he=re["".concat(Q,"Map")],xe=y1s(he),ue=g(M,Nr(Nr({},re),{},{dataStartIndex:I,dataEndIndex:P,updateId:O,graphicalItems:ce,stackGroups:ne,offset:oe}));return Nr(Nr({formattedGraphicalItems:ue,graphicalItems:ce,offset:oe,stackGroups:ne},xe),re)},_=function(j){function N(S){var M,I,P;return e1s(this,N),P=r1s(this,N,[S]),gi(P,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),gi(P,"accessibilityManager",new Bvs),gi(P,"handleLegendBBoxUpdate",function(O){if(O){var q=P.state,$=q.dataStartIndex,z=q.dataEndIndex,V=q.updateId;P.setState(Nr({legendBBox:O},y({props:P.props,dataStartIndex:$,dataEndIndex:z,updateId:V},Nr(Nr({},P.state),{},{legendBBox:O}))))}}),gi(P,"handleReceiveSyncEvent",function(O,q,$){if(P.props.syncId===O){if($===P.eventEmitterSymbol&&typeof P.props.syncMethod!="function")return;P.applySyncEvent(q)}}),gi(P,"handleBrushChange",function(O){var q=O.startIndex,$=O.endIndex;if(q!==P.state.dataStartIndex||$!==P.state.dataEndIndex){var z=P.state.updateId;P.setState(function(){return Nr({dataStartIndex:q,dataEndIndex:$},y({props:P.props,dataStartIndex:q,dataEndIndex:$,updateId:z},P.state))}),P.triggerSyncEvent({dataStartIndex:q,dataEndIndex:$})}}),gi(P,"handleMouseEnter",function(O){var q=P.getMouseInfo(O);if(q){var $=Nr(Nr({},q),{},{isTooltipActive:!0});P.setState($),P.triggerSyncEvent($);var z=P.props.onMouseEnter;Ai(z)&&z($,O)}}),gi(P,"triggeredAfterMouseMove",function(O){var q=P.getMouseInfo(O),$=q?Nr(Nr({},q),{},{isTooltipActive:!0}):{isTooltipActive:!1};P.setState($),P.triggerSyncEvent($);var z=P.props.onMouseMove;Ai(z)&&z($,O)}),gi(P,"handleItemMouseEnter",function(O){P.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),gi(P,"handleItemMouseLeave",function(){P.setState(function(){return{isTooltipActive:!1}})}),gi(P,"handleMouseMove",function(O){O.persist(),P.throttleTriggeredAfterMouseMove(O)}),gi(P,"handleMouseLeave",function(O){P.throttleTriggeredAfterMouseMove.cancel();var q={isTooltipActive:!1};P.setState(q),P.triggerSyncEvent(q);var $=P.props.onMouseLeave;Ai($)&&$(q,O)}),gi(P,"handleOuterEvent",function(O){var q=OYt(O),$=kf(P.props,"".concat(q));if(q&&Ai($)){var z,V;/.*touch.*/i.test(q)?V=P.getMouseInfo(O.changedTouches[0]):V=P.getMouseInfo(O),$((z=V)!==null&&z!==void 0?z:{},O)}}),gi(P,"handleClick",function(O){var q=P.getMouseInfo(O);if(q){var $=Nr(Nr({},q),{},{isTooltipActive:!0});P.setState($),P.triggerSyncEvent($);var z=P.props.onClick;Ai(z)&&z($,O)}}),gi(P,"handleMouseDown",function(O){var q=P.props.onMouseDown;if(Ai(q)){var $=P.getMouseInfo(O);q($,O)}}),gi(P,"handleMouseUp",function(O){var q=P.props.onMouseUp;if(Ai(q)){var $=P.getMouseInfo(O);q($,O)}}),gi(P,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),gi(P,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.handleMouseDown(O.changedTouches[0])}),gi(P,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.handleMouseUp(O.changedTouches[0])}),gi(P,"handleDoubleClick",function(O){var q=P.props.onDoubleClick;if(Ai(q)){var $=P.getMouseInfo(O);q($,O)}}),gi(P,"handleContextMenu",function(O){var q=P.props.onContextMenu;if(Ai(q)){var $=P.getMouseInfo(O);q($,O)}}),gi(P,"triggerSyncEvent",function(O){P.props.syncId!==void 0&&Sye.emit(Cye,P.props.syncId,O,P.eventEmitterSymbol)}),gi(P,"applySyncEvent",function(O){var q=P.props,$=q.layout,z=q.syncMethod,V=P.state.updateId,X=O.dataStartIndex,Y=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)P.setState(Nr({dataStartIndex:X,dataEndIndex:Y},y({props:P.props,dataStartIndex:X,dataEndIndex:Y,updateId:V},P.state)));else if(O.activeTooltipIndex!==void 0){var J=O.chartX,Q=O.chartY,ce=O.activeTooltipIndex,ne=P.state,re=ne.offset,oe=ne.tooltipTicks;if(!re)return;if(typeof z=="function")ce=z(oe,O);else if(z==="value"){ce=-1;for(var he=0;he=0){var qe,ve;if(J.dataKey&&!J.allowDuplicatedCategory){var dt=typeof J.dataKey=="function"?Oe:"payload.".concat(J.dataKey.toString());qe=ace(he,dt,ce),ve=xe&&ue&&ace(ue,dt,ce)}else qe=he==null?void 0:he[Q],ve=xe&&ue&&ue[Q];if(Ee||Se){var pe=O.props.activeIndex!==void 0?O.props.activeIndex:Q;return[k.cloneElement(O,Nr(Nr(Nr({},z.props),Me),{},{activeIndex:pe})),null,null]}if(!Ui(qe))return[ke].concat(RA(P.renderActivePoints({item:z,activePoint:qe,basePoint:ve,childIndex:Q,isRange:xe})))}else{var Ue,Xe=(Ue=P.getItemByXY(P.state.activeCoordinate))!==null&&Ue!==void 0?Ue:{graphicalItem:ke},et=Xe.graphicalItem,Ce=et.item,Je=Ce===void 0?O:Ce,Ge=et.childIndex,lt=Nr(Nr(Nr({},z.props),Me),{},{activeIndex:Ge});return[k.cloneElement(Je,lt),null,null]}return xe?[ke,null,null]:[ke,null]}),gi(P,"renderCustomized",function(O,q,$){return k.cloneElement(O,Nr(Nr({key:"recharts-customized-".concat($)},P.props),P.state))}),gi(P,"renderMap",{CartesianGrid:{handler:o9,once:!0},ReferenceArea:{handler:P.renderReferenceElement},ReferenceLine:{handler:o9},ReferenceDot:{handler:P.renderReferenceElement},XAxis:{handler:o9},YAxis:{handler:o9},Brush:{handler:P.renderBrush,once:!0},Bar:{handler:P.renderGraphicChild},Line:{handler:P.renderGraphicChild},Area:{handler:P.renderGraphicChild},Radar:{handler:P.renderGraphicChild},RadialBar:{handler:P.renderGraphicChild},Scatter:{handler:P.renderGraphicChild},Pie:{handler:P.renderGraphicChild},Funnel:{handler:P.renderGraphicChild},Tooltip:{handler:P.renderCursor,once:!0},PolarGrid:{handler:P.renderPolarGrid,once:!0},PolarAngleAxis:{handler:P.renderPolarAxis},PolarRadiusAxis:{handler:P.renderPolarAxis},Customized:{handler:P.renderCustomized}}),P.clipPathId="".concat((M=S.id)!==null&&M!==void 0?M:DE("recharts"),"-clip"),P.throttleTriggeredAfterMouseMove=wrt(P.triggeredAfterMouseMove,(I=S.throttleDelay)!==null&&I!==void 0?I:1e3/60),P.state={},P}return i1s(N,j),s1s(N,[{key:"componentDidMount",value:function(){var M,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,I=M.children,P=M.data,O=M.height,q=M.layout,$=nf(I,mp);if($){var z=$.props.defaultIndex;if(!(typeof z!="number"||z<0||z>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,X=J_e(this.state,P,z,V),Y=this.state.tooltipTicks[z].coordinate,J=(this.state.offset.top+O)/2,Q=q==="horizontal",ce=Q?{x:Y,y:J}:{y:Y,x:J},ne=this.state.formattedGraphicalItems.find(function(oe){var he=oe.item;return he.type.name==="Scatter"});ne&&(ce=Nr(Nr({},ce),ne.props.points[z].tooltipPosition),X=ne.props.points[z].tooltipPayload);var re={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:V,activePayload:X,activeCoordinate:ce};this.setState(re),this.renderCursor($),this.accessibilityManager.setIndex(z)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.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 P,O;this.accessibilityManager.setDetails({offset:{left:(P=this.props.margin.left)!==null&&P!==void 0?P:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(M){Mbe([nf(M.children,mp)],[nf(this.props.children,mp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=nf(this.props.children,mp);if(M&&typeof M.props.shared=="boolean"){var I=M.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var I=this.container,P=I.getBoundingClientRect(),O=cos(P),q={chartX:Math.round(M.pageX-O.left),chartY:Math.round(M.pageY-O.top)},$=P.width/I.offsetWidth||1,z=this.inRange(q.chartX,q.chartY,$);if(!z)return null;var V=this.state,X=V.xAxisMap,Y=V.yAxisMap,J=this.getTooltipEventType(),Q=JFe(this.state,this.props.data,this.props.layout,z);if(J!=="axis"&&X&&Y){var ce=g_(X).scale,ne=g_(Y).scale,re=ce&&ce.invert?ce.invert(q.chartX):null,oe=ne&&ne.invert?ne.invert(q.chartY):null;return Nr(Nr({},q),{},{xValue:re,yValue:oe},Q)}return Q?Nr(Nr({},q),Q):null}},{key:"inRange",value:function(M,I){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,q=M/P,$=I/P;if(O==="horizontal"||O==="vertical"){var z=this.state.offset,V=q>=z.left&&q<=z.left+z.width&&$>=z.top&&$<=z.top+z.height;return V?{x:q,y:$}:null}var X=this.state,Y=X.angleAxisMap,J=X.radiusAxisMap;if(Y&&J){var Q=g_(Y);return NRe({x:q,y:$},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,I=this.getTooltipEventType(),P=nf(M,mp),O={};P&&I==="axis"&&(P.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=ice(this.props,this.handleOuterEvent);return Nr(Nr({},q),O)}},{key:"addListener",value:function(){Sye.on(Cye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Sye.removeListener(Cye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,I,P){for(var O=this.state.formattedGraphicalItems,q=0,$=O.length;q<$;q++){var z=O[q];if(z.item===M||z.props.key===M.key||I===j1(z.item.type)&&P===z.childIndex)return z}return null}},{key:"renderClipPath",value:function(){var M=this.clipPathId,I=this.state.offset,P=I.left,O=I.top,q=I.height,$=I.width;return mt.createElement("defs",null,mt.createElement("clipPath",{id:M},mt.createElement("rect",{x:P,y:O,height:q,width:$})))}},{key:"getXScales",value:function(){var M=this.state.xAxisMap;return M?Object.entries(M).reduce(function(I,P){var O=YFe(P,2),q=O[0],$=O[1];return Nr(Nr({},I),{},gi({},q,$.scale))},{}):null}},{key:"getYScales",value:function(){var M=this.state.yAxisMap;return M?Object.entries(M).reduce(function(I,P){var O=YFe(P,2),q=O[0],$=O[1];return Nr(Nr({},I),{},gi({},q,$.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(M){var I;return(I=this.state.xAxisMap)===null||I===void 0||(I=I[M])===null||I===void 0?void 0:I.scale}},{key:"getYScaleByAxisId",value:function(M){var I;return(I=this.state.yAxisMap)===null||I===void 0||(I=I[M])===null||I===void 0?void 0:I.scale}},{key:"getItemByXY",value:function(M){var I=this.state,P=I.formattedGraphicalItems,O=I.activeItem;if(P&&P.length)for(var q=0,$=P.length;q<$;q++){var z=P[q],V=z.props,X=z.item,Y=X.type.defaultProps!==void 0?Nr(Nr({},X.type.defaultProps),X.props):X.props,J=j1(X.type);if(J==="Bar"){var Q=(V.data||[]).find(function(oe){return Hps(M,oe)});if(Q)return{graphicalItem:z,payload:Q}}else if(J==="RadialBar"){var ce=(V.data||[]).find(function(oe){return NRe(M,oe)});if(ce)return{graphicalItem:z,payload:ce}}else if(Khe(z,O)||Zhe(z,O)||pO(z,O)){var ne=Ixs({graphicalItem:z,activeTooltipItem:O,itemData:Y.data}),re=Y.activeIndex===void 0?ne:Y.activeIndex;return{graphicalItem:Nr(Nr({},z),{},{childIndex:re}),payload:pO(z,O)?Y.data[ne]:z.props.data[ne]}}}return null}},{key:"render",value:function(){var M=this;if(!pDe(this))return null;var I=this.props,P=I.children,O=I.className,q=I.width,$=I.height,z=I.style,V=I.compact,X=I.title,Y=I.desc,J=QFe(I,Zvs),Q=di(J,!1);if(V)return mt.createElement(PFe,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},mt.createElement(Abe,AM({},Q,{width:q,height:$,title:X,desc:Y}),this.renderClipPath(),xDe(P,this.renderMap)));if(this.props.accessibilityLayer){var ce,ne;Q.tabIndex=(ce=this.props.tabIndex)!==null&&ce!==void 0?ce:0,Q.role=(ne=this.props.role)!==null&&ne!==void 0?ne:"application",Q.onKeyDown=function(oe){M.accessibilityManager.keyboardEvent(oe)},Q.onFocus=function(){M.accessibilityManager.focus()}}var re=this.parseEventsOfWrapper();return mt.createElement(PFe,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},mt.createElement("div",AM({className:Hi("recharts-wrapper",O),style:Nr({position:"relative",cursor:"default",width:q,height:$},z)},re,{ref:function(he){M.container=he}}),mt.createElement(Abe,AM({},Q,{width:q,height:$,title:X,desc:Y,style:h1s}),this.renderClipPath(),xDe(P,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(k.Component);gi(_,"displayName",r),gi(_,"defaultProps",Nr({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},f)),gi(_,"getDerivedStateFromProps",function(j,N){var S=j.dataKey,M=j.data,I=j.children,P=j.width,O=j.height,q=j.layout,$=j.stackOffset,z=j.margin,V=N.dataStartIndex,X=N.dataEndIndex;if(N.updateId===void 0){var Y=e7e(j);return Nr(Nr(Nr({},Y),{},{updateId:0},y(Nr(Nr({props:j},Y),{},{updateId:0}),N)),{},{prevDataKey:S,prevData:M,prevWidth:P,prevHeight:O,prevLayout:q,prevStackOffset:$,prevMargin:z,prevChildren:I})}if(S!==N.prevDataKey||M!==N.prevData||P!==N.prevWidth||O!==N.prevHeight||q!==N.prevLayout||$!==N.prevStackOffset||!bT(z,N.prevMargin)){var J=e7e(j),Q={chartX:N.chartX,chartY:N.chartY,isTooltipActive:N.isTooltipActive},ce=Nr(Nr({},JFe(N,M,q)),{},{updateId:N.updateId+1}),ne=Nr(Nr(Nr({},J),Q),ce);return Nr(Nr(Nr({},ne),y(Nr({props:j},ne),N)),{},{prevDataKey:S,prevData:M,prevWidth:P,prevHeight:O,prevLayout:q,prevStackOffset:$,prevMargin:z,prevChildren:I})}if(!Mbe(I,N.prevChildren)){var re,oe,he,xe,ue=nf(I,CA),ge=ue&&(re=(oe=ue.props)===null||oe===void 0?void 0:oe.startIndex)!==null&&re!==void 0?re:V,_e=ue&&(he=(xe=ue.props)===null||xe===void 0?void 0:xe.endIndex)!==null&&he!==void 0?he:X,Be=ge!==V||_e!==X,Se=!Ui(M),Ee=Se&&!Be?N.updateId:N.updateId+1;return Nr(Nr({updateId:Ee},y(Nr(Nr({props:j},N),{},{updateId:Ee,dataStartIndex:ge,dataEndIndex:_e}),N)),{},{prevChildren:I,dataStartIndex:ge,dataEndIndex:_e})}return null}),gi(_,"renderActiveDot",function(j,N,S){var M;return k.isValidElement(j)?M=k.cloneElement(j,N):Ai(j)?M=j(N):M=mt.createElement(Uhe,N),mt.createElement(Xo,{className:"recharts-active-dot",key:S},M)});var w=k.forwardRef(function(N,S){return mt.createElement(_,AM({},N,{ref:S}))});return w.displayName=_.displayName,w},w1s=ySe({chartName:"LineChart",GraphicalChild:AR,axisComponents:[{axisType:"xAxis",AxisComp:y3},{axisType:"yAxis",AxisComp:v3}],formatAxisMap:hat}),Zat=ySe({chartName:"BarChart",GraphicalChild:B1,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:y3},{axisType:"yAxis",AxisComp:v3}],formatAxisMap:hat}),Yat=ySe({chartName:"PieChart",GraphicalChild:Y0,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Whe},{axisType:"radiusAxis",AxisComp:Hhe}],formatAxisMap:ahs,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const s7e=["hsl(220, 70%, 50%)","hsl(142, 71%, 45%)","hsl(270, 70%, 50%)","hsl(30, 90%, 55%)","hsl(350, 70%, 55%)","hsl(180, 60%, 45%)"];function j1s(){const t=ar(),{data:s,isLoading:r}=pt({queryKey:["email-campaign-analytics"],queryFn:async()=>{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}=pt({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),m=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",y=[{label:"Campaigns Sent",value:a.length,icon:Fn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:ur,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:Tn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${g}%`,icon:kh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:vd,color:"text-orange-600"},{label:"Complaints",value:m,icon:Bo,color:"text-destructive"}],_=new Map;a.forEach(S=>{var P,O;const M=S.user_id,I=_.get(M)||{name:((P=o.get(M))==null?void 0:P.name)||((O=o.get(M))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=S.sent_count||0,I.opens+=S.open_count||0,I.clicks+=S.click_count||0,_.set(M,I)});const w=[..._.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),j=w.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?ds(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Fn,{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:y.map(S=>e.jsx(Pe,{children:e.jsxs(De,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(wT,{width:"100%",height:"100%",children:e.jsxs(Zat,{data:N,children:[e.jsx(y3,{dataKey:"date",fontSize:11}),e.jsx(v3,{fontSize:11,unit:"%"}),e.jsx(mp,{formatter:S=>`${S}%`}),e.jsx(B1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(B1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(wT,{width:"100%",height:"100%",children:e.jsxs(Yat,{children:[e.jsx(Y0,{data:j,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:M})=>`${S} (${(M*100).toFixed(0)}%)`,fontSize:11,children:j.map((S,M)=>e.jsx(jR,{fill:s7e[M%s7e.length]},M))}),e.jsx(mp,{})]})})})})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(De,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(wT,{width:"100%",height:"100%",children:e.jsxs(w1s,{data:N,children:[e.jsx(y3,{dataKey:"date",fontSize:11}),e.jsx(v3,{fontSize:11}),e.jsx(mp,{}),e.jsx(AR,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Agent Performance"})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:w.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(Ye,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,M)=>{const I=S.sent_count>0?S.open_count/S.sent_count:0;return(M.sent_count>0?M.open_count/M.sent_count:0)-I}).slice(0,10).map((S,M)=>{const I=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",P=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?ds(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(kh,{className:"h-3 w-3"})," ",P,"%"]})]})]},S.id)})})})]})]})})}const N1s=()=>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(ga,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"analytics",children:"Analytics"}),e.jsx(ss,{value:"content",children:"Content"}),e.jsx(ss,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ss,{value:"activity",children:"Activity"}),e.jsx(ss,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(UGt,{})}),e.jsx(bs,{value:"content",className:"space-y-4",children:e.jsx(HGt,{})}),e.jsx(bs,{value:"email-campaigns",className:"space-y-4",children:e.jsx(j1s,{})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(qGt,{})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(ost,{})})]})]})});function k1s(){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,m]=k.useState(""),[f,g]=k.useState([]),[y,_]=k.useState([]),[w,j]=k.useState([]),[N,S]=k.useState(!1),[M,I]=k.useState(null),[P,O]=k.useState(""),{data:q,isLoading:$}=pt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(dt)throw dt;return ve}}),{data:z}=pt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:V}=pt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:X}=pt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:Y,isLoading:J}=pt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),Q=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),m(""),g([]),_([]),j([]),a(null),O("")},ce=ve=>{a(ve),l({title:ve.title,description:ve.description||"",publish_date:ve.publish_date.split("T")[0],is_published:ve.is_published,category_id:ve.category_id||""}),m(ve.preview_image_url||""),O("");const dt=(z==null?void 0:z.filter(Xe=>Xe.resource_id===ve.id))||[];g(dt.map(Xe=>({id:Xe.id,name:Xe.name,file_url:Xe.file_url,file_size:Xe.file_size,sort_order:Xe.sort_order})));const pe=(V==null?void 0:V.filter(Xe=>Xe.resource_id===ve.id))||[];_(pe.map(Xe=>({id:Xe.id,title:Xe.title,video_url:Xe.video_url,sort_order:Xe.sort_order})));const Ue=(X==null?void 0:X.filter(Xe=>Xe.resource_id===ve.id))||[];j(Ue.map(Xe=>({id:Xe.id,title:Xe.title,canva_share_link:Xe.canva_share_link,sort_order:Xe.sort_order}))),r(!0)},ne=ve=>{var pe;const dt=(pe=ve.target.files)==null?void 0:pe[0];dt&&(c(dt),m(URL.createObjectURL(dt)))},re=()=>{g([...f,{name:"",file_url:"",sort_order:f.length}])},oe=ve=>{g(f.filter((dt,pe)=>pe!==ve))},he=(ve,dt,pe)=>{const Ue=[...f];if(dt==="file"&&pe instanceof File){const Xe=pe.name.replace(/\.[^/.]+$/,"");Ue[ve]={...Ue[ve],file:pe,file_size:pe.size,name:Ue[ve].name||Xe}}else Ue[ve]={...Ue[ve],[dt]:pe};g(Ue)},xe=()=>{_([...y,{title:"",video_url:"",sort_order:y.length}])},ue=ve=>{_(y.filter((dt,pe)=>pe!==ve))},ge=(ve,dt,pe)=>{const Ue=[...y];dt==="file"&&pe instanceof File?Ue[ve]={...Ue[ve],file:pe}:Ue[ve]={...Ue[ve],[dt]:pe},_(Ue)},_e=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},Be=ve=>{j(w.filter((dt,pe)=>pe!==ve))},Se=(ve,dt,pe)=>{const Ue=[...w];Ue[ve]={...Ue[ve],[dt]:pe},j(Ue)},Ee=async(ve,dt)=>{try{const pe=await H.functions.invoke("bunny-upload",{body:{action:"create",title:ve.name}});if(pe.error)throw pe.error;const{videoId:Ue,uploadUrl:Xe,libraryId:et}=pe.data,Ce=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ue,libraryId:et}});if(Ce.error)throw Ce.error;const{uploadUrl:Je,apiKey:Ge}=Ce.data,lt=new XMLHttpRequest;return lt.open("PUT",Je,!0),lt.setRequestHeader("AccessKey",Ge),lt.upload.onprogress=He=>{if(He.lengthComputable){const We=Math.round(He.loaded/He.total*100),tt=[...y];tt[dt]={...tt[dt],uploadProgress:We},_(tt)}},await new Promise((He,We)=>{lt.onload=()=>lt.status>=200&<.status<300?He():We(new Error("Upload failed")),lt.onerror=()=>We(new Error("Upload failed")),lt.send(ve)}),`https://iframe.mediadelivery.net/embed/${et}/${Ue}`}catch(pe){throw console.error("Bunny upload error:",pe),pe}},Ae=Tt({mutationFn:async ve=>{const{data:dt,error:pe}=await H.from("brokerage_resource_categories").insert({name:ve,sort_order:(Y==null?void 0:Y.length)||0}).select().single();if(pe)throw pe;return dt},onSuccess:ve=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:ve.id}),O(""),me.success("Category created")},onError:ve=>{me.error("Failed to create category: "+ve.message)}}),Me=Tt({mutationFn:async()=>{S(!0);let ve=(n==null?void 0:n.preview_image_url)||null;if(i){const Ue=i.name.split(".").pop(),Xe=`${Date.now()}.${Ue}`,{error:et}=await H.storage.from("brokerage-resources").upload(`previews/${Xe}`,i);if(et)throw et;const{data:Ce}=H.storage.from("brokerage-resources").getPublicUrl(`previews/${Xe}`);ve=Ce.publicUrl}const dt={title:o.title,description:o.description||null,preview_image_url:ve,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let pe;if(n){const{error:Ue}=await H.from("brokerage_resources").update(dt).eq("id",n.id);if(Ue)throw Ue;pe=n.id;const Xe=(z==null?void 0:z.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],et=f.filter(Ke=>Ke.id).map(Ke=>Ke.id),Ce=Xe.filter(Ke=>!et.includes(Ke));Ce.length>0&&await H.from("brokerage_resource_pdfs").delete().in("id",Ce);const Je=(V==null?void 0:V.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],Ge=y.filter(Ke=>Ke.id).map(Ke=>Ke.id),lt=Je.filter(Ke=>!Ge.includes(Ke));lt.length>0&&await H.from("brokerage_resource_videos").delete().in("id",lt);const He=(X==null?void 0:X.filter(Ke=>Ke.resource_id===n.id).map(Ke=>Ke.id))||[],We=w.filter(Ke=>Ke.id).map(Ke=>Ke.id),tt=He.filter(Ke=>!We.includes(Ke));tt.length>0&&await H.from("brokerage_resource_links").delete().in("id",tt)}else{const{data:Ue,error:Xe}=await H.from("brokerage_resources").insert(dt).select().single();if(Xe)throw Xe;pe=Ue.id}for(let Ue=0;Ue{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),Q(),S(!1)},onError:ve=>{me.error("Failed to save resource: "+ve.message),S(!1)}}),ke=Tt({mutationFn:async ve=>{const{error:dt}=await H.from("brokerage_resources").delete().eq("id",ve);if(dt)throw dt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:ve=>{me.error("Failed to delete: "+ve.message)}}),Oe=ve=>{if(ve.preventDefault(),!o.title){me.error("Please enter a title");return}Me.mutate()},qe=ve=>{const dt=(z==null?void 0:z.filter(Xe=>Xe.resource_id===ve).length)||0,pe=(V==null?void 0:V.filter(Xe=>Xe.resource_id===ve).length)||0,Ue=(X==null?void 0:X.filter(Xe=>Xe.resource_id===ve).length)||0;return{pdfCount:dt,videoCount:pe,linkCount:Ue}};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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.filter(ve=>ve.is_published).length)||0})})]})]}),e.jsxs(G,{onClick:()=>{Q(),r(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Content"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:$?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(q==null?void 0:q.length)===0?e.jsx(ks,{children:e.jsx(ut,{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(ve=>{const{pdfCount:dt,videoCount:pe,linkCount:Ue}=qe(ve.id),Xe=Y==null?void 0:Y.find(et=>et.id===ve.category_id);return e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ve.preview_image_url?e.jsx("img",{src:ve.preview_image_url,alt:ve.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(sh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ve.title}),ve.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:ve.description})]})]})}),e.jsx(ut,{children:Xe?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:Xe.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{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(wn,{className:"h-3.5 w-3.5"}),dt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(An,{className:"h-3.5 w-3.5"}),pe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uo,{className:"h-3.5 w-3.5"}),Ue]})]})}),e.jsx(ut,{children:ds(new Date(ve.publish_date),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${ve.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:ve.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{const et=(z==null?void 0:z.filter(Ge=>Ge.resource_id===ve.id))||[],Ce=(V==null?void 0:V.filter(Ge=>Ge.resource_id===ve.id))||[],Je=(X==null?void 0:X.filter(Ge=>Ge.resource_id===ve.id))||[];I({...ve,pdfs:et,videos:Ce,links:Je})},children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>ce(ve),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&ke.mutate(ve.id)},children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},ve.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(js,{children:e.jsx(vs,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Oe,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(sh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Le,{type:"file",accept:"image/*",onChange:ne})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:o.title,onChange:ve=>l({...o,title:ve.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(Lh,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:o.category_id,onValueChange:ve=>l({...o,category_id:ve}),children:[e.jsx(Ls,{className:"flex-1",children:e.jsx($s,{placeholder:"Select a category"})}),e.jsx(Ds,{children:Y==null?void 0:Y.map(ve=>e.jsx(ft,{value:ve.id,children:ve.name},ve.id))})]}),o.category_id&&e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Er,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Or create new category...",value:P,onChange:ve=>O(ve.target.value),className:"flex-1"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",disabled:!P.trim()||Ae.isPending,onClick:()=>Ae.mutate(P.trim()),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:o.description,onChange:ve=>l({...o,description:ve}),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(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:o.publish_date,onChange:ve=>l({...o,publish_date:ve.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:o.is_published,onCheckedChange:ve=>l({...o,is_published:ve})}),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(ye,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:re,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((ve,dt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Le,{placeholder:"PDF Name",value:ve.name,onChange:pe=>he(dt,"name",pe.target.value),className:"flex-1"}),e.jsx(Le,{type:"file",accept:".pdf",onChange:pe=>{var Xe;const Ue=(Xe=pe.target.files)==null?void 0:Xe[0];Ue&&he(dt,"file",Ue)},className:"flex-1"}),ve.file_url&&!ve.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(dt),children:e.jsx(Er,{className:"h-4 w-4"})})]},dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Videos (",y.length,")"]}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:xe,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),y.map((ve,dt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{placeholder:"Video Title",value:ve.title,onChange:pe=>ge(dt,"title",pe.target.value),className:"flex-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>ue(dt),children:e.jsx(Er,{className:"h-4 w-4"})})]}),e.jsx(Le,{type:"file",accept:"video/*",onChange:pe=>{var Xe;const Ue=(Xe=pe.target.files)==null?void 0:Xe[0];Ue&&ge(dt,"file",Ue)}}),ve.uploadProgress!==void 0&&ve.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:`${ve.uploadProgress}%`}})}),ve.video_url&&!ve.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((ve,dt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Le,{placeholder:"Link Title",value:ve.title,onChange:pe=>Se(dt,"title",pe.target.value),className:"flex-1"}),e.jsx(Le,{placeholder:"Canva Share Link",value:ve.canva_share_link,onChange:pe=>Se(dt,"canva_share_link",pe.target.value),className:"flex-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>Be(dt),children:e.jsx(Er,{className:"h-4 w-4"})})]},dt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:Me.isPending||N,children:Me.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(wn,{className:"h-4 w-4"}),"PDF Documents (",M.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.pdfs.map(ve=>e.jsx("a",{href:ve.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ve.name},ve.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(ve=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:ve.title})},ve.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(Uo,{className:"h-4 w-4"}),"Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.links.map(ve=>e.jsx("a",{href:ve.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ve.title},ve.id))})]})]})]})})]})})}const Qat=[{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 S1s(){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),[m,f]=k.useState(!1),[g,y]=k.useState(!1),[_,w]=k.useState(""),[j,N]=k.useState(""),[S,M]=k.useState(""),[I,P]=k.useState(""),[O,q]=k.useState("Learn More"),[$,z]=k.useState("top"),[V,X]=k.useState(""),[Y,J]=k.useState(!0),[Q,ce]=k.useState(""),[ne,re]=k.useState("");k.useEffect(()=>{oe()},[]);const oe=async()=>{try{const{data:Ae,error:Me}=await H.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Me)throw Me;s(Ae||[])}catch(Ae){me.error("Failed to load banners: "+Ae.message)}finally{n(!1)}},he=()=>{w(""),N(""),M(""),P(""),q("Learn More"),z("top"),X(""),J(!0),ce(""),re(""),u(null)},xe=Ae=>{u(Ae),w(Ae.title),N(Ae.description||""),M(Ae.image_url),P(Ae.link_url||""),q(Ae.link_text||"Learn More"),z(Ae.placement),X(Ae.section_after||""),J(Ae.is_active),ce(Ae.start_date?ds(new Date(Ae.start_date),"yyyy-MM-dd'T'HH:mm"):""),re(Ae.end_date?ds(new Date(Ae.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ue=async Ae=>{var ke;const Me=(ke=Ae.target.files)==null?void 0:ke[0];if(Me){f(!0);try{const Oe=Me.name.split(".").pop(),qe=`${Date.now()}.${Oe}`,{error:ve}=await H.storage.from("banner-images").upload(qe,Me);if(ve)throw ve;const{data:{publicUrl:dt}}=H.storage.from("banner-images").getPublicUrl(qe);M(dt),me.success("Image uploaded successfully")}catch(Oe){me.error("Failed to upload image: "+Oe.message)}finally{f(!1)}}},ge=async()=>{if(!_.trim()||!S){me.error("Please fill in required fields (title and image)");return}y(!0);try{const Ae={title:_.trim(),description:j.trim()||null,image_url:S,link_url:I.trim()||null,link_text:O.trim()||"Learn More",placement:$,section_after:$==="between"?V:null,is_active:Y,start_date:Q?new Date(Q).toISOString():null,end_date:ne?new Date(ne).toISOString():null};if(c){const{error:Me}=await H.from("dashboard_banners").update(Ae).eq("id",c.id);if(Me)throw Me;me.success("Banner updated successfully")}else{const Me=t.filter(Oe=>Oe.placement===$).length,{error:ke}=await H.from("dashboard_banners").insert({...Ae,sort_order:Me});if(ke)throw ke;me.success("Banner created successfully")}o(!1),he(),oe()}catch(Ae){me.error("Failed to save banner: "+Ae.message)}finally{y(!1)}},_e=async()=>{if(c)try{const{error:Ae}=await H.from("dashboard_banners").delete().eq("id",c.id);if(Ae)throw Ae;me.success("Banner deleted successfully"),i(!1),u(null),oe()}catch(Ae){me.error("Failed to delete banner: "+Ae.message)}},Be=async Ae=>{try{const{error:Me}=await H.from("dashboard_banners").update({is_active:!Ae.is_active}).eq("id",Ae.id);if(Me)throw Me;me.success(Ae.is_active?"Banner deactivated":"Banner activated"),oe()}catch(Me){me.error("Failed to update banner: "+Me.message)}},Se=t.filter(Ae=>Ae.placement==="top"),Ee=t.filter(Ae=>Ae.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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(bl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(vr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&$==="top",onOpenChange:Ae=>{Ae||he(),o(Ae),Ae&&z("top")},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{onClick:()=>{he(),z("top")},children:[e.jsx(qs,{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(js,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Gr,{children:"Configure the banner's content and display settings"})]}),e.jsx(r7e,{title:_,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:P,linkText:O,setLinkText:q,placement:$,setPlacement:z,sectionAfter:V,setSectionAfter:X,isActive:Y,setIsActive:J,startDate:Q,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:ue,uploading:m,showPlacementOptions:!1}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(G,{onClick:ge,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(De,{children:Se.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:Se.map(Ae=>e.jsx(n7e,{banner:Ae,onEdit:()=>xe(Ae),onDelete:()=>{u(Ae),i(!0)},onToggleActive:()=>Be(Ae)},Ae.id))})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(bl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(vr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&$==="between",onOpenChange:Ae=>{Ae||he(),o(Ae),Ae&&z("between")},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{onClick:()=>{he(),z("between")},children:[e.jsx(qs,{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(js,{children:[e.jsxs(vs,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Gr,{children:"Configure where this banner appears between sections"})]}),e.jsx(r7e,{title:_,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:P,linkText:O,setLinkText:q,placement:$,setPlacement:z,sectionAfter:V,setSectionAfter:X,isActive:Y,setIsActive:J,startDate:Q,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:ue,uploading:m,showPlacementOptions:!0}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(G,{onClick:ge,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(De,{children:Ee.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ee.map(Ae=>e.jsx(n7e,{banner:Ae,onEdit:()=>xe(Ae),onDelete:()=>{u(Ae),i(!0)},onToggleActive:()=>Be(Ae),showSection:!0},Ae.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsxs(js,{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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:_e,children:"Delete"})]})]})})]})}function r7e({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:c,placement:u,setPlacement:m,sectionAfter:f,setSectionAfter:g,isActive:y,setIsActive:_,startDate:w,setStartDate:j,endDate:N,setEndDate:S,handleImageUpload:M,uploading:I,showPlacementOptions:P}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{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(ye,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Le,{type:"file",accept:"image/*",onChange:M,disabled:I,className:"flex-1"}),I&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Le,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Le,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>c(O.target.value)})]})]}),P&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Placement"}),e.jsxs(Rs,{value:f,onValueChange:g,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select section placement..."})}),e.jsx(Ds,{children:Qat.map(O=>e.jsx(ft,{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(ye,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Le,{id:"startDate",type:"datetime-local",value:w,onChange:O=>j(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Le,{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:y,onCheckedChange:_}),e.jsx(ye,{htmlFor:"isActive",children:"Active"})]})})]})}function n7e({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var c;const o=(c=Qat.find(u=>u.value===t.section_after))==null?void 0:c.label,[l,i]=k.useState(null);return k.useEffect(()=>{(async()=>{const{count:m}=await H.from("content_engagement_logs").select("*",{count:"exact",head:!0}).eq("resource_id",t.id).eq("action_type","click_link");i(m??0)})()},[t.id]),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(Eu,{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(Ye,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(Ye,{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})]}),l!==null&&e.jsxs("div",{className:"flex items-center gap-1 text-destructive",title:"Button clicks",children:[e.jsx($m,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-semibold",children:l})]}),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(G,{variant:"ghost",size:"icon",children:e.jsx(rn,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(Tn,{className:"h-4 w-4"}):e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})]})}const l9={open:{label:"Open",icon:mn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Uc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:wi,color:"bg-green-500"},closed:{label:"Closed",icon:Nc,color:"bg-muted-foreground"}},a7e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function C1s(){var O,q;const{user:t}=Fs(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState("all"),[m,f]=k.useState(!1),{data:g=[],isLoading:y}=pt({queryKey:["admin-support-tickets",l,c],queryFn:async()=>{let $=H.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&($=$.eq("status",l)),c!=="all"&&($=$.eq("category",c));const{data:z,error:V}=await $;if(V)throw V;return z}}),{data:_=[]}=pt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:$,error:z}=await H.from("user_roles").select("user_id").eq("role","admin");if(z)throw z;const V=$.map(ne=>ne.user_id),{data:X,error:Y}=await H.from("profiles").select("id, name, email").in("id",V);if(Y)throw Y;const{data:J,error:Q}=await H.from("support_notification_settings").select("user_id, receive_notifications");if(Q)throw Q;const ce=new Map((J==null?void 0:J.map(ne=>[ne.user_id,ne.receive_notifications]))||[]);return X.map(ne=>({...ne,receives_notifications:ce.get(ne.id)||!1}))}}),{data:w=[]}=pt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:$,error:z}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(z)throw z;return $},enabled:!!r}),j=Tt({mutationFn:async({userId:$,enabled:z})=>{const{data:V}=await H.from("support_notification_settings").select("id").eq("user_id",$).maybeSingle();if(V){const{error:X}=await H.from("support_notification_settings").update({receive_notifications:z}).eq("user_id",$);if(X)throw X}else{const{error:X}=await H.from("support_notification_settings").insert({user_id:$,receive_notifications:z});if(X)throw X}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),N=Tt({mutationFn:async({ticketId:$,status:z})=>{const{error:V}=await H.from("support_tickets").update({status:z}).eq("id",$);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=Tt({mutationFn:async({ticketId:$,assignedTo:z})=>{const{error:V}=await H.from("support_tickets").update({assigned_to:z}).eq("id",$);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),M=Tt({mutationFn:async $=>{var V,X;if(!r||!t)throw new Error("Missing data");const{error:z}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:$,is_admin_reply:!0});if(z)throw z;try{await H.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:$,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(X=r.profiles)==null?void 0:X.name}})}catch(Y){console.error("Failed to send reply notification:",Y)}},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")}}),I=()=>{a.trim()&&M.mutate(a)};k.useEffect(()=>{const $=H.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{H.removeChannel($)}},[s]);const P=g.filter($=>$.status==="open").length;return r?(l9[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(G,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Ga,{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(Ye,{variant:"secondary",children:a7e[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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm",children:"Status"})}),e.jsx(De,{children:e.jsxs(Rs,{value:r.status,onValueChange:$=>{N.mutate({ticketId:r.id,status:$}),n({...r,status:$})},children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"open",children:"Open"}),e.jsx(ft,{value:"in_progress",children:"In Progress"}),e.jsx(ft,{value:"resolved",children:"Resolved"}),e.jsx(ft,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm",children:"Assigned To"})}),e.jsx(De,{children:e.jsxs(Rs,{value:r.assigned_to||"unassigned",onValueChange:$=>{const z=$==="unassigned"?null:$;S.mutate({ticketId:r.id,assignedTo:z}),n({...r,assigned_to:z})},children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Unassigned"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"unassigned",children:"Unassigned"}),_.map($=>e.jsx(ft,{value:$.id,children:$.name},$.id))]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(vr,{children:["Created on ",ds(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(De,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Conversation"})}),e.jsxs(De,{children:[e.jsx(Li,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map($=>{var z,V;return e.jsxs("div",{className:`p-4 rounded-lg ${$.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:$.is_admin_reply?`${((z=$.profiles)==null?void 0:z.name)||"Admin"} (Support)`:((V=$.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ds(new Date($.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:$.content})]},$.id)})})}),e.jsx(Qo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Tr,{placeholder:"Type your reply...",value:a,onChange:$=>o($.target.value),className:"min-h-[80px]"}),e.jsx(G,{onClick:I,disabled:!a.trim()||M.isPending,className:"self-end",children:e.jsx(Fn,{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",P>0&&e.jsxs(Ye,{variant:"destructive",className:"ml-2",children:[P," open"]})]})]}),e.jsxs(fs,{open:m,onOpenChange:f,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",children:[e.jsx(el,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ps,{children:[e.jsxs(js,{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($=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Zi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[$.receives_notifications?e.jsx(Fm,{className:"h-4 w-4 text-primary"}):e.jsx(c1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(qr,{checked:$.receives_notifications,onCheckedChange:z=>j.mutate({userId:$.id,enabled:z})})]})]},$.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ga,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(fa,{children:[e.jsx(ss,{value:"all",children:"All"}),e.jsx(ss,{value:"open",children:"Open"}),e.jsx(ss,{value:"in_progress",children:"In Progress"}),e.jsx(ss,{value:"resolved",children:"Resolved"}),e.jsx(ss,{value:"closed",children:"Closed"})]})}),e.jsxs(Rs,{value:c,onValueChange:u,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"All Categories"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Categories"}),e.jsx(ft,{value:"general",children:"General Support"}),e.jsx(ft,{value:"technology",children:"Technology Support"}),e.jsx(ft,{value:"crm",children:"CRM Support"}),e.jsx(ft,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:y?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):g.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"text-center py-12",children:[e.jsx(Uc,{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($=>{var V,X;const z=l9[$.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n($),children:e.jsx(De,{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:$.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(Ye,{variant:"outline",className:"text-xs",children:a7e[$.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=$.profiles)==null?void 0:V.name," • ",ds(new Date($.created_at),"MMM d, yyyy")]}),$.assigned_to&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Zi,{className:"h-3 w-3"}),((X=_.find(Y=>Y.id===$.assigned_to))==null?void 0:X.name)||"Assigned"]})]})]}),e.jsxs(Ye,{className:l9[$.status].color,children:[e.jsx(z,{className:"h-3 w-3 mr-1"}),l9[$.status].label]})]})})},$.id)})})})]})]})})}const Xat=Rh.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 M1s({content:t,onChange:s,variables:r}){const n=_ke({extensions:[jke,Ike.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Lke.configure({types:["heading","paragraph"]}),Dke,Xat],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(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(tS,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(dS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(nh,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(g0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(X4,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(Q4,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(J4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Uo,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(nS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(MS,{className:"h-4 w-4"})}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(iT,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Ud,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(La,{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(vke,{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(Ye,{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 T1s(){const t=Qt(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(""),[i,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(!0),[y,_]=k.useState("visual"),{data:w,isLoading:j}=pt({queryKey:["email-templates"],queryFn:async()=>{const{data:P,error:O}=await H.from("email_templates").select("*").order("name");if(O)throw O;return P.map(q=>({...q,available_variables:q.available_variables||[]}))}}),N=Tt({mutationFn:async P=>{const{error:O}=await H.from("email_templates").update({subject:P.subject,body_html:P.body_html,description:P.description,is_active:P.is_active}).eq("id",P.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:P=>{me.error("Failed to update template: "+P.message)}}),S=P=>{r(P),l(P.subject),c(P.body_html),m(P.description||""),g(P.is_active),_("visual")},M=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(P,O)=>{let q=P;return O.forEach($=>{const z=`{{${$.key}}}`,V=`[${$.label}]`;q=q.replace(new RegExp(z.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(G,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(G,{variant:"outline",onClick:()=>a(s),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(G,{onClick:M,disabled:N.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),s.name]}),e.jsxs(vr,{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(ye,{htmlFor:"active-toggle",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:f,onCheckedChange:g})]})]})}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",value:u,onChange:P=>m(P.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"subject",children:"Email Subject"}),e.jsx(Le,{id:"subject",value:o,onChange:P=>l(P.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(ye,{children:"Email Body"}),e.jsx(ga,{value:y,onValueChange:P=>_(P),children:e.jsxs(fa,{className:"h-8",children:[e.jsxs(ss,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(vS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ss,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(nS,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),y==="visual"?e.jsx(M1s,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Tr,{value:i,onChange:P=>c(P.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(js,{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:I(i,s.available_variables)}})})]})})]}):e.jsx(Ms,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),j?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((P,O)=>e.jsx(Pe,{children:e.jsxs(Et,{children:[e.jsx(ws,{className:"h-5 w-48"}),e.jsx(ws,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(P=>e.jsxs(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Lt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(rr,{className:"h-5 w-5 text-muted-foreground"}),P.name,!P.is_active&&e.jsx(Ye,{variant:"secondary",children:"Inactive"})]}),e.jsx(vr,{children:P.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>a(P),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(G,{size:"sm",onClick:()=>S(P),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(De,{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:P.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:P.available_variables.map(O=>e.jsx(Ye,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},P.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(js,{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:I(n.body_html,n.available_variables)}})})]})})]})})}function A1s(){const t=Qt(),[s,r]=k.useState("templates"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,m]=k.useState(!1),[f,g]=k.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[y,_]=k.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=pt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:X}=await H.from("email_template_categories").select("*").order("sort_order");if(X)throw X;return V}}),{data:j=[],isLoading:N}=pt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:X}=await H.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(X)throw X;return V}}),S=Tt({mutationFn:async V=>{const X={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:Y}=await H.from("agent_email_templates").update(X).eq("id",V.id);if(Y)throw Y}else{const{error:Y}=await H.from("agent_email_templates").insert(X);if(Y)throw Y}},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=Tt({mutationFn:async V=>{const{error:X}=await H.from("agent_email_templates").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),I=Tt({mutationFn:async V=>{const X={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:Y}=await H.from("email_template_categories").update(X).eq("id",V.id);if(Y)throw Y}else{const Y=w.length>0?Math.max(...w.map(Q=>Q.sort_order))+1:0,{error:J}=await H.from("email_template_categories").insert({...X,sort_order:Y});if(J)throw J}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),m(!1),me.success(o?"Category updated":"Category created")},onError:()=>me.error("Failed to save category")}),P=Tt({mutationFn:async V=>{const{error:X}=await H.from("email_template_categories").delete().eq("id",V);if(X)throw X},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)},$=()=>{l(null),_({name:"",description:"",icon:"📧"}),m(!0)},z=V=>{l(V),_({name:V.name,description:V.description||"",icon:V.icon}),m(!0)};return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(dh,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ga,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"templates",className:"gap-2",children:[e.jsx(rr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ss,{value:"categories",className:"gap-2",children:[e.jsx(Bm,{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(G,{onClick:O,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Template"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:N?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:e.jsx(ys,{className:"h-6 w-6 animate-spin mx-auto"})})}):j.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):j.map(V=>e.jsxs(ks,{children:[e.jsx(ut,{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(ut,{className:"hidden md:table-cell",children:V.category?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:V.tone?e.jsx(Ye,{variant:"secondary",children:V.tone}):"—"}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>q(V),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&M.mutate(V.id)},children:e.jsx(kr,{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(G,{onClick:$,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(V=>e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>z(V),children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&P.mutate(V.id)},children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(De,{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:[j.filter(X=>X.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(js,{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(ye,{children:"Title"}),e.jsx(Le,{value:f.title,onChange:V=>g(X=>({...X,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Category"}),e.jsxs(Rs,{value:f.category_id,onValueChange:V=>g(X=>({...X,category_id:V})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select category"})}),e.jsx(Ds,{children:w.map(V=>e.jsxs(ft,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Subject Line"}),e.jsx(Le,{value:f.subject,onChange:V=>g(X=>({...X,subject:V.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Email Body"}),e.jsx(Tr,{value:f.body,onChange:V=>g(X=>({...X,body:V.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Description (internal)"}),e.jsx(Le,{value:f.description,onChange:V=>g(X=>({...X,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Tone"}),e.jsx(Le,{value:f.tone,onChange:V=>g(X=>({...X,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(X=>({...X,is_active:V}))}),e.jsx(ye,{children:"Active"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(G,{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(ys,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:m,children:e.jsxs(ps,{className:"sm:max-w-[450px]",children:[e.jsx(js,{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(ye,{children:"Icon"}),e.jsx(Le,{value:y.icon,onChange:V=>_(X=>({...X,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Name"}),e.jsx(Le,{value:y.name,onChange:V=>_(X=>({...X,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Description"}),e.jsx(Le,{value:y.description,onChange:V=>_(X=>({...X,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(G,{onClick:()=>I.mutate({...y,id:o==null?void 0:o.id}),disabled:I.isPending||!y.name,children:[I.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const E1s=({brokerageId:t})=>{var no,$t;const{toast:s}=Ra(),r=ar(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,m]=k.useState("all"),[f,g]=k.useState(new Set),[y,_]=k.useState(!1),[w,j]=k.useState({}),[N,S]=k.useState(!1),[M,I]=k.useState(!1),[P,O]=k.useState({email:"",name:"",password:"",phone:""}),[q,$]=k.useState(!1),[z,V]=k.useState(null),[X,Y]=k.useState(!1),[J,Q]=k.useState(!1),[ce,ne]=k.useState(!1),[re,oe]=k.useState(""),[he,xe]=k.useState(!1),[ue,ge]=k.useState([]),[_e,Be]=k.useState(!1),[Se,Ee]=k.useState(!1),[Ae,Me]=k.useState(null),[ke,Oe]=k.useState({name:"",phone:"",email:""}),[qe,ve]=k.useState(!1),[dt,pe]=k.useState(!1),[Ue,Xe]=k.useState(null),[et,Ce]=k.useState("asc"),[Je,Ge]=k.useState(!1),[lt,He]=k.useState(null),[We,tt]=k.useState(!1),[Ke,rt]=k.useState(null),[it,It]=k.useState(""),[Vt,hs]=k.useState(!1),[Es,Ts]=k.useState(null);k.useEffect(()=>{zr(),cr()},[t]);const cr=async()=>{try{const{data:je,error:$e}=await H.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if($e)throw $e;ge((je==null?void 0:je.map(st=>st.user_id))||[])}catch(je){console.error("Error loading brokerage managers:",je)}},zr=async()=>{try{l(!0);const{data:je,error:$e}=await H.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if($e)throw $e;const st=je.agents||[];if(a(st),st.length>0){const vt=st.map(Ot=>Ot.id),{data:xt}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",vt);if(xt&&xt.length>0){const Ot=xt.map(Xt=>Xt.assistant_id),{data:Zt}=await H.from("profiles").select("id, name, email").in("id",Ot),qt={};for(const Xt of xt){const Os=Zt==null?void 0:Zt.find(Ns=>Ns.id===Xt.assistant_id);Os&&(qt[Xt.agent_id]={name:Os.name||"",email:Os.email||""})}j(qt)}else j({})}}catch(je){console.error("Error loading agents:",je),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},Ft=async()=>{if(!P.email||!P.name||!P.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({...P,brokerageId:t})}),st=await $e.json();if(!$e.ok)throw new Error(st.error||"Failed to create agent");s({title:"Success",description:`Agent ${P.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),S(!1),zr()}catch(je){console.error("Error creating agent:",je),s({title:"Error",description:je.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Ps=async je=>{try{const{data:{session:$e}}=await H.auth.getSession(),st=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({userId:je})}),vt=await st.json();if(!st.ok)throw new Error(vt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch($e){console.error("Error resending welcome email:",$e),s({title:"Error",description:$e.message||"Failed to resend welcome email",variant:"destructive"})}},yr=async(je,$e)=>{try{const{error:st}=await H.functions.invoke("send-password-reset",{body:{email:je,redirectTo:window.location.origin}});if(st)throw st;s({title:"Password Reset Sent",description:`Password reset email sent to ${$e}`})}catch(st){console.error("Error sending password reset:",st),s({title:"Error",description:st.message||"Failed to send password reset email",variant:"destructive"})}},Is=je=>{V(je),$(!0)},Ar=je=>{Me(je),Oe({name:je.name,phone:je.phone||"",email:je.email}),Ee(!0)},tn=async()=>{if(!Ae)return;if(!ke.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const je=ke.email.trim().toLowerCase()!==Ae.email.toLowerCase();ve(!0);try{if(je){if(!ke.email.trim())throw new Error("Email is required");pe(!0);const{data:{session:st}}=await H.auth.getSession(),vt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${st==null?void 0:st.access_token}`},body:JSON.stringify({agentId:Ae.id,newEmail:ke.email.trim(),brokerageId:t})}),xt=await vt.json();if(pe(!1),!vt.ok)throw new Error(xt.error||"Failed to update email")}const{error:$e}=await H.from("profiles").update({name:ke.name.trim(),phone:ke.phone.trim()||null}).eq("id",Ae.id);if($e)throw $e;s({title:"Success",description:"Agent profile updated successfully"}),Ee(!1),Me(null),zr()}catch($e){console.error("Error updating agent:",$e),s({title:"Error",description:$e.message||"Failed to update agent",variant:"destructive"})}finally{ve(!1),pe(!1)}},na=async()=>{if(!re){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}xe(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({userId:re,role:"brokerage_manager",action:"add",brokerageId:t})}),st=await $e.json();if(!$e.ok)throw new Error(st.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ne(!1),oe(""),cr()}catch(je){console.error("Error adding brokerage manager:",je),s({title:"Error",description:je.message||"Failed to add brokerage manager",variant:"destructive"})}finally{xe(!1)}},Ln=async je=>{try{const{data:{session:$e}}=await H.auth.getSession(),st=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({userId:je,role:"brokerage_manager",action:"remove",brokerageId:t})}),vt=await st.json();if(!st.ok)throw new Error(vt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),cr()}catch($e){console.error("Error removing brokerage manager:",$e),s({title:"Error",description:$e.message||"Failed to remove brokerage manager",variant:"destructive"})}},tr=je=>ue.includes(je),dr=je=>{rt(je),It(""),tt(!0)},Sr=async()=>{if(!(!Ke||!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:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({agentId:Ke.id,brokerageId:t,action:"set_password",newPassword:it})}),st=await $e.json();if(!$e.ok)throw new Error(st.error||"Failed to set password");s({title:"Success",description:`Password set for ${Ke.name}`}),tt(!1),rt(null),It("")}catch(je){console.error("Error setting password:",je),s({title:"Error",description:je.message||"Failed to set password",variant:"destructive"})}finally{hs(!1)}}},dn=async je=>{Ts(je.id);try{const{data:{session:$e}}=await H.auth.getSession(),st=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e==null?void 0:$e.access_token}`},body:JSON.stringify({agentId:je.id,brokerageId:t,action:"claim_account"})}),vt=await st.json();if(!st.ok)throw new Error(vt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${je.name}`}),zr()}catch($e){console.error("Error claiming account:",$e),s({title:"Error",description:$e.message||"Failed to claim account",variant:"destructive"})}finally{Ts(null)}},Yr=async()=>{if(z){Y(!0);try{const{data:{session:je}}=await H.auth.getSession(),$e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({userId:z.id,brokerageId:t})}),st=await $e.json();if(!$e.ok)throw new Error(st.error||"Failed to remove agent");s({title:"Success",description:`${z.name} has been removed from your brokerage`}),$(!1),V(null),zr()}catch(je){console.error("Error removing agent:",je),s({title:"Error",description:je.message||"Failed to remove agent",variant:"destructive"})}finally{Y(!1)}}},ui=je=>{const $e=je.trim().split(" ");return $e.length>1?$e[$e.length-1].toLowerCase():je.toLowerCase()},ns=je=>{Ue===je?Ce(et==="asc"?"desc":"asc"):(Xe(je),Ce("asc"))},Wt=je=>Ue!==je?e.jsx(wd,{className:"ml-1 h-4 w-4"}):et==="asc"?e.jsx(Tu,{className:"ml-1 h-4 w-4"}):e.jsx(Yh,{className:"ml-1 h-4 w-4"}),Hr=n.filter(je=>{if(u==="active"&&!je.claimed||u==="pending"&&je.claimed)return!1;if(!i)return!0;const $e=i.toLowerCase();return je.name.toLowerCase().includes($e)||je.email.toLowerCase().includes($e)}),Mr=[...Hr].sort((je,$e)=>{if(!Ue)return 0;let st=0;return Ue==="name"?st=ui(je.name).localeCompare(ui($e.name)):Ue==="status"&&(st=je.claimed===$e.claimed?0:je.claimed?-1:1),et==="asc"?st:-st});Hr.filter(je=>je.claimed&&!tr(je.id));const xr=je=>{g($e=>{const st=new Set($e);return st.has(je)?st.delete(je):st.add(je),st})},Wn=()=>{f.size===Mr.length?g(new Set):g(new Set(Mr.map(je=>je.id)))},ai=()=>{g(new Set)},Aa=async()=>{const je=Array.from(f);if(je.length===0)return;_(!0);let $e=0,st=0;try{const{data:{session:vt}}=await H.auth.getSession();for(const xt of je)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vt==null?void 0:vt.access_token}`},body:JSON.stringify({userId:xt})})).ok?$e++:st++}catch{st++}$e>0?s({title:"Success",description:`Welcome emails sent to ${$e} agent${$e>1?"s":""}${st>0?` (${st} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),ai()}catch(vt){console.error("Error bulk sending welcome emails:",vt),s({title:"Error",description:vt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return o?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Agents"}),e.jsx(vr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{variant:"outline",onClick:()=>ne(!0),children:[e.jsx(ou,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(G,{variant:"outline",onClick:()=>Q(!0),children:[e.jsx(h1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(G,{onClick:()=>S(!0),children:[e.jsx(El,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(De,{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(sn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:i,onChange:je=>c(je.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:u,onValueChange:je=>m(je),children:[e.jsx(Ls,{className:"w-[160px]",children:e.jsx($s,{placeholder:"Filter by status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Agents"}),e.jsx(ft,{value:"active",children:"Active"}),e.jsx(ft,{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(G,{size:"sm",variant:"outline",onClick:()=>{const $e=n.filter(st=>f.has(st.id)&&st.email).map(st=>({email:st.email,name:st.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify($e)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:$e}})},disabled:y,children:[e.jsx(Ph,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:Aa,disabled:y,children:[e.jsx(rr,{className:"mr-2 h-4 w-4"}),y?"Sending...":"Resend Welcome Email"]}),e.jsx(G,{size:"sm",variant:"ghost",onClick:ai,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(Mo,{checked:Mr.length>0&&f.size===Mr.length,onCheckedChange:Wn,"aria-label":"Select all"})}),e.jsx(jt,{children:e.jsxs(G,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ns("name"),children:["Name (Last)",Wt("name")]})}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:e.jsxs(G,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ns("status"),children:["Status",Wt("status")]})}),e.jsx(jt,{children:"Actions"})]})}),e.jsx(qn,{children:Mr.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Mr.map(je=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx(Mo,{checked:f.has(je.id),onCheckedChange:()=>xr(je.id),"aria-label":`Select ${je.name}`})}),e.jsx(ut,{className:"font-medium",children:je.name}),e.jsx(ut,{children:je.email}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[je.claimed?e.jsx(Ye,{variant:"default",children:"Active"}):e.jsx(Ye,{variant:"secondary",children:"Pending"}),tr(je.id)&&e.jsxs(Ye,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(jS,{className:"mr-1 h-3 w-3"}),"Manager"]}),w[je.id]&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:[e.jsx(ur,{className:"mr-1 h-3 w-3"}),"Asst: ",w[je.id].name||w[je.id].email]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{He(je),Ge(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(iu,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Ar(je),title:"Edit agent",children:e.jsx(Pa,{className:"h-4 w-4"})}),!je.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Ps(je.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>dn(je),title:"Claim account for agent",disabled:Es===je.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(ew,{className:"h-4 w-4"})})]}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>dr(je),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(zd,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>yr(je.email,je.name),title:"Send password reset email",children:e.jsx(uS,{className:"h-4 w-4"})}),tr(je.id)&&e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Ln(je.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(ou,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>Is(je),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},je.id))})]})})]})]}),e.jsx(fs,{open:N,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",value:P.name,onChange:je=>O({...P,name:je.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",value:P.email,onChange:je=>O({...P,email:je.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Le,{id:"phone",type:"tel",value:P.phone,onChange:je=>O({...P,phone:je.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Le,{id:"password",type:"password",value:P.password,onChange:je=>O({...P,password:je.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(G,{onClick:Ft,disabled:M,children:M?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:q,onOpenChange:$,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Remove Agent"}),e.jsxs(Gr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:z==null?void 0:z.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:Yr,disabled:X,children:X?"Removing...":"Remove Agent"})]})]})}),e.jsx(Ett,{open:J,onOpenChange:Q,fixedBrokerageId:t,onSuccess:zr}),e.jsx(fs,{open:ce,onOpenChange:ne,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Select Agent"}),e.jsxs(Vo,{open:_e,onOpenChange:Be,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":_e,className:"w-full justify-between",children:[re?((no=n.find(je=>je.id===re))==null?void 0:no.name)+" ("+(($t=n.find(je=>je.id===re))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-full p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search by name or email..."}),e.jsxs(qx,{className:"max-h-[200px]",children:[e.jsx(Ux,{children:"No eligible agents found."}),e.jsx(Vx,{children:n.filter(je=>!tr(je.id)).map(je=>e.jsxs(_p,{value:`${je.name} ${je.email}`,onSelect:()=>{oe(je.id),Be(!1)},children:[e.jsx(ua,{className:`mr-2 h-4 w-4 ${re===je.id?"opacity-100":"opacity-0"}`}),je.name," (",je.email,")"]},je.id))})]})]})})]}),n.filter(je=>!tr(je.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(G,{onClick:na,disabled:he||!re,children:he?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Se,onOpenChange:Ee,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Edit Agent"}),e.jsxs(Gr,{children:["Update profile information for ",Ae==null?void 0:Ae.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"edit-name",children:"Name"}),e.jsx(Le,{id:"edit-name",value:ke.name,onChange:je=>Oe({...ke,name:je.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"edit-email",children:"Email"}),e.jsx(Le,{id:"edit-email",type:"email",value:ke.email,onChange:je=>Oe({...ke,email:je.target.value}),placeholder:"agent@example.com"}),ke.email.trim().toLowerCase()!==(Ae==null?void 0:Ae.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(ye,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Le,{id:"edit-phone",type:"tel",value:ke.phone,onChange:je=>Oe({...ke,phone:je.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>Ee(!1),children:"Cancel"}),e.jsx(G,{onClick:tn,disabled:qe||dt,children:dt?"Updating email...":qe?"Saving...":"Save Changes"})]})]})}),lt&&e.jsx(Ptt,{open:Je,onOpenChange:je=>{Ge(je),je||He(null)},userId:lt.id,userName:lt.name}),e.jsx(fs,{open:We,onOpenChange:tt,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Set Password"}),e.jsxs(Gr,{children:["Set a new password for ",Ke==null?void 0:Ke.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(ye,{htmlFor:"new-password",children:"New Password"}),e.jsx(Le,{id:"new-password",type:"password",value:it,onChange:je=>It(je.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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>tt(!1),children:"Cancel"}),e.jsx(G,{onClick:Sr,disabled:Vt||!it||it.length<6,children:Vt?"Setting...":"Set Password"})]})]})})]})},P1s={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},I1s={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},L1s=t=>{switch(t){case"academy_video":return e.jsx(An,{className:"h-4 w-4"});case"template":return e.jsx(wn,{className:"h-4 w-4"});case"toolbox":return e.jsx(wn,{className:"h-4 w-4"});case"newsletter":return e.jsx(x1,{className:"h-4 w-4"});case"social_swag":return e.jsx(nn,{className:"h-4 w-4"});case"event":return e.jsx(fn,{className:"h-4 w-4"});default:return e.jsx(rn,{className:"h-4 w-4"})}},D1s=({brokerageId:t})=>{const{toast:s}=Ra(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState([]),[c,u]=k.useState(!0),[m,f]=k.useState(null);k.useEffect(()=>{g()},[t]);const g=async()=>{try{u(!0);const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("brokerage_id",t);if(j)throw j;const N=w.map(X=>X.id),S=new Map(w.map(X=>[X.id,X]));if(N.length===0){n([]),o([]),i([]);return}const{data:M,error:I}=await H.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const P=M.map(X=>{var Y,J;return{id:X.id,user_id:X.user_id,app_name:X.app_name,launched_at:X.launched_at,user_name:((Y=S.get(X.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=S.get(X.user_id))==null?void 0:J.email)||"Unknown"}});n(P);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 $=(O||[]).map(X=>{var Y,J;return{id:X.id,user_id:X.user_id,resource_type:X.resource_type,resource_id:X.resource_id,resource_title:X.resource_title,action_type:X.action_type,created_at:X.created_at,user_name:((Y=S.get(X.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=S.get(X.user_id))==null?void 0:J.email)||"Unknown"}});o($);const z=new Map;w.forEach(X=>{z.set(X.id,{user_id:X.id,user_name:X.name,user_email:X.email,app_launches:0,content_views:0,last_activity:""})}),P.forEach(X=>{const Y=z.get(X.user_id);Y&&(Y.app_launches++,(!Y.last_activity||new Date(X.launched_at)>new Date(Y.last_activity))&&(Y.last_activity=X.launched_at))}),$.forEach(X=>{const Y=z.get(X.user_id);Y&&(Y.content_views++,(!Y.last_activity||new Date(X.created_at)>new Date(Y.last_activity))&&(Y.last_activity=X.created_at))});const V=Array.from(z.values()).filter(X=>X.app_launches>0||X.content_views>0).sort((X,Y)=>new Date(Y.last_activity).getTime()-new Date(X.last_activity).getTime());i(V)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},y=w=>r.filter(j=>j.user_id===w),_=w=>a.filter(j=>j.user_id===w);return c?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Agent Activity"}),e.jsx(vr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(De,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"App Launches"}),e.jsx(jt,{className:"text-center",children:"Content Views"}),e.jsx(jt,{children:"Last Active"})]})}),e.jsx(qn,{children:l.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(sl,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(wn,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:w.last_activity&&ql(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(fs,{open:!!m,onOpenChange:w=>!w&&f(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(vs,{children:[m==null?void 0:m.name,"'s Activity"]}),e.jsx(Gr,{children:m==null?void 0:m.email})]}),e.jsxs(ga,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsx(ss,{value:"content",children:"Content Engagement"}),e.jsx(ss,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Resource"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(qn,{children:m&&_(m.id).length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):m&&_(m.id).map(w=>e.jsxs(ks,{children:[e.jsx(ut,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(ut,{children:e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[L1s(w.resource_type),P1s[w.resource_type]||w.resource_type]})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:I1s[w.action_type]||w.action_type})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ql(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx(bs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"App"}),e.jsx(jt,{children:"Time"})]})}),e.jsx(qn,{children:m&&y(m.id).length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):m&&y(m.id).map(w=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx(Ye,{variant:"outline",children:w.app_name})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ql(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},O1s=({brokerageId:t})=>{const{toast:s}=Ra(),[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(P=>P.id),m=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:y}=await H.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),_=y||0,w=m-_,{count:j}=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:I}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",M.toISOString());n({totalAgents:m,activeAgents:_,pendingAgents:w,totalLaunches:j||0,launchesThisWeek:S||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(ur,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(wi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(De,{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"})]})]})]})},R1s=({brokerageId:t})=>{const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=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(),y=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),m({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")}},w=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(I=>I.id===N?{...I,is_active:!S}:I)),me.success(`Invite link ${S?"deactivated":"activated"}`)}catch(M){console.error("Error toggling invite code:",M),me.error("Failed to update invite link")}},j=N=>{const S=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")};return n?e.jsx(Pe,{children:e.jsx(De,{className:"flex items-center justify-center py-8",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(vr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Le,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>m({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Le,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>m({...u,maxUses:N.target.value})})]}),e.jsx(G,{onClick:y,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(De,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Uo,{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(Ye,{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(G,{variant:"ghost",size:"sm",onClick:()=>j(N.code),title:"Copy link",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>w(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>_(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(kr,{className:"h-4 w-4"})})]})]},N.id))})})]})},F1s=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=k.useState(""),[u,m]=k.useState([]),[f,g]=k.useState(""),[y,_]=k.useState(!1),w=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),j=()=>{const I=i.trim().toLowerCase();if(I&&w(I)&&!u.includes(I)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}m([...u,I]),c("")}else I&&!w(I)?me.error("Please enter a valid email address"):u.includes(I)&&me.error("Email already added")},N=I=>{m(u.filter(P=>P!==I))},S=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),j())},M=async()=>{if(u.length===0){me.error("Please add at least one email address");return}_(!0);try{const{data:I,error:P}=await H.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(P)throw P;I.successCount===I.totalCount?me.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):me.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),m([]),g(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rr,{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(bo,{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(ye,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>c(I.target.value),onKeyDown:S,onBlur:j}),e.jsx(G,{type:"button",variant:"secondary",onClick:j,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(Ye,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>N(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Er,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Tr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>g(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(nn,{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(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:M,disabled:u.length===0||y,children:y?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(Fn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},z1s=({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(Ye,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(wi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(Ye,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Nc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{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(rr,{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 ",ds(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},B1s=()=>{const{brokerageId:t,user:s}=Fs(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState([]),[m,f]=k.useState(!0),[g,y]=k.useState(!1),[_,w]=k.useState(0);k.useEffect(()=>{t&&j()},[t]);const j=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:$}=await H.from("referral_codes").select("code").eq("brokerage_id",t).single();if($)n($.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:z}=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(z||[])}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,I=S*25,P=Math.max(0,Math.ceil((299-I)/25));return m?null:e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(bo,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",I]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),I>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(wi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),P>0&&I<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",P," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),I>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(nn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(De,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(G,{onClick:()=>y(!0),className:"w-full",size:"lg",children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(G,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(yi,{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(ml,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",I]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(ur,{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(mn,{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(z1s,{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,$;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)||(($=O.referred_user)==null?void 0:$.email)||"Pending setup"}),e.jsxs(Ye,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(wi,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(F1s,{open:g,onOpenChange:y,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(O=>O+1)})]})},$1s=({brokerageId:t})=>{const s=ar(),{teams:r,isLoading:n}=L3(t),{data:a,isLoading:o}=pt({queryKey:["team-aggregate-stats",t,r.map(m=>m.id)],queryFn:async()=>{if(r.length===0)return[];const m=r.map(O=>O.id),{data:f}=await H.from("team_members").select("team_id, user_id, role").in("team_id",m);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),y=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:_}=await H.from("profiles").select("id, name, avatar_url").in("id",y),w=new Map((_||[]).map(O=>[O.id,O])),{data:j}=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;(j||[]).forEach(O=>{M.set(O.owner_user_id,(M.get(O.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)});const P=new Map;return(S||[]).forEach(O=>{P.set(O.owner_user_id,(P.get(O.owner_user_id)||0)+1)}),r.map(O=>{const q=f.filter(Q=>Q.team_id===O.id),$=q.find(Q=>Q.role==="team_leader"),z=$?w.get($.user_id):null,V=q.map(Q=>Q.user_id),X=V.reduce((Q,ce)=>Q+(M.get(ce)||0),0),Y=V.reduce((Q,ce)=>Q+(I.get(ce)||0),0),J=V.reduce((Q,ce)=>Q+(P.get(ce)||0),0);return{team_id:O.id,team_name:O.name,member_count:q.length,leader_name:(z==null?void 0:z.name)||null,leader_avatar:(z==null?void 0:z.avatar_url)||null,total_contacts:X,total_deals:Y,total_videos:J}})},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(m=>e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(ws,{className:"h-5 w-32"})}),e.jsx(De,{children:e.jsx(ws,{className:"h-24 w-full"})})]},m))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ur,{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(G,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((m,f)=>m+f.member_count,0),c=(a||[]).reduce((m,f)=>m+f.total_contacts,0),u=(a||[]).reduce((m,f)=>m+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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ur,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ur,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(iS,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(sh,{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(m=>e.jsxs(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Lt,{className:"text-lg",children:m.team_name}),e.jsxs(Ye,{variant:"secondary",children:[m.member_count," members"]})]}),m.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:m.leader_avatar||""}),e.jsx(Mn,{className:"text-xs",children:m.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(zm,{className:"h-3 w-3 text-amber-500"}),m.leader_name]})]})]}),e.jsx(De,{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:m.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:m.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:m.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},m.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(G,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},q1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Fs(),i=ar(),{toast:c}=Ra(),[u,m]=k.useState(""),[f,g]=k.useState(!0),y=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),y?_():a.length===0&&!r&&g(!1)},[t,s,n,y,i,a,o]);const _=async()=>{if(!y){g(!1);return}try{const{data:w,error:j}=await H.from("brokerages").select("name").eq("id",y).single();if(j)throw j;m(w.name)}catch(w){console.error("Error loading brokerage info:",w),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"})})}):y?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(Rs,{value:o||"",onValueChange:l,children:[e.jsxs(Ls,{className:"w-[280px]",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),e.jsx($s,{placeholder:"Select brokerage"})]}),e.jsx(Ds,{children:a.map(w=>e.jsx(ft,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(ga,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ss,{value:"agents",children:"Agents"}),e.jsx(ss,{value:"teams",children:"Teams"}),e.jsx(ss,{value:"invite",children:"Invite Links"}),e.jsx(ss,{value:"referrals",children:"Referrals"}),e.jsx(ss,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ss,{value:"activity",children:"Activity"}),e.jsx(ss,{value:"analytics",children:"Analytics"}),e.jsx(ss,{value:"shares",children:"Shares"})]}),e.jsx(bs,{value:"agents",className:"space-y-4",children:e.jsx(E1s,{brokerageId:y})}),e.jsx(bs,{value:"teams",className:"space-y-4",children:e.jsx($1s,{brokerageId:y})}),e.jsx(bs,{value:"invite",className:"space-y-4",children:e.jsx(R1s,{brokerageId:y})}),e.jsx(bs,{value:"referrals",className:"space-y-4",children:e.jsx(B1s,{})}),e.jsx(bs,{value:"leaderboard",className:"space-y-4",children:e.jsx(Yet,{brokerageId:y,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(bs,{value:"activity",className:"space-y-4",children:e.jsx(D1s,{brokerageId:y})}),e.jsx(bs,{value:"analytics",className:"space-y-4",children:e.jsx(O1s,{brokerageId:y})}),e.jsx(bs,{value:"shares",className:"space-y-4",children:e.jsx(ost,{brokerageOnly:!0,brokerageId:y})})]})]})}):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(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You don't have any brokerages to manage."})]})})};function U1s({brokerageId:t,canManage:s}){const{user:r}=Fs(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(!1),[u,m]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(!1),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState(!1),P=async()=>{try{const{data:V,error:X}=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(X)throw X;const Y=V;if(Y&&Y.length>0){const J=[...new Set(Y.map(re=>re.created_by))],{data:Q}=await H.from("profiles").select("id, name, avatar_url").in("id",J),ce=new Map((Q==null?void 0:Q.map(re=>[re.id,re]))||[]),ne=Y.map(re=>({...re,author:ce.get(re.created_by)||{name:"Unknown",avatar_url:null}}));a(ne)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};k.useEffect(()=>{P()},[t]);const O=()=>{j(""),S(""),I(!1),m(null)},q=V=>{V?(m(V),j(V.title),S(V.content),I(V.is_pinned)):O(),c(!0)},$=async()=>{if(!w.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:w.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:w.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(),P()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{_(!1)}},z=async()=>{if(f)try{const{error:V}=await H.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;me.success("Announcement deleted"),P()}catch(V){console.error("Error deleting announcement:",V),me.error("Failed to delete announcement")}finally{g(null)}};return o?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Ph,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Ph,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(G,{size:"sm",onClick:()=>q(),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(De,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(V=>{var X,Y,J,Q;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(J_,{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(Cn,{className:"h-5 w-5",children:[e.jsx(Wa,{src:((X=V.author)==null?void 0:X.avatar_url)||void 0}),e.jsx(Mn,{className:"text-[10px]",children:((J=(Y=V.author)==null?void 0:Y.name)==null?void 0:J.charAt(0))||"?"})]}),e.jsx("span",{children:(Q=V.author)==null?void 0:Q.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ds(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>q(V),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>g(V.id),children:e.jsx(kr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{htmlFor:"title",children:"Title"}),e.jsx(Le,{id:"title",value:w,onChange:V=>j(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"content",children:"Content"}),e.jsx(Tr,{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:I}),e.jsxs(ye,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(J_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(G,{onClick:$,disabled:y,children:y?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(Tc,{open:!!f,onOpenChange:()=>g(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Announcement"}),e.jsx(lc,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function V1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=Gde(),{user:a}=Fs(),[o,l]=k.useState([]),[i,c]=k.useState(!0),[u,m]=k.useState(""),[f,g]=k.useState(new Set);k.useEffect(()=>{(async()=>{try{const{data:w,error:j}=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(j)throw j;if(l(w||[]),w&&w.length>0){const N=w.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(w){console.error("Error fetching agents:",w)}finally{c(!1)}})()},[t]);const y=o.filter(_=>{var w,j;return _.name.toLowerCase().includes(u.toLowerCase())||_.email.toLowerCase().includes(u.toLowerCase())||((w=_.title)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=_.areas_served)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:u,onChange:_=>m(_.target.value),className:"pl-9"})]})]}),e.jsx(De,{children:y.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:y.map(_=>e.jsx(H1s,{agent:_,hasAssistant:f.has(_.id),canImpersonate:s&&_.id!==(a==null?void 0:a.id),onImpersonate:()=>r(_.id,"/my-brokerage"),impersonationLoading:n},_.id))})})]})}function H1s({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(Cn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Wa,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(Mn,{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(Ye,{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(aa,{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(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{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(pS,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(G,{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(Nn,{className:"h-4 w-4"})})}),e.jsx(G,{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(rr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(G,{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(Ap,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(G,{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(Pu,{className:"h-4 w-4"})})})]})]})}function G1s({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 m=c.map(w=>w.id),{data:f,error:g}=await H.from("agent_attendance_stats").select("user_id, total_points").in("user_id",m).order("total_points",{ascending:!1});if(g)throw g;const y=new Map(c.map(w=>[w.id,w])),_=(f||[]).filter(w=>w.total_points>0).map(w=>{const j=y.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(j==null?void 0:j.name)||"Unknown",avatar_url:(j==null?void 0:j.avatar_url)||null}});r(_)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(De,{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(f1,{className:Pt("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(De,{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),m=c+1;return e.jsxs("div",{className:Pt("flex items-center gap-3 p-2 rounded-lg",m<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(m)}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:i.avatar_url||void 0}),e.jsx(Mn,{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 W1s({brokerageId:t}){const s=ar(),[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 m=c.map(w=>w.id),f=new Map(c.map(w=>[w.id,w])),{data:g,error:y}=await H.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",m).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(y)throw y;const _=(g||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:f.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(_)}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(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(De,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(xn,{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(G,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(qs,{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(xn,{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(G,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(rn,{className:"h-3 w-3 ml-1"})]})]})]})}function K1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Fs(),n=ar(),[a,o]=k.useState(!0),[l,i]=k.useState(null),[c,u]=k.useState(""),[m,f]=k.useState(0),[g,y]=k.useState(!1),[_,w]=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)y(!0),w(!0);else if(r){const{data:I}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();y(!!I),w(!!I)}}catch(N){console.error("Error fetching brokerage info:",N)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ms,{title:"My Brokerage",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?e.jsx(Ms,{title: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(ur,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[m," ",m===1?"Agent":"Agents"]})]}),_&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Ah,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(G,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(xn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(U1s,{brokerageId:l,canManage:g}),e.jsx(V1s,{brokerageId:l,canManage:g}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(G1s,{brokerageId:l}),e.jsx(W1s,{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(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}function Z1s(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 Y1s(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 i7e={video:{icon:sl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:wn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:pl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:fn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:$l,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function Q1s({item:t,canManage:s}){const[r,n]=k.useState(!1),[a,o]=k.useState(null),l=c8t(),i=ar(),c=i7e[t.content_type]||i7e.link,u=c.icon,m=k.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?Z1s(t.url):null,[t]);k.useEffect(()=>{m||!t.url||t.content_type!=="video"||!Y1s(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,m]);const f=m||a,g=()=>{i(`/brokerage-content/${t.id}`)},y=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(Pe,{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(De,{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(Ye,{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(Ye,{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:["📅 ",ds(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ds(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,onClick:_=>_.stopPropagation(),children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(vx,{className:"h-4 w-4"})})}),e.jsx(Ud,{align:"end",children:e.jsxs(La,{onClick:_=>{_.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(Tc,{open:r,onOpenChange:n,children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Content"}),e.jsxs(lc,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:y,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function X1s(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 o7e=[{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 J1s({brokerageId:t,categories:s}){var ge;const{user:r}=Fs(),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,m]=k.useState("📁"),[f,g]=k.useState(!1);k.useRef(null);const[y,_]=k.useState("video"),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState(""),[P,O]=k.useState(""),[q,$]=k.useState(""),[z,V]=k.useState(""),[X,Y]=k.useState(""),J=l8t(),Q=d8t(t),ce=u8t(),ne=h8t(t),re=()=>{_("video"),j(""),S(""),I(""),O(""),$(""),V(""),Y("")},oe=async(_e,Be)=>{var Ee;const Se=(Ee=_e.target.files)==null?void 0:Ee[0];if(Se){g(!0);try{const Ae=Se.name.split(".").pop(),Me=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Ae}`,{error:ke}=await H.storage.from("brokerage-content").upload(Me,Se);if(ke)throw ke;const{data:{publicUrl:Oe}}=H.storage.from("brokerage-content").getPublicUrl(Me);Be==="file"?(O(Oe),y==="graphic"&&!q&&$(Oe)):$(Oe),me.success("File uploaded")}catch(Ae){me.error(Ae.message||"Upload failed")}finally{g(!1)}}},he=async()=>{if(!w.trim()){me.error("Title is required");return}if(r)try{await J.mutateAsync({brokerage_id:t,category_id:X||null,content_type:y,title:w.trim(),description:N.trim()||null,url:M.trim()||null,file_url:P.trim()||null,thumbnail_url:q.trim()||null,event_date:z?new Date(z).toISOString():null,created_by:r.id}),me.success("Content added!"),re(),a(!1)}catch(_e){me.error(_e.message||"Failed to add content")}},xe=async()=>{if(i.trim())try{await Q.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),m("📁"),me.success("Category created")}catch(_e){me.error(_e.message||"Failed to create category")}},ue=async()=>{try{await ne.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(Oi,{asChild:!0,children:e.jsxs(G,{children:[e.jsx(qs,{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(js,{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(ye,{children:"Content Type"}),e.jsxs(Rs,{value:y,onValueChange:_,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:o7e.map(_e=>e.jsx(ft,{value:_e.value,children:_e.label},_e.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(ge=o7e.find(_e=>_e.value===y))==null?void 0:ge.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Category"}),e.jsxs(Rs,{value:X,onValueChange:Y,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select category (optional)"})}),e.jsx(Ds,{children:s.map(_e=>e.jsxs(ft,{value:_e.id,children:[_e.icon," ",_e.name]},_e.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Title *"}),e.jsx(Le,{value:w,onChange:_e=>j(_e.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:N,onChange:_e=>S(_e.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(y)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:y==="video"?"Video URL":y==="graphic"?"Canva / Image URL":y==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Le,{value:M,onChange:_e=>{const Be=_e.target.value;if(I(Be),y==="video"&&!q){const Se=X1s(Be);Se&&$(Se)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(y)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:y==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"file",accept:y==="pdf"?".pdf,.doc,.docx":"image/*",onChange:_e=>oe(_e,"file"),disabled:f}),f&&e.jsx(ys,{className:"h-4 w-4 animate-spin"})]}),P&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Thumbnail Image (optional)"}),e.jsx(Le,{type:"file",accept:"image/*",onChange:_e=>oe(_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:()=>$(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Er,{className:"h-3 w-3"})})]})]}),y==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Event Date & Time"}),e.jsx(Le,{type:"datetime-local",value:z,onChange:_e=>V(_e.target.value)})]}),e.jsxs(G,{onClick:he,disabled:J.isPending||!w.trim(),className:"w-full",children:[J.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",children:[e.jsx(el,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{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(G,{variant:"outline",size:"sm",onClick:ue,disabled:ne.isPending,children:[ne.isPending?e.jsx(ys,{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(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(_e.id),me.success("Category deleted")},children:e.jsx(Er,{className:"h-4 w-4"})})]},_e.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Le,{value:u,onChange:_e=>m(_e.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Le,{value:i,onChange:_e=>c(_e.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:_e=>_e.key==="Enter"&&xe()}),e.jsx(G,{size:"sm",onClick:xe,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function ebs(){const{user:t,isAdmin:s,isBrokerageManager:r}=Fs(),[n,a]=k.useState(!0),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,m]=k.useState(!1),[f,g]=k.useState(null),[y,_]=k.useState("");k.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:P}=await H.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(P&&c(P.name),s)m(!0);else if(r){const{data:O}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();m(!!O)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:w=[]}=a8t(o),{data:j=[],isLoading:N}=i8t(o,f),S=k.useMemo(()=>{if(!y.trim())return j;const M=y.toLowerCase();return j.filter(I=>{var P;return I.title.toLowerCase().includes(M)||((P=I.description)==null?void 0:P.toLowerCase().includes(M))||I.content_type.toLowerCase().includes(M)})},[j,y]);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(J1s,{brokerageId:o,categories:w}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search content...",value:y,onChange:M=>_(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(G,{variant:f===null?"default":"outline",size:"sm",onClick:()=>g(null),children:"All"}),w.map(M=>e.jsxs(G,{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(Pe,{className:"bg-muted/30 border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Bm,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:y.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:y.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(Q1s,{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(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}const l7e={video:{icon:sl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:wn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:pl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:fn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:$l,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function tbs(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 sbs(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function rbs(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function nbs(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function abs(){const{contentId:t}=ao(),{data:s,isLoading:r}=pt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:m}=await H.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(m)throw m;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(Ta,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Content not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This content may have been removed."}),e.jsx(G,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=l7e[s.content_type]||l7e.link,a=n.icon,o=s.url||s.file_url,l=o&&sbs(o)?tbs(o):null,i=o&&rbs(o)?nbs(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(G,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(la,{to:"/brokerage-content",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ye,{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(Ye,{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 ",ds(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Pe,{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(Pe,{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(Pe,{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(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsxs(De,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(fn,{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:ds(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(G,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(G,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),c?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function ibs(){const t=ar(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o,isLoading:l}=pt({queryKey:["newsletters"],queryFn:async()=>{const{data:M,error:I}=await H.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return M}}),{data:i}=pt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_likes").select("newsletter_id");return M||[]}}),{data:c}=pt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_comments").select("newsletter_id");return M||[]}}),{data:u}=pt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[M,I,P,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:I.data||[],videos:P.data||[],drives:O.data||[]}}}),m=M=>(i==null?void 0:i.filter(I=>I.newsletter_id===M).length)||0,f=M=>(c==null?void 0:c.filter(I=>I.newsletter_id===M).length)||0,g=M=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(P=>P.newsletter_id===M).length)||0},y=M=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(P=>P.newsletter_id===M).length)||0},_=M=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(P=>P.newsletter_id===M).length)||0},w=M=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(P=>P.newsletter_id===M).length)||0},j=M=>g(M)+y(M)+_(M)+w(M),N=o==null?void 0:o.filter(M=>{var I;return M.title.toLowerCase().includes(s.toLowerCase())||((I=M.description)==null?void 0:I.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(G,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Tp,{className:"h-4 w-4"})}),e.jsx(G,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(nh,{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,I)=>e.jsx(Pe,{children:e.jsxs(De,{className:"p-0",children:[e.jsx(ws,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(ws,{className:"h-5 w-3/4"}),e.jsx(ws,{className:"h-4 w-full"})]})]})},I))}),!l&&(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(wn,{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(G,{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 I=j(M.id),P=g(M.id),O=y(M.id),q=_(M.id);return n==="grid"?e.jsxs(Pe,{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(wn,{className:"h-16 w-16"})})}),e.jsxs(De,{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(fn,{className:"h-3 w-3"}),ds(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,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[P>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx($l,{className:"h-3 w-3"})," ",P," Template",P>1?"s":""]}),O>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(vi,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),q>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(sl,{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(ah,{className:"h-3 w-3"})," ",m(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]},M.id):e.jsx(Pe,{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(wn,{className:"h-10 w-10"})})}),e.jsxs(De,{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(fn,{className:"h-3 w-3"}),ds(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:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ah,{className:"h-3 w-3"})," ",m(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]})},M.id)})})]})})}function obs({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(Pe,{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(De,{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 lbs(){const{id:t}=ao(),s=ar(),{user:r}=Fs(),{toast:n}=Ra(),a=Qt(),{trackEngagement:o}=bE(),[l,i]=k.useState(""),{data:c,isLoading:u}=pt({queryKey:["newsletter",t],queryFn:async()=>{const{data:P,error:O}=await H.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return P},enabled:!!t});k.useEffect(()=>{c&&o("newsletter",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:m}=pt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:f}=pt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:g}=pt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:y}=pt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:_}=pt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_likes").select("*").eq("newsletter_id",t);return P||[]},enabled:!!t}),{data:w}=pt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return P||[]},enabled:!!t}),j=_==null?void 0:_.some(P=>P.user_id===(r==null?void 0:r.id)),N=Tt({mutationFn:async()=>{j?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=Tt({mutationFn:async P=>{const{error:O}=await H.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:P});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),M=Tt({mutationFn:async P=>{const{error:O}=await H.from("newsletter_comments").delete().eq("id",P);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=P=>{if(P.includes("player.mediadelivery.net")||P.includes("iframe.mediadelivery.net")){const O=P.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(P.includes("youtube.com")||P.includes("youtu.be")){const O=P.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:P,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(sl,{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(ws,{className:"h-8 w-32"}),e.jsx(ws,{className:"h-64 w-full"}),e.jsx(ws,{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(G,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Ga,{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:ds(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(obs,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(kE,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(G,{variant:j?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(Ja,{className:`h-4 w-4 mr-1 ${j?"fill-current":""}`}),(_==null?void 0:_.length)||0," ",(_==null?void 0:_.length)===1?"Like":"Likes"]})]}),y&&y.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(De,{className:"space-y-2",children:y.map(P=>e.jsxs("a",{href:P.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($l,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:P.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},P.id))})]}),m&&m.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(De,{className:"space-y-2",children:m.map(P=>e.jsxs("a",{href:P.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(rn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:P.title})]},P.id))})]}),f&&f.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(De,{className:"space-y-2",children:f.map(P=>e.jsxs("a",{href:P.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(wn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:P.name}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]},P.id))})]}),g&&g.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Videos"})}),e.jsx(De,{className:"space-y-6",children:g.map(P=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:P.title}),I(P.video_url)]},P.id))})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Tr,{placeholder:"Write a comment...",value:l,onChange:P=>i(P.target.value),className:"flex-1"}),e.jsx(G,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(Fn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(P=>{var O,q,$;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{children:((q=(O=P.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:(($=P.profiles)==null?void 0:$.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ds(new Date(P.created_at),"MMM d, yyyy")}),P.user_id===(r==null?void 0:r.id)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>M.mutate(P.id),children:e.jsx(kr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:P.content})]})]},P.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(G,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function cbs({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((m,f)=>f!==u))},l=(u,m,f,g)=>{const y=[...t];y[u]={...y[u],columns:y[u].columns.map((_,w)=>w===m?{..._,[f]:g}:_)},s(y)},i=async(u,m,f)=>{var _;const g=(_=f.target.files)==null?void 0:_[0];if(!g)return;const y=`${u}-${m}`;n(y);try{const w=`content-blocks/${Date.now()}-${g.name}`,{error:j}=await H.storage.from("newsletter-content").upload(w,g);if(!j){const{data:N}=H.storage.from("newsletter-content").getPublicUrl(w);l(u,m,"image_url",N.publicUrl)}}finally{n(null)}},c=(u,m)=>{l(u,m,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(qs,{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,m)=>e.jsxs(Pe,{className:"relative",children:[e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(m),children:e.jsx(Er,{className:"h-4 w-4"})}),e.jsxs(De,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Eu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",m+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,g)=>{const y=`${m}-${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(G,{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(m,g),children:e.jsx(Er,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Le,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${y}`,onChange:_=>i(m,g,_)}),e.jsx(G,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===y,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${y}`,className:"cursor-pointer",children:r===y?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(bl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Le,{placeholder:"Title",value:f.title,onChange:_=>l(m,g,"title",_.target.value),className:"h-8 text-sm"}),e.jsx(Tr,{placeholder:"Description",value:f.description,onChange:_=>l(m,g,"description",_.target.value),className:"text-sm min-h-[60px] resize-none"})]},g)})})]})]},m))]})}function dbs(){const{toast:t}=Ra(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState({title:"",description:"",publish_date:ds(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=k.useState(null),[m,f]=k.useState(null),[g,y]=k.useState([]),[_,w]=k.useState([]),[j,N]=k.useState([]),[S,M]=k.useState([]),[I,P]=k.useState([]),[O,q]=k.useState([]),[$,z]=k.useState(!1),{data:V,isLoading:X}=pt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Se,error:Ee}=await H.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ee)throw Ee;return Se}}),Y=Tt({mutationFn:async Se=>{const{data:Ee,error:Ae}=await H.from("newsletter_content").insert({title:Se.title,description:Se.description||null,preview_image_url:Se.preview_image_url,publish_date:Se.publish_date,is_published:Se.is_published,content_blocks:Se.content_blocks}).select().single();if(Ae)throw Ae;return Ee},onSuccess:async Se=>{await ce(Se.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Se.is_published&&WVt(Se.title,Se.id),oe()},onError:Se=>{t({title:"Error creating newsletter",description:Se.message,variant:"destructive"})}}),J=Tt({mutationFn:async Se=>{const{error:Ee}=await H.from("newsletter_content").update({title:Se.title,description:Se.description||null,preview_image_url:Se.preview_image_url,publish_date:Se.publish_date,is_published:Se.is_published,content_blocks:Se.content_blocks}).eq("id",Se.id);if(Ee)throw Ee;return Se.id},onSuccess:async Se=>{await ce(Se),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),oe()},onError:Se=>{t({title:"Error updating newsletter",description:Se.message,variant:"destructive"})}}),Q=Tt({mutationFn:async Se=>{const{error:Ee}=await H.from("newsletter_content").delete().eq("id",Se);if(Ee)throw Ee},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Se=>{t({title:"Error deleting newsletter",description:Se.message,variant:"destructive"})}}),ce=async Se=>{await H.from("newsletter_drive_links").delete().eq("newsletter_id",Se),await H.from("newsletter_pdfs").delete().eq("newsletter_id",Se),await H.from("newsletter_videos").delete().eq("newsletter_id",Se),await H.from("newsletter_canva_links").delete().eq("newsletter_id",Se);for(const Ee of O){const Ae=`${Se}/${Date.now()}-${Ee.file.name}`,{error:Me}=await H.storage.from("newsletter-content").upload(Ae,Ee.file);if(!Me){const{data:ke}=H.storage.from("newsletter-content").getPublicUrl(Ae);_.push({name:Ee.name,file_url:ke.publicUrl,file_size:Ee.file.size,sort_order:_.length})}}g.length>0&&await H.from("newsletter_drive_links").insert(g.map((Ee,Ae)=>({newsletter_id:Se,title:Ee.title,drive_url:Ee.drive_url,sort_order:Ae}))),_.length>0&&await H.from("newsletter_pdfs").insert(_.map((Ee,Ae)=>({newsletter_id:Se,name:Ee.name,file_url:Ee.file_url,file_size:Ee.file_size||null,sort_order:Ae}))),j.length>0&&await H.from("newsletter_videos").insert(j.map((Ee,Ae)=>({newsletter_id:Se,title:Ee.title,video_url:Ee.video_url,sort_order:Ae}))),S.length>0&&await H.from("newsletter_canva_links").insert(S.map((Ee,Ae)=>({newsletter_id:Se,title:Ee.title,canva_share_link:Ee.canva_share_link,sort_order:Ae})))},ne=async Se=>{o(Se),i({title:Se.title,description:Se.description||"",publish_date:ds(new Date(Se.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Se.is_published}),f(Se.preview_image_url),P(Se.content_blocks||[]);const[Ee,Ae,Me,ke]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Se.id).order("sort_order")]);y(Ee.data||[]),w(Ae.data||[]),N(Me.data||[]),M(ke.data||[]),q([]),n(!0)},re=async Se=>{const[Ee,Ae,Me,ke]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Se.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Se.id).order("sort_order")]);o(null),i({title:`${Se.title} (Copy)`,description:Se.description||"",publish_date:ds(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Se.preview_image_url),P(Se.content_blocks||[]),y((Ee.data||[]).map(({id:Oe,...qe})=>qe)),w((Ae.data||[]).map(({id:Oe,...qe})=>qe)),N((Me.data||[]).map(({id:Oe,...qe})=>qe)),M((ke.data||[]).map(({id:Oe,...qe})=>qe)),q([]),n(!0)},oe=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ds(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),y([]),w([]),N([]),M([]),P([]),q([])},he=async Se=>{var Ae;const Ee=(Ae=Se.target.files)==null?void 0:Ae[0];Ee&&(u(Ee),f(URL.createObjectURL(Ee)))},xe=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}z(!0);let Se=m;if(c){const Ee=`previews/${Date.now()}-${c.name}`,{error:Ae}=await H.storage.from("newsletter-content").upload(Ee,c);if(!Ae){const{data:Me}=H.storage.from("newsletter-content").getPublicUrl(Ee);Se=Me.publicUrl}}a?J.mutate({id:a.id,...l,preview_image_url:Se,content_blocks:I}):Y.mutate({...l,preview_image_url:Se,content_blocks:I}),z(!1)},ue=()=>y([...g,{title:"",drive_url:"",sort_order:g.length}]),ge=()=>N([...j,{title:"",video_url:"",sort_order:j.length}]),_e=()=>M([...S,{title:"",canva_share_link:"",sort_order:S.length}]),Be=Se=>{const Ee=Se.target.files;if(!Ee)return;const Ae=Array.from(Ee).map(Me=>({file:Me,name:Me.name.replace(/\.[^/.]+$/,"")}));q([...O,...Ae])};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(dh,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Se=>Se.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Se=>!Se&&oe(),children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{onClick:()=>n(!0),children:[e.jsx(qs,{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(js,{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(ye,{children:"Title *"}),e.jsx(Le,{value:l.title,onChange:Se=>i({...l,title:Se.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Publish Date"}),e.jsx(Le,{type:"datetime-local",value:l.publish_date,onChange:Se=>i({...l,publish_date:Se.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:l.description,onChange:Se=>i({...l,description:Se}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[m&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:m,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(G,{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(Er,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Le,{type:"file",accept:"image/*",onChange:he,className:"hidden",id:"preview-upload"}),e.jsx(G,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(ci,{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:Se=>i({...l,is_published:Se})}),e.jsx(ye,{children:"Published"})]}),e.jsx(cbs,{rows:I,onChange:P}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Se,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Link title",value:Se.title,onChange:Ae=>{const Me=[...S];Me[Ee].title=Ae.target.value,M(Me)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Canva share link",value:Se.canva_share_link,onChange:Ae=>{const Me=[...S];Me[Ee].canva_share_link=Ae.target.value,M(Me)},className:"flex-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(S.filter((Ae,Me)=>Me!==Ee)),children:e.jsx(Er,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),g.map((Se,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Link title",value:Se.title,onChange:Ae=>{const Me=[...g];Me[Ee].title=Ae.target.value,y(Me)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Google Drive URL",value:Se.drive_url,onChange:Ae=>{const Me=[...g];Me[Ee].drive_url=Ae.target.value,y(Me)},className:"flex-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>y(g.filter((Ae,Me)=>Me!==Ee)),children:e.jsx(Er,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Le,{type:"file",accept:".pdf",multiple:!0,onChange:Be,className:"hidden",id:"pdf-upload"}),e.jsx(G,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(ci,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),_.map((Se,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Se.name}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(_.filter((Ae,Me)=>Me!==Ee)),children:e.jsx(Er,{className:"h-4 w-4"})})]},`existing-${Ee}`)),O.map((Se,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:Se.name,onChange:Ae=>{const Me=[...O];Me[Ee].name=Ae.target.value,q(Me)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>q(O.filter((Ae,Me)=>Me!==Ee)),children:e.jsx(Er,{className:"h-4 w-4"})})]},`pending-${Ee}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:ge,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),j.map((Se,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Video title",value:Se.title,onChange:Ae=>{const Me=[...j];Me[Ee].title=Ae.target.value,N(Me)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Video URL",value:Se.video_url,onChange:Ae=>{const Me=[...j];Me[Ee].video_url=Ae.target.value,N(Me)},className:"flex-1"}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(j.filter((Ae,Me)=>Me!==Ee)),children:e.jsx(Er,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(G,{variant:"outline",onClick:oe,children:"Cancel"}),e.jsx(G,{onClick:xe,disabled:$||Y.isPending||J.isPending,children:$?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:X?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(Se=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Se.preview_image_url?e.jsx("img",{src:Se.preview_image_url,alt:Se.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(wn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Se.title}),Se.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Se.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(ut,{children:ds(new Date(Se.publish_date),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Se.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:Se.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>ne(Se),title:"Edit",children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>re(Se),title:"Duplicate",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Q.mutate(Se.id)},children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})})]})})}const c7e={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 ubs(){const{user:t}=Fs(),{toast:s}=Ra(),r=ar(),n=Qt(),[a,o]=k.useState(""),[l,i]=k.useState("popular"),[c,u]=k.useState(!1),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState(!1),{data:j=[],isLoading:N}=pt({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:$}=await O;if($)throw $;const z=[...new Set((q==null?void 0:q.map(ne=>ne.user_id))||[])],{data:V}=await H.from("profiles").select("id, name").in("id",z),X=new Map((V==null?void 0:V.map(ne=>[ne.id,ne]))||[]);let Y=[];if(t){const{data:ne}=await H.from("wishlist_votes").select("item_id").eq("user_id",t.id);Y=(ne==null?void 0:ne.map(re=>re.item_id))||[]}const J=(q==null?void 0:q.map(ne=>ne.id))||[],{data:Q}=await H.from("wishlist_comments").select("item_id").in("item_id",J),ce=new Map;return Q==null||Q.forEach(ne=>{ce.set(ne.item_id,(ce.get(ne.item_id)||0)+1)}),q==null?void 0:q.map(ne=>{const re=X.get(ne.user_id),oe=(re==null?void 0:re.name)||"Unknown";return{...ne,user_name:oe,user_initials:oe.split(" ").map(he=>he[0]).join("").toUpperCase().slice(0,2),has_voted:Y.includes(ne.id),comment_count:ce.get(ne.id)||0}})}}),S=Tt({mutationFn:async({title:O,description:q})=>{const{error:$}=await H.from("wishlist_items").insert({user_id:t.id,title:O,description:q});if($)throw $},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),y(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),M=Tt({mutationFn:async({itemId:O,hasVoted:q})=>{if(q){const{error:$}=await H.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if($)throw $;return{itemId:O,wasAdded:!1}}else{const{error:$}=await H.from("wishlist_votes").insert({item_id:O,user_id:t.id});if($)throw $;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const q=j.find(z=>z.id===O.itemId),$=((q==null?void 0:q.vote_count)||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:$}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),I=j.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),P=()=>{if(!m.trim()||!g.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:m.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(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ps,{children:[e.jsx(js,{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(ye,{htmlFor:"title",children:"Title"}),e.jsx(Le,{id:"title",placeholder:"Give your idea a clear title...",value:m,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:g,onChange:O=>y(O.target.value),rows:4})]}),e.jsx(G,{onClick:P,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ga,{value:l,onValueChange:O=>i(O),children:e.jsxs(fa,{children:[e.jsx(ss,{value:"popular",children:"Most Popular"}),e.jsx(ss,{value:"latest",children:"Latest"}),e.jsx(ss,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(G,{variant:_?"default":"outline",size:"sm",onClick:()=>w(!_),children:_?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(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(G,{onClick:()=>u(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.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:Pt("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(Tu,{className:Pt("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(Cn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(Mn,{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(Ye,{className:Pt("text-xs",c7e[O.status].color),children:c7e[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(Ki,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const d7e={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 hbs(){const{itemId:t}=ao(),s=ar(),{user:r}=Fs(),{toast:n}=Ra(),a=Qt(),[o,l]=k.useState(""),{data:i=!1}=pt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:j,error:N}=await H.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!j},enabled:!!r}),{data:c,isLoading:u}=pt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:j,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",j.user_id).single();let M=!1;if(r){const{data:I}=await H.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();M=!!I}return{...j,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:M}}}),{data:m=[],isLoading:f}=pt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:j,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((j==null?void 0:j.map(P=>P.user_id))||[])],{data:M}=await H.from("profiles").select("id, name").in("id",S),I=new Map((M==null?void 0:M.map(P=>[P.id,P]))||[]);return j==null?void 0:j.map(P=>{const O=I.get(P.user_id),q=(O==null?void 0:O.name)||"Unknown";return{...P,user_name:q,user_initials:q.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2)}})}}),g=Tt({mutationFn:async j=>{if(j){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 j=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),j!=null&&j.wasAdded&&c){const N=(c.vote_count||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),y=Tt({mutationFn:async j=>{const{error:N}=await H.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:j});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),_=Tt({mutationFn:async j=>{const{error:N}=await H.from("wishlist_comments").delete().eq("id",j);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),w=()=>{o.trim()&&y.mutate(o.trim())};return u?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(ws,{className:"h-8 w-32 mb-6"}),e.jsx(ws,{className:"h-48 w-full mb-6"}),e.jsx(ws,{className:"h-32 w-full"})]})}):c?e.jsx(Ms,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Ga,{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:Pt("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(Tu,{className:Pt("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(Ye,{className:Pt("text-xs",d7e[c.status].color),children:d7e[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(Cn,{className:"h-6 w-6",children:e.jsx(Mn,{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 (",m.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Jle,{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(G,{onClick:w,disabled:!o.trim()||y.isPending,size:"icon",className:"h-auto",children:y.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(j=>e.jsx(ws,{className:"h-20 w-full"},j))}):m.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:m.map(j=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{className:"bg-primary/20 text-primary text-xs",children:j.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:j.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsx(Yke,{content:j.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===j.user_id&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>_.mutate(j.id),children:e.jsx(kr,{className:"h-4 w-4"})})]},j.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(G,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const u7e={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"}},h7e=["open","under_review","planned","in_progress","launched","declined"];function mbs(){const{toast:t}=Ra(),s=ar(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState("all"),[i,c]=k.useState(!1),[u,m]=k.useState(null),{data:f=[],isLoading:g}=pt({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(z=>z.user_id))||[])],{data:I}=await H.from("profiles").select("id, name, email").in("id",M),P=new Map((I==null?void 0:I.map(z=>[z.id,z]))||[]),O=(N==null?void 0:N.map(z=>z.id))||[],{data:q}=await H.from("wishlist_comments").select("item_id").in("item_id",O),$=new Map;return q==null||q.forEach(z=>{$.set(z.item_id,($.get(z.item_id)||0)+1)}),N==null?void 0:N.map(z=>{const V=P.get(z.user_id);return{...z,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:$.get(z.id)||0}})}}),y=Tt({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"})}}),_=Tt({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),m(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),w=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}),j={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(G,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Ga,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:j.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:j.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:j.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:j.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:j.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search ideas, users...",value:n,onChange:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(Rs,{value:o,onValueChange:N=>l(N),children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Filter by status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Statuses"}),h7e.map(N=>e.jsx(ft,{value:N,children:u7e[N].label},N))]})]})]}),g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(ws,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[60px]",children:"Votes"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(jt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(qn,{children:w.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(N=>e.jsxs(ks,{className:Pt(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(ut,{children:e.jsx(Ye,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(ut,{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(ut,{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(ut,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(ut,{children:e.jsxs(Rs,{value:N.status,onValueChange:S=>y.mutate({itemId:N.id,status:S}),children:[e.jsx(Ls,{className:"w-[140px] h-8",children:e.jsx($s,{})}),e.jsx(Ds,{children:h7e.map(S=>e.jsx(ft,{value:S,children:u7e[S].label},S))})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${N.id}`,"_blank"),children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{m(N.id),c(!0)},children:e.jsx(kr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsx(js,{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(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:()=>u&&_.mutate(u),disabled:_.isPending,children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function pbs(){const{user:t}=Fs(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=k.useState(!1),[f,g]=k.useState(null),[y,_]=k.useState(""),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState(""),[P,O]=k.useState(""),[q,$]=k.useState(!1),[z,V]=k.useState(""),[X,Y]=k.useState("once"),[J,Q]=k.useState([]),[ce,ne]=k.useState([]),[re,oe]=k.useState(!1),[he,xe]=k.useState(!1),[ue,ge]=k.useState([]),[_e,Be]=k.useState({total:0,dismissed:0});k.useEffect(()=>{Se()},[]);const Se=async()=>{const{data:We,error:tt}=await H.from("levelup_briefs").select("*").order("created_at",{ascending:!1});tt?(me.error("Failed to fetch briefs"),console.error(tt)):r(We||[]),a(!1)},Ee=()=>{_(""),j(""),S(""),I(""),O(""),$(!1),V(new Date().toISOString().slice(0,16)),Y("once"),Q([]),ne([]),c(null)},Ae=()=>{Ee(),l(!0)},Me=async We=>{c(We),_(We.title),j(We.description||""),S(We.video_url||""),I(We.graphic_url||""),O(We.graphic_link_url||""),$(We.is_published),V(We.publish_date.slice(0,16)),Y(We.show_frequency);const{data:tt}=await H.from("levelup_brief_links").select("*").eq("brief_id",We.id).order("sort_order");Q((tt==null?void 0:tt.map(rt=>({title:rt.title,url:rt.url})))||[]);const{data:Ke}=await H.from("levelup_brief_polls").select("*").eq("brief_id",We.id).order("sort_order");if(Ke){const rt=[];for(const it of Ke){const{data:It}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",it.id).order("sort_order");rt.push({question:it.question,poll_type:it.poll_type,options:(It==null?void 0:It.map(Vt=>Vt.option_text))||[]})}ne(rt)}l(!0)},ke=async We=>{var Ke;const tt=(Ke=We.target.files)==null?void 0:Ke[0];if(tt){oe(!0);try{const rt=await H.functions.invoke("bunny-upload",{body:{action:"create",title:tt.name.replace(/\.[^/.]+$/,"")}});if(rt.error)throw rt.error;const{videoId:it,libraryId:It}=rt.data,Vt=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:it}});if(Vt.error)throw Vt.error;const{uploadUrl:hs,apiKey:Es}=Vt.data,Ts=new XMLHttpRequest;await new Promise((zr,Ft)=>{Ts.upload.addEventListener("progress",Ps=>{if(Ps.lengthComputable){const yr=Math.round(Ps.loaded/Ps.total*100);console.log("Upload progress:",yr)}}),Ts.addEventListener("load",()=>{Ts.status>=200&&Ts.status<300?zr():Ft(new Error(`Upload failed with status ${Ts.status}`))}),Ts.addEventListener("error",()=>Ft(new Error("Upload failed"))),Ts.open("PUT",hs),Ts.setRequestHeader("AccessKey",Es),Ts.send(tt)});const cr=`https://player.mediadelivery.net/embed/${It}/${it}`;S(cr),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(rt){console.error("Upload error:",rt),me.error("Failed to upload video")}finally{oe(!1)}}},Oe=async()=>{if(!y.trim()){me.error("Title is required");return}try{let We;if(i){const{error:tt}=await H.from("levelup_briefs").update({title:y,description:w||null,video_url:N||null,graphic_url:M||null,graphic_link_url:P||null,is_published:q,publish_date:z,show_frequency:X}).eq("id",i.id);if(tt)throw tt;We=i.id,await H.from("levelup_brief_links").delete().eq("brief_id",We);const{data:Ke}=await H.from("levelup_brief_polls").select("id").eq("brief_id",We);if(Ke)for(const rt of Ke)await H.from("levelup_brief_poll_options").delete().eq("poll_id",rt.id);await H.from("levelup_brief_polls").delete().eq("brief_id",We)}else{const{data:tt,error:Ke}=await H.from("levelup_briefs").insert({title:y,description:w||null,video_url:N||null,graphic_url:M||null,graphic_link_url:P||null,is_published:q,publish_date:z,show_frequency:X,created_by:t==null?void 0:t.id}).select().single();if(Ke)throw Ke;We=tt.id}if(J.length>0){const tt=J.map((Ke,rt)=>({brief_id:We,title:Ke.title,url:Ke.url,sort_order:rt}));await H.from("levelup_brief_links").insert(tt)}for(let tt=0;tt0){const It=Ke.options.map((Vt,hs)=>({poll_id:rt.id,option_text:Vt,sort_order:hs}));await H.from("levelup_brief_poll_options").insert(It)}}me.success(i?"Brief updated":"Brief created"),l(!1),Ee(),Se()}catch(We){console.error("Error saving brief:",We),me.error("Failed to save brief")}},qe=async We=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:tt}=await H.from("levelup_briefs").delete().eq("id",We);if(tt)throw tt;me.success("Brief deleted"),Se()}catch(tt){console.error("Error deleting brief:",tt),me.error("Failed to delete brief")}},ve=async We=>{g(We);const{count:tt}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",We.id),{count:Ke}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",We.id).not("dismissed_at","is",null);Be({total:tt||0,dismissed:Ke||0});const{data:rt}=await H.from("levelup_brief_polls").select("*").eq("brief_id",We.id).order("sort_order");if(rt){const it=[];for(const It of rt){const{data:Vt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",It.id).order("sort_order"),{data:hs}=await H.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",It.id),Es=[...new Set((hs==null?void 0:hs.map(Ps=>Ps.user_id))||[])];let Ts={};if(Es.length>0){const{data:Ps}=await H.from("profiles").select("id, name, email").in("id",Es);Ps&&Ps.forEach(yr=>{Ts[yr.id]=yr.name||yr.email||"Unknown"})}const cr=(hs||[]).map(Ps=>({optionId:Ps.option_id,userName:Ts[Ps.user_id]||"Unknown",userId:Ps.user_id})),zr={};let Ft=0;Vt&&Vt.forEach(Ps=>{const yr=(hs==null?void 0:hs.filter(Is=>Is.option_id===Ps.id).length)||0;zr[Ps.id]=yr,Ft+=yr}),it.push({...It,options:Vt||[],results:zr,respondents:cr,totalResponses:It.poll_type==="single"?new Set(hs==null?void 0:hs.map(Ps=>Ps.user_id)).size:Ft})}ge(it)}m(!0)},dt=()=>{Q([...J,{title:"",url:""}])},pe=(We,tt,Ke)=>{const rt=[...J];rt[We][tt]=Ke,Q(rt)},Ue=We=>{Q(J.filter((tt,Ke)=>Ke!==We))},Xe=()=>{ne([...ce,{question:"",poll_type:"single",options:["",""]}])},et=(We,tt)=>{const Ke=[...ce];Ke[We].question=tt,ne(Ke)},Ce=(We,tt)=>{const Ke=[...ce];Ke[We].poll_type=tt,ne(Ke)},Je=We=>{const tt=[...ce];tt[We].options.push(""),ne(tt)},Ge=(We,tt,Ke)=>{const rt=[...ce];rt[We].options[tt]=Ke,ne(rt)},lt=(We,tt)=>{const Ke=[...ce];Ke[We].options=Ke[We].options.filter((rt,it)=>it!==tt),ne(Ke)},He=We=>{ne(ce.filter((tt,Ke)=>Ke!==We))};return e.jsxs(Ms,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(G,{onClick:Ae,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Frequency"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:n?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(We=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:We.title}),e.jsx(ut,{children:e.jsx(Ye,{variant:We.is_published?"default":"secondary",children:We.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"capitalize",children:We.show_frequency.replace("_"," ")}),e.jsx(ut,{children:ds(new Date(We.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>ve(We),children:e.jsx(co,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>Me(We),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>qe(We.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},We.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(js,{children:e.jsx(vs,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ga,{defaultValue:"content",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4",children:[e.jsx(ss,{value:"content",children:"Content"}),e.jsx(ss,{value:"media",children:"Media"}),e.jsx(ss,{value:"links",children:"Links"}),e.jsx(ss,{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(ye,{children:"Title *"}),e.jsx(Le,{value:y,onChange:We=>_(We.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:w,onChange:We=>j(We),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(ye,{children:"Publish Date"}),e.jsx(Le,{type:"datetime-local",value:z,onChange:We=>V(We.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Show Frequency"}),e.jsxs(Rs,{value:X,onValueChange:Y,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"once",children:"Once (until dismissed)"}),e.jsx(ft,{value:"every_login",children:"Every login"}),e.jsx(ft,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qr,{checked:q,onCheckedChange:$}),e.jsx(ye,{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(ye,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Le,{type:"file",accept:"video/*",onChange:ke,disabled:re})}),re&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Or paste embed URL"}),e.jsx(Le,{value:N,onChange:We=>S(We.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(ye,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Le,{type:"file",accept:"image/*",onChange:async We=>{var Ke;const tt=(Ke=We.target.files)==null?void 0:Ke[0];if(tt){xe(!0);try{const rt=tt.name.split(".").pop(),it=`brief-graphics/${Date.now()}.${rt}`,{error:It}=await H.storage.from("banner-images").upload(it,tt,{upsert:!0});if(It)throw It;const{data:Vt}=H.storage.from("banner-images").getPublicUrl(it);I(Vt.publicUrl),me.success("Image uploaded!")}catch(rt){console.error(rt),me.error("Failed to upload image")}finally{xe(!1)}}},disabled:he})}),he&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Or paste Image URL"}),e.jsx(Le,{value:M,onChange:We=>I(We.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Click-through Link (optional)"}),e.jsx(Le,{value:P,onChange:We=>O(We.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(ye,{children:"Quick Links"}),e.jsxs(G,{variant:"outline",size:"sm",onClick:dt,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),J.map((We,tt)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Le,{value:We.title,onChange:Ke=>pe(tt,"title",Ke.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Le,{value:We.url,onChange:Ke=>pe(tt,"url",Ke.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>Ue(tt),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]},tt)),J.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(ye,{children:"Polls"}),e.jsxs(G,{variant:"outline",size:"sm",onClick:Xe,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((We,tt)=>e.jsx(Pe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Le,{value:We.question,onChange:Ke=>et(tt,Ke.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Rs,{value:We.poll_type,onValueChange:Ke=>Ce(tt,Ke),children:[e.jsx(Ls,{className:"w-32",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"single",children:"Single"}),e.jsx(ft,{value:"multi",children:"Multi-select"})]})]}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>He(tt),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[We.options.map((Ke,rt)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:Ke,onChange:it=>Ge(tt,rt,it.target.value),placeholder:`Option ${rt+1}`}),We.options.length>2&&e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>lt(tt,rt),children:e.jsx(kr,{className:"h-4 w-4 text-muted-foreground"})})]},rt)),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>Je(tt),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},tt)),ce.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(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{onClick:Oe,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:m,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(De,{children:e.jsx("p",{className:"text-2xl font-bold",children:_e.total})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(De,{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(We=>e.jsxs(Pe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:We.question}),e.jsx("div",{className:"space-y-2",children:We.options.map(tt=>{const Ke=We.results[tt.id]||0,rt=We.totalResponses>0?Math.round(Ke/We.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:tt.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[Ke," (",rt,"%)"]})]}),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:`${rt}%`}})}),Ke>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(We.respondents||[]).filter(it=>it.optionId===tt.id).map((it,It)=>e.jsx(Ye,{variant:"secondary",className:"text-xs font-normal",children:it.userName},It))})]},tt.id)})})]},We.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const fbs=()=>{const{user:t}=Fs(),{toast:s}=Ra(),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,m]=k.useState(null),[f,g]=k.useState(""),{data:y=[],isLoading:_}=pt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:P,error:O}=await H.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return P}}),w=Tt({mutationFn:async P=>{let O=P.existingImageUrl;if(P.image){const $=P.image.name.split(".").pop(),z=`${Date.now()}-${Math.random().toString(36).substring(7)}.${$}`,{error:V}=await H.storage.from("service-images").upload(z,P.image);if(V)throw V;const{data:X}=H.storage.from("service-images").getPublicUrl(z);O=X.publicUrl}const q={name:P.item.name,description:P.item.description||null,preview_image_url:O,signup_link_url:P.item.signup_link_url,publish_date:P.item.publish_date?new Date(P.item.publish_date).toISOString():new Date().toISOString(),is_published:P.item.is_published,created_by:t==null?void 0:t.id};if(P.itemId){const{error:$}=await H.from("additional_services").update(q).eq("id",P.itemId);if($)throw $}else{const{error:$}=await H.from("additional_services").insert(q);if($)throw $}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),N()},onError:P=>{s({title:"Error saving service",description:P.message,variant:"destructive"})}}),j=Tt({mutationFn:async P=>{const{error:O}=await H.from("additional_services").delete().eq("id",P);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:P=>{s({title:"Error deleting service",description:P.message,variant:"destructive"})}}),N=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),m(null),g(""),l(null)},S=P=>{l(P),c({name:P.name,description:P.description||"",signup_link_url:P.signup_link_url,publish_date:P.publish_date?new Date(P.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:P.is_published}),g(P.preview_image_url||""),a(!0)},M=P=>{var q;const O=(q=P.target.files)==null?void 0:q[0];O&&(m(O),g(URL.createObjectURL(O)))},I=P=>{if(P.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:y.length})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:y.filter(P=>P.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:P=>{a(P),P||N()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(Le,{id:"name",value:i.name,onChange:P=>c({...i,name:P.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(xy,{content:i.description,onChange:P=>c({...i,description:P}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Le,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:P=>c({...i,signup_link_url:P.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:i.publish_date,onChange:P=>c({...i,publish_date:P.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:P=>c({...i,is_published:P})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(G,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{m(null),g("")},children:e.jsx(Er,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(bl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Le,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{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"})}):y.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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-16",children:"Preview"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Signup Link"}),e.jsx(jt,{children:"Publish Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:y.map(P=>e.jsxs(ks,{children:[e.jsx(ut,{children:P.preview_image_url?e.jsx("img",{src:P.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(bl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(ut,{className:"font-medium",children:P.name}),e.jsx(ut,{children:e.jsxs("a",{href:P.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(ut,{children:new Date(P.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(Ye,{variant:P.is_published?"default":"secondary",children:P.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>S(P),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&j.mutate(P.id)},children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},P.id))})]})})})]})})};function xbs(){const{toast:t}=Ra(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:j,error:N}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(j.coupons||[])}catch(j){console.error("Error fetching coupons:",j),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 j={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?j.percent_off=parseFloat(u.percentOff):(j.amount_off=Math.round(parseFloat(u.amountOff)*100),j.currency="usd"),u.duration==="repeating"&&(j.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:S}=await H.functions.invoke("stripe-manage-coupons",{body:j});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),c(!1),m({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(j){console.error("Error creating coupon:",j),t({title:"Error",description:j.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},y=async j=>{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:j}});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"})}},_=j=>j.percent_off?`${j.percent_off}% off`:j.amount_off?`$${(j.amount_off/100).toFixed(2)} off`:"N/A",w=j=>{switch(j.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${j.duration_in_months} months`;default:return j.duration}};return e.jsx(Ms,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Promotion Code (what users will type)"}),e.jsx(Le,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:j=>m({...u,promotionCode:j.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Coupon Name (internal label)"}),e.jsx(Le,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:j=>m({...u,name:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Discount Type"}),e.jsxs(Rs,{value:u.discountType,onValueChange:j=>{const N=j==="amount"&&u.duration==="forever"?"once":u.duration;m({...u,discountType:j,duration:N})},children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(_S,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(ft,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(ml,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:j=>m({...u,percentOff:j.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Le,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:j=>m({...u,amountOff:j.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Duration"}),e.jsxs(Rs,{value:u.duration,onValueChange:j=>m({...u,duration:j}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"once",children:"Once (first payment only)"}),e.jsx(ft,{value:"repeating",children:"Multiple months"}),e.jsxs(ft,{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(ye,{children:"Number of Months"}),e.jsx(Le,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:j=>m({...u,durationInMonths:j.target.value})})]}),e.jsx(G,{onClick:g,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Active Coupons"}),e.jsx(vr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(De,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ys,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Promo Code"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Discount"}),e.jsx(jt,{children:"Duration"}),e.jsx(jt,{children:"Redemptions"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:s.map(j=>{var N;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-mono font-medium",children:((N=j.promotion_codes)==null?void 0:N.length)>0?j.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(ut,{children:j.name||"-"}),e.jsx(ut,{children:_(j)}),e.jsx(ut,{children:w(j)}),e.jsx(ut,{children:j.times_redeemed}),e.jsx(ut,{children:e.jsx(Ye,{variant:j.valid?"default":"secondary",children:j.valid?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>y(j.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})})]},j.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"How to Use Coupons"})}),e.jsxs(De,{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 Tye={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 gbs(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),[l,i]=k.useState(null),{data:c,isLoading:u,refetch:m}=pt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:N,error:S}=await H.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(S)throw S;return N}}),{data:f}=pt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:N,error:S}=await H.from("brokerages").select("*").order("name");if(S)throw S;return await Promise.all((N||[]).map(async I=>{const{data:P}=await H.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",I.id),{data:O}=await H.from("user_roles").select("user_id").eq("role","brokerage_manager"),q=(O==null?void 0:O.map(V=>V.user_id))||[],$=(P==null?void 0:P.filter(V=>q.includes(V.id)))||[],z=(P==null?void 0:P.length)||0;return{...I,managers:$,agentCount:z}}))}}),{data:g}=pt({queryKey:["admin-website-subscriptions"],queryFn:async()=>{const{data:N,error:S}=await H.from("local_move_subscriptions").select("*").order("created_at",{ascending:!1});if(S)throw S;return N}}),y=N=>{if(N.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(N.brokerage_id&&!N.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(N.is_trial&&N.trial_expires_at)return new Date(N.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(N.subscription_status==="active"||N.subscription_status==="trialing"){const S=Tye[N.subscription_product_id];return{status:(S==null?void 0:S.name)||"Active",badge:N.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return N.subscription_status==="canceled"||N.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},_=c==null?void 0:c.filter(N=>{var M,I;if(!(((M=N.name)==null?void 0:M.toLowerCase().includes(t.toLowerCase()))||((I=N.email)==null?void 0:I.toLowerCase().includes(t.toLowerCase()))))return!1;if(a!=="all"){const P=N.subscription_source||"platform";if(a==="platform"&&P==="local_move_website"||a==="local_move_website"&&P!=="local_move_website")return!1}switch(y(N),r){case"active":return N.subscription_status==="active";case"trialing":return N.subscription_status==="trialing"||N.is_trial&&new Date(N.trial_expires_at)>new Date;case"grandfathered":return N.is_grandfathered;case"brokerage":return N.brokerage_id&&!N.subscription_product_id&&!N.is_grandfathered;case"expired":return N.subscription_status==="canceled"||N.subscription_status==="past_due"||N.is_trial&&new Date(N.trial_expires_at)<=new Date;case"none":return!N.subscription_status||N.subscription_status==="none";default:return!0}}),w={totalUsers:(c==null?void 0:c.length)||0,activeSubscriptions:(c==null?void 0:c.filter(N=>N.subscription_status==="active").length)||0,trials:(c==null?void 0:c.filter(N=>N.subscription_status==="trialing"||N.is_trial&&new Date(N.trial_expires_at)>new Date).length)||0,grandfathered:(c==null?void 0:c.filter(N=>N.is_grandfathered).length)||0,brokerageMembers:(c==null?void 0:c.filter(N=>N.brokerage_id&&!N.subscription_product_id&&!N.is_grandfathered).length)||0,individualSubscribers:(c==null?void 0:c.filter(N=>N.subscription_status==="active"&&N.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(c==null?void 0:c.filter(N=>N.subscription_status==="active"&&(N.subscription_product_id==="prod_Tc08MupgoVySDG"||N.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},j=N=>{window.open(`https://dashboard.stripe.com/customers/${N}`,"_blank")};return e.jsx(Ms,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(G,{onClick:()=>m(),variant:"outline",size:"sm",children:[e.jsx(zo,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ur,{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:w.totalUsers})]})}),e.jsx(Pe,{className:"border-green-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Px,{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:w.activeSubscriptions})]})}),e.jsx(Pe,{className:"border-blue-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{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:w.trials})]})}),e.jsx(Pe,{className:"border-purple-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{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:w.grandfathered})]})}),e.jsx(Pe,{className:"border-orange-500/50",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:w.brokerageMembers})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ew,{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:w.individualSubscribers})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:w.brokerageSubscribers})]})})]}),e.jsxs(ga,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"users",children:"All Users"}),e.jsx(ss,{value:"brokerages",children:"Brokerages"}),e.jsxs(ss,{value:"websites",className:"gap-2",children:[e.jsx(Nd,{className:"h-4 w-4"}),"Website Subscriptions",g&&g.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1",children:g.length})]})]}),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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:t,onChange:N=>s(N.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:a,onValueChange:N=>o(N),children:[e.jsx(Ls,{className:"w-[200px]",children:e.jsx($s,{placeholder:"Source"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Sources"}),e.jsx(ft,{value:"platform",children:"Platform"}),e.jsx(ft,{value:"local_move_website",children:"Local Move Website"})]})]}),e.jsxs(Rs,{value:r,onValueChange:N=>n(N),children:[e.jsx(Ls,{className:"w-[200px]",children:e.jsx($s,{placeholder:"Filter by status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Statuses"}),e.jsx(ft,{value:"active",children:"Active Subscriptions"}),e.jsx(ft,{value:"trialing",children:"Trials"}),e.jsx(ft,{value:"grandfathered",children:"Grandfathered"}),e.jsx(ft,{value:"brokerage",children:"Brokerage Members"}),e.jsx(ft,{value:"expired",children:"Expired/Canceled"}),e.jsx(ft,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"User"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Plan"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{children:"End Date"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:u?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(_==null?void 0:_.length)===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):_==null?void 0:_.map(N=>{var I,P;const S=y(N),M=Tye[N.subscription_product_id];return e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N.email})]})}),e.jsx(ut,{children:e.jsx(Ye,{variant:S.variant,children:S.badge})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm",children:N.is_grandfathered?"Legacy Access":N.brokerage_id&&!N.subscription_product_id?"Brokerage Subscription":(M==null?void 0:M.name)||S.status})}),e.jsx(ut,{children:(I=N.brokerages)!=null&&I.name?e.jsx("span",{className:"text-sm",children:N.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{children:N.subscription_end_date?e.jsx("span",{className:"text-sm",children:ds(new Date(N.subscription_end_date),"MMM d, yyyy")}):N.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ds(new Date(N.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[N.stripe_customer_id&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>j(N.stripe_customer_id),children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(Oi,{asChild:!0,children:e.jsx(G,{variant:"outline",size:"sm",onClick:()=>i(N),children:"Details"})}),e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Subscription Details"}),e.jsxs(Gr,{children:[N.name," (",N.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(Ye,{variant:S.variant,className:"mt-1",children:S.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:N.is_grandfathered?"Grandfathered (Legacy)":N.brokerage_id&&!N.subscription_product_id?"Brokerage Subscription":(M==null?void 0:M.name)||"None"})]}),N.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((P=N.brokerages)==null?void 0:P.name)||"Unknown"})]}),N.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:ds(new Date(N.subscription_end_date),"MMMM d, yyyy")})]}),N.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:ds(new Date(N.trial_expires_at),"MMMM d, yyyy")})]}),N.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:N.stripe_customer_id})]})]}),N.stripe_customer_id&&e.jsxs(G,{className:"w-full",onClick:()=>j(N.stripe_customer_id),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},N.id)})})]})})})]}),e.jsx(bs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:f==null?void 0:f.map(N=>{var M,I;const S=(M=N.managers)==null?void 0:M.some(P=>P.subscription_status==="active"&&(P.subscription_product_id==="prod_Tc08MupgoVySDG"||P.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ta,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:N.name}),e.jsxs(vr,{children:[N.agentCount," agents"]})]})]}),e.jsx(Ye,{variant:S?"default":"outline",children:S?"Active Subscription":"No Active Subscription"})]})}),e.jsx(De,{children:((I=N.managers)==null?void 0:I.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),N.managers.map(P=>{const O=Tye[P.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:P.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:P.email})]}),e.jsx("div",{className:"text-right",children:O?e.jsxs("div",{children:[e.jsx(Ye,{variant:"default",children:O.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:O.price})]}):e.jsx(Ye,{variant:"outline",children:"No Subscription"})})]},P.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},N.id)})})}),e.jsx(bs,{value:"websites",className:"space-y-4",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Nd,{className:"h-5 w-5 text-primary"}),"Local Move Website Subscriptions"]}),e.jsx(vr,{children:"$249 setup fee + $99/mo subscriptions from TheLocalMove.com agent websites"})]}),e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Setup Fee"}),e.jsx(jt,{children:"Monthly"}),e.jsx(jt,{children:"Next Renewal"}),e.jsx(jt,{children:"Started"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:g?g.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No website subscriptions yet"})}):g.map(N=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N.agent_name||"—"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:N.agent_email})]})}),e.jsx(ut,{children:e.jsx(Ye,{variant:N.status==="active"?"default":N.status==="canceled"?"destructive":"outline",children:N.status})}),e.jsx(ut,{children:N.setup_fee_paid?e.jsxs(Ye,{variant:"secondary",children:["Paid · $",(N.setup_fee_amount_cents/100).toFixed(0)]}):e.jsx(Ye,{variant:"outline",children:"Unpaid"})}),e.jsxs(ut,{className:"font-medium",children:["$",(N.monthly_amount_cents/100).toFixed(0),"/mo"]}),e.jsx(ut,{children:N.current_period_end?e.jsx("span",{className:"text-sm",children:ds(new Date(N.current_period_end),"MMM d, yyyy")}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm",children:ds(new Date(N.created_at),"MMM d, yyyy")})}),e.jsx(ut,{className:"text-right",children:N.stripe_customer_id&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>j(N.stripe_customer_id),children:e.jsx(rn,{className:"h-4 w-4"})})})]},N.id)):e.jsx(ks,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8",children:"Loading…"})})})]})})]})})]})]})})}function ybs(){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(()=>{m()},[]);const m=async()=>{try{const{data:_,error:w}=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(w)throw w;s(_||[]);const j=(_==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:j,pending:N,cancelled:S,totalDiscounts:j*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"),m()}catch(_){me.dismiss(),console.error("Error processing qualifications:",_),me.error("Failed to process qualifications")}},g=t.filter(_=>{var N,S,M,I,P,O;const w=((S=(N=_.referrer_brokerage)==null?void 0:N.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((I=(M=_.referred_brokerage)==null?void 0:M.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((O=(P=_.referred_user)==null?void 0:P.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),j=l==="all"||_.status===l;return w&&j}),y=_=>{switch(_){case"qualified":return e.jsxs(Ye,{className:"bg-green-100 text-green-800",children:[e.jsx(wi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(Ye,{variant:"secondary",children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(Ye,{variant:"destructive",children:[e.jsx(Nc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(Ye,{children:_})}};return e.jsx(Ms,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(G,{onClick:f,variant:"outline",children:[e.jsx(zo,{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(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ur,{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(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wi,{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(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{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(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nc,{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(Pe,{children:e.jsx(De,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ml,{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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"All Referrals"}),e.jsx(vr,{children:"View and manage all referral relationships"})]}),e.jsxs(De,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by brokerage or email...",value:a,onChange:_=>o(_.target.value),className:"pl-10"})]}),e.jsxs(Rs,{value:l,onValueChange:i,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Filter by status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Statuses"}),e.jsx(ft,{value:"pending",children:"Pending"}),e.jsx(ft,{value:"qualified",children:"Qualified"}),e.jsx(ft,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Referrer"}),e.jsx(jt,{children:"Referred"}),e.jsx(jt,{children:"Signup Date"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Qualified Date"}),e.jsx(jt,{children:"Discount"})]})}),e.jsx(qn,{children:g.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):g.map(_=>{var w,j,N,S;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:((w=_.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{children:((j=_.referred_brokerage)==null?void 0:j.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(ut,{children:ds(new Date(_.signup_date),"MMM d, yyyy")}),e.jsx(ut,{children:y(_.status)}),e.jsx(ut,{children:_.qualified_date?ds(new Date(_.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(ut,{children:_.discount_applied?e.jsx(Ye,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},_.id)})})]})]})]})]})})}const Aye=[{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"}],vbs=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function bbs(){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(()=>{m()},[]);const m=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)},y=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(I=>I.target_role===c.target_role).reduce((I,P)=>Math.max(I,P.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),m()}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"),m()}catch(M){console.error("Error deleting checklist item:",M),me.error("Failed to delete checklist item")}},w=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"),m()}catch(M){console.error("Error toggling item:",M),me.error("Failed to update item")}},j=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(G,{onClick:f,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Ye,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(De,{children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:j.map((S,M)=>{var I;return e.jsxs(ks,{children:[e.jsx(ut,{className:"text-muted-foreground",children:M+1}),e.jsx(ut,{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(ut,{children:e.jsx(Ye,{variant:"outline",children:((I=Aye.find(P=>P.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(ut,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Ye,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(De,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:N.map((S,M)=>{var I;return e.jsxs(ks,{children:[e.jsx(ut,{className:"text-muted-foreground",children:M+1}),e.jsx(ut,{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(ut,{children:e.jsx(Ye,{variant:"outline",children:((I=Aye.find(P=>P.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(ut,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{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(ye,{children:"Target Role"}),e.jsxs(Rs,{value:c.target_role,onValueChange:S=>u({...c,target_role:S}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:vbs.map(S=>e.jsx(ft,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Action Type"}),e.jsxs(Rs,{value:c.action_type,onValueChange:S=>u({...c,action_type:S}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:Aye.map(S=>e.jsx(ft,{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(ye,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(G,{onClick:y,children:l?"Save Changes":"Create Item"})]})]})})]})}function _bs(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("name"),[l,i]=k.useState("asc"),[c,u]=k.useState(""),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState(""),{data:j}=pt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:X}=await H.from("brokerages").select("id, name").order("name");if(X)throw X;return V}}),N=async V=>{let Y=[],J=0,Q=!0;for(;Q;){const{data:ce,error:ne}=await V(J,J+1e3-1);if(ne)throw ne;ce&&ce.length>0?(Y=[...Y,...ce],J+=1e3,Q=ce.length===1e3):Q=!1}return Y},{data:S,isLoading:M}=pt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((Me,ke)=>H.from("profiles").select("id, name, email, brokerage_id, created_at").range(Me,ke)),{data:X}=await H.from("brokerages").select("id, name"),Y=new Map((X==null?void 0:X.map(Me=>[Me.id,Me.name]))||[]),[{data:J},{data:Q},{data:ce},{data:ne},{data:re},{data:oe},{data:he}]=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")]),xe=new Map;J==null||J.forEach(Me=>xe.set(Me.owner_user_id,Me.contact_count));const ue=new Map;Q==null||Q.forEach(Me=>ue.set(Me.owner_user_id,Me.video_count));const ge=new Map;ce==null||ce.forEach(Me=>ge.set(Me.owner_user_id,Me.popby_count));const _e=new Map;ne==null||ne.forEach(Me=>_e.set(Me.agent_id,Me.listing_count));const Be=new Map;re==null||re.forEach(Me=>Be.set(Me.owner_user_id,Me.deal_count));const Se=new Map;oe==null||oe.forEach(Me=>Se.set(Me.owner_user_id,{total:Me.portal_count,active:Me.active_portal_count}));const Ee=new Map;return he==null||he.forEach(Me=>Ee.set(Me.owner_user_id,{total:Me.card_count,sent:Me.sent_card_count,views:Me.total_card_views})),V.map(Me=>{const ke=Se.get(Me.id),Oe=Ee.get(Me.id);return{id:Me.id,name:Me.name||"Unknown",email:Me.email||"",brokerage_id:Me.brokerage_id,brokerage_name:Me.brokerage_id&&Y.get(Me.brokerage_id)||null,contact_count:xe.get(Me.id)||0,video_count:ue.get(Me.id)||0,popby_count:ge.get(Me.id)||0,listing_count:_e.get(Me.id)||0,deal_count:Be.get(Me.id)||0,portal_count:(ke==null?void 0:ke.total)||0,active_portal_count:(ke==null?void 0:ke.active)||0,card_count:(Oe==null?void 0:Oe.total)||0,sent_card_count:(Oe==null?void 0:Oe.sent)||0,total_card_views:(Oe==null?void 0:Oe.views)||0,created_at:Me.created_at}})}}),I=k.useMemo(()=>{if(!S)return[];let V=S.filter(X=>{const Y=t.toLowerCase(),J=!t||X.name.toLowerCase().includes(Y)||X.email.toLowerCase().includes(Y),Q=r==="all"||r==="none"&&!X.brokerage_id||X.brokerage_id===r,ce=parseInt(c)||0,ne=parseInt(m)||0,re=parseInt(g)||0,oe=parseInt(_)||0,he=X.contact_count>=ce&&X.video_count>=ne&&X.popby_count>=re&&X.listing_count>=oe;return J&&Q&&he});return V.sort((X,Y)=>{let J=0;return a==="name"?J=X.name.localeCompare(Y.name):J=X[a]-Y[a],l==="asc"?J:-J}),V},[S,t,r,a,l,c,m,g,_]),P=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"],X=I.map(ne=>[ne.name,ne.email,ne.brokerage_name||"None",ne.contact_count,ne.video_count,ne.popby_count,ne.listing_count,ne.deal_count,`${ne.portal_count} (${ne.active_portal_count})`,ne.card_count,ne.sent_card_count,ne.total_card_views]),Y=[V.join(","),...X.map(ne=>ne.map(re=>`"${re}"`).join(","))].join(` `),J=new Blob([Y],{type:"text/csv"}),Q=URL.createObjectURL(J),ce=document.createElement("a");ce.href=Q,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(Q)},q=k.useMemo(()=>I.length?I.reduce((V,X)=>({contacts:V.contacts+X.contact_count,videos:V.videos+X.video_count,popbys:V.popbys+X.popby_count,listings:V.listings+X.listing_count,deals:V.deals+X.deal_count,portals:V.portals+X.portal_count,activePortals:V.activePortals+X.active_portal_count,cards:V.cards+X.card_count,sentCards:V.sentCards+X.sent_card_count,cardViews:V.cardViews+X.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[I]),$=k.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),z=({field:V,children:X})=>e.jsx(jt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>P(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[X,e.jsx(wd,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(W1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(u1,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(De,{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:$.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(Pe,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(rr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(De,{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:$.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(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(vr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(De,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:t,onChange:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Rs,{value:r,onValueChange:n,children:[e.jsxs(Ls,{children:[e.jsx(Ta,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx($s,{placeholder:"Brokerage"})]}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Brokerages"}),e.jsx(ft,{value:"none",children:"No Brokerage"}),j==null?void 0:j.map(V=>e.jsx(ft,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(Le,{type:"number",placeholder:"Min contacts",value:c,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Le,{type:"number",placeholder:"Min videos",value:m,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Le,{type:"number",placeholder:"Min popbys",value:g,onChange:V=>y(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:I.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children: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(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(z,{field:"name",children:"Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Brokerage"}),e.jsx(z,{field:"contact_count",children:"Contacts"}),e.jsx(z,{field:"video_count",children:"Videos"}),e.jsx(z,{field:"popby_count",children:"Popbys"}),e.jsx(z,{field:"listing_count",children:"Listings"}),e.jsx(z,{field:"deal_count",children:"Deals"}),e.jsx(z,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(u1,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(z,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(qn,{children:I.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(V=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:V.name}),e.jsx(ut,{className:"text-muted-foreground",children:V.email}),e.jsx(ut,{children:V.brokerage_name?e.jsx(Ye,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(ut,{children:e.jsx(Ye,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(ut,{children:V.portal_count>0?e.jsxs(kc,{children:[e.jsx(Sc,{children:e.jsxs(Ye,{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(sc,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(Ye,{variant:"outline",children:"0"})}),e.jsx(ut,{children:V.card_count>0?e.jsxs(kc,{children:[e.jsx(Sc,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ye,{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(Fn,{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(Tn,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(sc,{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(Ye,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function wbs(){Ra(),Qt();const[t,s]=k.useState("user-analytics"),{data:r}=pt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:y,error:_}=await H.from("feature_flags").select("*").order("key");if(_)throw _;return y}}),{data:n,isLoading:a}=pt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:y,error:_}=await H.from("relationship_types").select("*").order("sort_order");if(_)throw _;return y}}),{data:o,isLoading:l}=pt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:y,error:_}=await H.from("action_types").select("*").order("sort_order");if(_)throw _;return y}}),{data:i,isLoading:c}=pt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:y,error:_}=await H.from("action_scripts").select("*, action_type:action_types(*)");if(_)throw _;return y}}),{data:u,isLoading:m}=pt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:y,error:_}=await H.from("touchpoint_plans").select("*").order("name");if(_)throw _;return y}}),{data:f,isLoading:g}=pt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:y,error:_}=await H.from("popby_items").select("*").is("owner_user_id",null).order("name");if(_)throw _;return y}});return e.jsx(Ms,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ga,{value:t,onValueChange:s,children:[e.jsxs(fa,{className:"grid w-full grid-cols-9",children:[e.jsxs(ss,{value:"user-analytics",className:"gap-2",children:[e.jsx(co,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ss,{value:"relationship-types",className:"gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ss,{value:"action-types",className:"gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ss,{value:"scripts",className:"gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ss,{value:"video-scripts",className:"gap-2",children:[e.jsx(_u,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ss,{value:"plans",className:"gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ss,{value:"popbys",className:"gap-2",children:[e.jsx(bo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ss,{value:"settings",className:"gap-2",children:[e.jsx(el,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ss,{value:"feature-flags",className:"gap-2",children:[e.jsx(m1,{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(_bs,{})}),e.jsx(bs,{value:"relationship-types",className:"mt-6",children:e.jsx(jbs,{types:n||[],isLoading:a})}),e.jsx(bs,{value:"action-types",className:"mt-6",children:e.jsx(Nbs,{types:o||[],isLoading:l})}),e.jsx(bs,{value:"scripts",className:"mt-6",children:e.jsx(kbs,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx(bs,{value:"video-scripts",className:"mt-6",children:e.jsx(Tbs,{})}),e.jsx(bs,{value:"plans",className:"mt-6",children:e.jsx(Sbs,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:m})}),e.jsx(bs,{value:"popbys",className:"mt-6",children:e.jsx(Mbs,{items:f||[],isLoading:g})}),e.jsx(bs,{value:"settings",className:"mt-6",children:e.jsx(Abs,{})}),e.jsx(bs,{value:"feature-flags",className:"mt-6",children:e.jsx(Cbs,{flags:r||[]})})]})]})})}function jbs({types:t,isLoading:s}){const{toast:r}=Ra(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Tt({mutationFn:async m=>{if(m.id){const{error:f}=await H.from("relationship_types").update({name:m.name,description:m.description,icon:m.icon}).eq("id",m.id);if(f)throw f}else{const{error:f}=await H.from("relationship_types").insert([{name:m.name,description:m.description,icon:m.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:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),u=async m=>{await H.from("relationship_types").update({active:!m.active}).eq("id",m.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Relationship Types"}),e.jsx(vr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(G,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-12"}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:t.map(m=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx(Eu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(ut,{className:"font-medium",children:m.name}),e.jsx(ut,{className:"text-muted-foreground",children:m.description}),e.jsx(ut,{children:e.jsx(qr,{checked:m.active,onCheckedChange:()=>u(m)})}),e.jsx(ut,{children:e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{o(m),i(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})})})]},m.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:m=>{m.preventDefault();const f=new FormData(m.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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"icon",children:"Icon"}),e.jsx(Le,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Nbs({types:t,isLoading:s}){const{toast:r}=Ra(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Tt({mutationFn:async m=>{if(m.id){const{error:f}=await H.from("action_types").update({name:m.name,description:m.description,icon:m.icon,color:m.color}).eq("id",m.id);if(f)throw f}else{const{error:f}=await H.from("action_types").insert([{name:m.name,description:m.description,icon:m.icon,color:m.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:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),u=async m=>{await H.from("action_types").update({active:!m.active}).eq("id",m.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Action Types"}),e.jsx(vr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(G,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Color"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:t.map(m=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:m.name}),e.jsx(ut,{className:"text-muted-foreground",children:m.description}),e.jsx(ut,{children:m.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:m.color}})}),e.jsx(ut,{children:e.jsx(qr,{checked:m.active,onCheckedChange:()=>u(m)})}),e.jsx(ut,{children:e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{o(m),i(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})})})]},m.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsxs(vs,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:m=>{m.preventDefault();const f=new FormData(m.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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"icon",children:"Icon"}),e.jsx(Le,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"color",children:"Color"}),e.jsx(Le,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function kbs({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ra(),a=Qt(),[o,l]=k.useState(null),[i,c]=k.useState(!1),u=Tt({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"})}}),m=Tt({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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Script Library"}),e.jsx(vr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(G,{onClick:()=>{l(null),c(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(De,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Action Type"}),e.jsx(jt,{children:"Tone"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:t.map(f=>{var g;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:f.title}),e.jsx(ut,{children:e.jsx(Ye,{variant:"outline",children:((g=f.action_type)==null?void 0:g.name)||"Unknown"})}),e.jsx(ut,{className:"text-muted-foreground",children:f.tone}),e.jsx(ut,{children:e.jsx(Ye,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(ut,{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{l(f),c(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>m.mutate(f.id),children:e.jsx(kr,{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(js,{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(ye,{htmlFor:"title",children:"Title"}),e.jsx(Le,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Rs,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select action type"})}),e.jsx(Ds,{children:s.map(f=>e.jsx(ft,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(Le,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Tr,{id:"script_body",name:"script_body",defaultValue:o==null?void 0:o.script_body,rows:8,required:!0,placeholder:`Use {{FirstName}}, {{LastName}}, and {{AgentName}} as placeholders. Example: Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in...`})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Sbs({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ra(),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[m,f]=k.useState(null),[g,y]=k.useState(!1),[_,w]=k.useState(null),[j,N]=k.useState(null),{data:S}=pt({queryKey:["plan-items",m],queryFn:async()=>{if(!m)return[];const{data:z,error:V}=await H.from("touchpoint_plan_items").select("*").eq("plan_id",m).order("month_number");if(V)throw V;return z},enabled:!!m}),M=Tt({mutationFn:async z=>{if(z.id){const{error:V}=await H.from("touchpoint_plans").update({name:z.name,description:z.description,active:z.active}).eq("id",z.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plans").insert([{name:z.name,description:z.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:z=>{a({title:"Error",description:z.message,variant:"destructive"})}}),I=Tt({mutationFn:async z=>{if(z.id){const{error:V}=await H.from("touchpoint_plan_items").update({action_type_id:z.action_type_id,default_script_id:z.default_script_id,notes:z.notes}).eq("id",z.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plan_items").insert([{plan_id:z.plan_id,month_number:z.month_number,action_type_id:z.action_type_id,default_script_id:z.default_script_id,notes:z.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",m]}),a({title:"Item saved"})}}),P=Tt({mutationFn:async z=>{const{error:V}=await H.from("touchpoint_plan_items").delete().eq("id",z);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",m]})}}),O=Tt({mutationFn:async z=>{const{data:V,error:X}=await H.from("action_scripts").insert([{...z,active:!0}]).select().single();if(X)throw X;return V},onSuccess:async z=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),_&&await I.mutateAsync({id:_.itemId,plan_id:m,month_number:_.month,action_type_id:_.actionTypeId,default_script_id:z.id}),y(!1),w(null),a({title:"Script created and assigned"})},onError:z=>{a({title:"Error",description:z.message,variant:"destructive"})}}),q=(z,V,X)=>{w({month:z,actionTypeId:V,itemId:X}),y(!0)},$=z=>r.find(V=>V.id===z);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Touchpoint Plans"}),e.jsx(vr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(G,{onClick:()=>{i(null),u(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(De,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{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(z=>e.jsxs(Pe,{className:`cursor-pointer transition-colors ${m===z.id?"border-primary":""}`,onClick:()=>f(z.id),children:[e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Lt,{className:"text-base",children:z.name}),e.jsx(G,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(z),u(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})})]})}),e.jsxs(De,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:z.description}),e.jsx(Ye,{variant:z.active?"default":"secondary",className:"mt-2",children:z.active?"Active":"Inactive"})]})]},z.id))})})]}),m&&e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Plan Schedule"}),e.jsx(vr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(z,V)=>V+1).map(z=>{const V=S==null?void 0:S.find(J=>J.month_number===z),X=V!=null&&V.default_script_id?$(V.default_script_id):null,Y=r.filter(J=>J.action_type_id===(V==null?void 0:V.action_type_id)&&J.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 ",z]}),e.jsxs(Rs,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:J=>{J==="none"&&V?P.mutate(V.id):J!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:m,month_number:z,action_type_id:J,default_script_id:null})},children:[e.jsx(Ls,{className:"w-40",children:e.jsx($s,{placeholder:"No action"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No action"}),s.filter(J=>J.active).map(J=>e.jsx(ft,{value:J.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[J.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:J.color}}),J.name]})},J.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{value:V.default_script_id||"none",onValueChange:J=>{N(null),I.mutate({id:V.id,default_script_id:J==="none"?null:J})},children:[e.jsx(Ls,{className:"w-56",children:e.jsx($s,{placeholder:"Select script"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No default script"}),Y.map(J=>e.jsxs(ft,{value:J.id,children:[J.title," ",J.tone&&`(${J.tone})`]},J.id))]})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>q(z,V.action_type_id,V.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"New Script"]}),X&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>N((j==null?void 0:j.id)===X.id?null:X),children:(j==null?void 0:j.id)===X.id?"Hide":"Preview"})]})]}),j&&(V==null?void 0:V.default_script_id)===j.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ye,{variant:"outline",children:j.title}),j.tone&&e.jsx(Ye,{variant:"secondary",children:j.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:j.script_body})]})]},z)})})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsxs(vs,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:z=>{z.preventDefault();const V=new FormData(z.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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:M.isPending,children:[M.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(fs,{open:g,onOpenChange:y,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(js,{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:z=>{z.preventDefault();const V=new FormData(z.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(ye,{htmlFor:"script_title",children:"Title"}),e.jsx(Le,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Le,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Tr,{id:"script_body",name:"script_body",rows:6,required:!0,placeholder:"Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in..."})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function Cbs({flags:t}){const{toast:s}=Ra(),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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Feature Flags"}),e.jsx(vr,{children:"Control which features are enabled for members"})]}),e.jsx(De,{children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Flag"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Notes"}),e.jsx(jt,{children:"Last Updated"})]})}),e.jsx(qn,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-mono text-sm",children:a.key}),e.jsx(ut,{children:e.jsx(qr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(ut,{children:e.jsx(Le,{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(ut,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function Mbs({items:t,isLoading:s}){const{toast:r}=Ra(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=Tt({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"]})},m=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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Popby Ideas"}),e.jsx(vr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(G,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(De,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{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(bo,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:t.map(f=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:f.name}),e.jsx(ut,{className:"text-muted-foreground",children:f.description}),e.jsx(ut,{children:e.jsx(qr,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>m(f.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Tbs(){var y;const{toast:t}=Ra(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),{data:l,isLoading:i}=pt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:_,error:w}=await H.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return _}}),{data:c,isLoading:u}=pt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:_,error:w}=await H.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return _}}),m=Tt({mutationFn:async _=>{var w,j;if(_.id){const{error:N}=await H.from("video_scripts").update({title:_.title,script_text:_.script_text,category_id:_.category_id,tags:((w=_.tags)==null?void 0:w.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:((j=_.tags)==null?void 0:j.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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Video Scripts"}),e.jsx(vr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(G,{onClick:()=>{n(null),o(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(De,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Title"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"w-24",children:"Actions"})]})}),e.jsx(qn,{children:c==null?void 0:c.map(_=>{var w;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:_.title}),e.jsx(ut,{className:"text-muted-foreground",children:((w=_.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(ut,{children:e.jsx(qr,{checked:_.is_active,onCheckedChange:()=>f(_)})}),e.jsxs(ut,{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>{n(_),o(!0)},children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>g(_.id),children:e.jsx(kr,{className:"h-4 w-4"})})]})]},_.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(vs,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const w=new FormData(_.currentTarget);m.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"title",children:"Title"}),e.jsx(Le,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"category_id",children:"Category"}),e.jsxs(Rs,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select category"})}),e.jsx(Ds,{children:l==null?void 0:l.map(_=>e.jsx(ft,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Tr,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(Le,{id:"tags",name:"tags",defaultValue:((y=r==null?void 0:r.tags)==null?void 0:y.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(Rn,{className:"mt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:m.isPending,children:[m.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Abs(){const{toast:t}=Ra(),[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(Pe,{children:e.jsx(De,{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(aa,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(vr,{children:"Configure the map feature for popbys"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Le,{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(G,{onClick:i,disabled:o,children:[o&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(Ye,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const Ebs=()=>{const[t,s]=k.useState(""),[r,n]=k.useState("grid"),a=ar(),{data:o=[],isLoading:l}=pt({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 m;return c.name.toLowerCase().includes(t.toLowerCase())||((m=c.description)==null?void 0:m.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(G,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(Tp,{className:"h-4 w-4"})}),e.jsx(G,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(nh,{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(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ws,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ws,{className:"h-5 w-3/4 mb-2"}),e.jsx(ws,{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(G,{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(Pe,{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(nn,{className:"h-8 w-8"})})}),e.jsxs(De,{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:Ode(c.description)})]})]},c.id))})]})})},Pbs=()=>{const{serviceId:t}=ao(),s=ar(),{data:r,isLoading:n}=pt({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(ws,{className:"h-8 w-48"}),e.jsx(ws,{className:"h-64 w-full rounded-lg"}),e.jsx(ws,{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(G,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Pe,{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(nn,{className:"h-16 w-16"})})})}),e.jsx(Pe,{children:e.jsxs(De,{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(fn,{className:"h-4 w-4 mr-1"}),"Published ",ds(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(G,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(rn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ms,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(G,{onClick:()=>s("/additional-services"),children:[e.jsx(Ga,{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 Ibs(){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(BM,{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(Rs,{value:t,onValueChange:s,children:[e.jsx(Ls,{className:"w-full",children:e.jsx($s,{placeholder:"Select a tool"})}),e.jsx(Ds,{children:CI.map(n=>e.jsx(ft,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ga,{value:t,onValueChange:s,className:"w-full",children:e.jsx(fa,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:CI.map(n=>e.jsx(ss,{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 m7e="agent-os-onboarding-completed",c9=[{icon:_0,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:Jh,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:ur,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:Fd,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:bo,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:co,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"]}],Lbs=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(0),[a,o]=k.useState(!1);k.useEffect(()=>{if(!localStorage.getItem(m7e)){const _=setTimeout(()=>s(!0),500);return()=>clearTimeout(_)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem(m7e,"true"),s(!1)},u=c9[r],m=u.icon,f=r===c9.length-1,g=y=>{y||c(),s(y)};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(m,{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(nn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(js,{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((y,_)=>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(ua,{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:y})]},_))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:c9.map((y,_)=>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}=Fs();return pt({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})},Obs=()=>{const t=Qt(),{user:s}=Fs();return Tt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=Ll(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"]}),kn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{kn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},Rbs=()=>{const t=Qt();return Tt({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"]}),kn({title:"Snooze cancelled"})},onError:s=>{kn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},Fbs=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function sme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=k.useState(null),l=Obs(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ds(Ll(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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(mn,{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:Fbs.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Pt("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(fn,{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(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const zbs={Crown:zm,FileText:wn,Users:ur,Globe:Nd,Star:ea,Phone:Nn,MessageSquare:Ki,PenTool:X_,Video:An,Gift:bo};function Bbs({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=ar(),[c,u]=k.useState("name"),[m,f]=k.useState("asc"),[g,y]=k.useState(null),[_,w]=k.useState(""),j=P=>{c===P?f(O=>O==="asc"?"desc":"asc"):(u(P),f("asc"))},N=k.useMemo(()=>[...t].sort((P,O)=>{var $,z;let q=0;switch(c){case"name":{const V=`${P.contact.first_name} ${P.contact.last_name||""}`.toLowerCase(),X=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();q=V.localeCompare(X);break}case"relationship_type":q=(P.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":q=((($=P.actionType)==null?void 0:$.name)||"").localeCompare(((z=O.actionType)==null?void 0:z.name)||"");break;case"last_touch":q=(P.monthNumber||0)-(O.monthNumber||0);break}return m==="asc"?q:-q}),[t,c,m]),S=P=>zbs[P||"Phone"]||Nn,M=({field:P,children:O})=>e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>j(P),children:[O,c===P?m==="asc"?e.jsx(Tu,{className:"ml-2 h-4 w-4"}):e.jsx(Yh,{className:"ml-2 h-4 w-4"}):e.jsx(wd,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(P,O,q)=>{y(P),w(`${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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[180px]",children:e.jsx(M,{field:"name",children:"Contact"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(M,{field:"relationship_type",children:"Type"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(M,{field:"action_type",children:"Action"})}),e.jsx(jt,{className:"w-[130px]",children:"Phone"}),e.jsx(jt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(qn,{children:N.map((P,O)=>{var Y,J,Q,ce,ne,re;const q=P.isSpecialDate,$=P.specialDateType,z=q?$==="birthday"?Eh:xn:S(((Y=P.actionType)==null?void 0:Y.icon)||null),V=P.contact.phone,X=P.contact.email;return e.jsxs(ks,{className:Pt("hover:bg-muted/50 transition-colors",q&&$==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",q&&$==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(ut,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${P.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[P.contact.first_name," ",P.contact.last_name]})})}),e.jsx(ut,{children:P.relationshipTypeName?e.jsx(Ye,{variant:"secondary",className:"text-xs",children:P.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:q?e.jsx(Ye,{className:Pt("gap-1",$==="birthday"&&"bg-pink-500 hover:bg-pink-600",$==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:$==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Eh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(xn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(z,{className:"h-3 w-3"}),(J=P.actionType)==null?void 0:J.name]})})}),e.jsx(ut,{children:V?e.jsx("span",{className:"text-sm font-mono",children:P.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${P.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(P.contact.phone,(Q=P.script)==null?void 0:Q.script_body,P.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(Ki,{className:"h-3.5 w-3.5"})}),X&&(l?e.jsx("button",{onClick:()=>l({id:P.contact.id,first_name:P.contact.first_name,last_name:P.contact.last_name,email:P.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(rr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(P.contact.email,(ce=P.script)==null?void 0:ce.script_body,(ne=P.script)==null?void 0:ne.email_subject,(re=P.actionType)==null?void 0:re.name,P.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(rr,{className:"h-3.5 w-3.5"})})),q&&e.jsxs("button",{onClick:()=>{const oe=`${P.contact.first_name}${P.contact.last_name?" "+P.contact.last_name:""}`,he=$==="birthday"?"birthday":"home_anniversary",xe=new URLSearchParams({cardType:he,contactId:P.contact.id,name:oe,...P.contact.address?{address:P.contact.address}:{},...$==="anniversary"&&P.contact.home_anniversary?{date:P.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${xe.toString()}`)},className:Pt("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",$==="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 ${$==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(rr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>I(P.contact.id,P.contact.first_name,P.contact.last_name),title:"Snooze",children:e.jsx(Ih,{className:"h-3.5 w-3.5"})}),e.jsxs(G,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var oe;return s(P.contact.id,P.actionType.id,(oe=P.script)==null?void 0:oe.id)},disabled:n,children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${P.contact.id}-${O}`)})})]})}),e.jsx(sme,{open:!!g,onOpenChange:P=>!P&&y(null),contactId:g||"",contactName:_})]})}function Ff(){const{data:t,isLoading:s}=pt({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 $bs({onSelect:t}){const[s,r]=k.useState(null),{data:n=[],isLoading:a}=pt({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}=pt({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:m}=await c;if(m)throw m;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(ys,{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(tl,{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(ys,{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(Li,{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(Ye,{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 vSe(){var a;const{user:t}=Fs(),{data:s,isLoading:r}=pt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,m,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())||((m=c==null?void 0:c.email)==null?void 0:m.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 qbs=5*1024*1024,Lv=50,Ubs=["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 Vbs(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function Hbs(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 Vb(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 X1({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Fs(),u=Qt(),{isReady:m,settings:f}=vSe(),g=!!n&&n.length>0,y=g&&m,_=g?n:r?[r]:[],w=_[0],j=g?Math.ceil(_.length/Lv):1,N=g&&_.length>Lv,[S,M]=k.useState((w==null?void 0:w.email)||""),[I,P]=k.useState(a),[O,q]=k.useState(o),[$,z]=k.useState(!1),[V,X]=k.useState(!1),[Y,J]=k.useState([]),[Q,ce]=k.useState(a),[ne,re]=k.useState(o),[oe,he]=k.useState("composing"),[xe,ue]=k.useState(0),[ge,_e]=k.useState(0),[Be,Se]=k.useState(0),[Ee,Ae]=k.useState(0),Me=k.useRef(!1),[ke,Oe]=k.useState(null);k.useEffect(()=>{t&&(M((w==null?void 0:w.email)||""),ce(a),re(o),P(Vb(a,w||{first_name:""})),q(Vb(o,w||{first_name:""})),X(!a&&!o),J([]),he("composing"),ue(0),_e(0),Se(0),Ae(0),Me.current=!1,Oe(null))},[t,w,a,o]);const qe=async tt=>{const Ke=tt.target.files;if(!Ke)return;const rt=Y.reduce((It,Vt)=>It+Vt.size,0),it=[];for(const It of Array.from(Ke)){if(!Ubs.includes(It.type)){me.error(`${It.name}: Unsupported file type`);continue}if(rt+It.size>qbs){me.error("Total attachments exceed 5MB limit");break}try{const Vt=await Hbs(It);it.push({name:It.name,type:It.type,size:It.size,data:Vt})}catch{me.error(`Failed to read ${It.name}`)}}J(It=>[...It,...it]),tt.target.value=""},ve=tt=>{J(Ke=>Ke.filter((rt,it)=>it!==tt))},dt=tt=>{ce(tt.subject),re(tt.body),P(Vb(tt.subject,w||{first_name:""})),q(Vb(tt.body,w||{first_name:""})),X(!1)},pe=tt=>tt.split(/\n\n+/).map(Ke=>`

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

`).join(""),Ue=async tt=>{const Ke=Vb(Q,tt),rt=Vb(ne,tt),it=pe(rt);try{if(y){const It=(f==null?void 0:f.display_name)||"ReLevelUp",Vt=`${It.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,hs=`${It} <${Vt}>`,{data:Es,error:Ts}=await H.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:tt.email,from_email:hs,subject:Ke,body_html:it,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Ts)throw Ts;if(!(Es!=null&&Es.success))throw new Error((Es==null?void 0:Es.error)||"Failed to send")}else{const{data:It,error:Vt}=await H.functions.invoke("gmail-send",{body:{to:tt.email,subject:Ke,body:it,contactId:tt.id,attachments:Y.map(({name:hs,type:Es,data:Ts})=>({name:hs,type:Es,data:Ts}))}});if(Vt)throw Vt;if(!(It!=null&&It.success))throw new Error((It==null?void 0:It.error)||"Failed to send")}return c&&await H.from("bulk_email_sends").insert({user_id:c.id,contact_id:tt.id,contact_email:tt.email,subject:Ke,source:y?"ses_bulk":"sphere_gaps"}),!0}catch(It){return console.error("Send error:",It),me.error("Failed to send to "+tt.first_name+": "+(It instanceof Error?It.message:"Unknown error")),!1}},Xe=()=>{const tt=xe*Lv;return _.slice(tt,tt+Lv)},et=async()=>{if(!I||!O){me.error("Please fill in subject and message");return}const tt=Xe();z(!0),he("sending");let Ke=0,rt=0;for(let It=0;ItsetTimeout(hs,150));_e(It=>It+Ke),Se(It=>It+rt),z(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),xe>=j-1||Me.current?he("all_done"):he("batch_complete")},Ce=async()=>{if(!I||!O){me.error("Please fill in subject and message");return}if(!g){z(!0);const tt=await Ue(w);z(!1),tt&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await et()},Je=async()=>{ue(tt=>tt+1),Ae(0),await new Promise(tt=>setTimeout(tt,50)),await et()};k.useEffect(()=>{},[xe]);const Ge=()=>{if($){Me.current=!0;return}s(!1),i==null||i()},lt=xe*Lv,He=Math.min(lt+Lv,_.length),We=g&&_.length>0?Math.round((ge+Be)/_.length*100):0;return e.jsx(fs,{open:t,onOpenChange:Ge,children:e.jsxs(ps,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:`h-5 w-5 ${y?"text-orange-500":"text-red-500"}`}),g?`Send to ${_.length} Contacts`:"Compose Email"]}),y?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&&oe==="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."]})]}),oe==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ys,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",xe+1," of ",j,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ee," of ",Xe().length," in this batch"]})]}),e.jsx(qi,{value:Ee/Xe().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",ge+Be," / ",_.length]}),e.jsxs("span",{children:[ge," sent • ",Be," failed"]})]}),e.jsx(G,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Me.current=!0},children:"Stop Sending"})]}),oe==="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 ",xe+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[ge," sent, ",Be," failed so far"]})]}),e.jsx(qi,{value:We,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[_.length-ge-Be," contacts remaining (",j-xe-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",className:"flex-1",onClick:Ge,children:"Done for Now"}),e.jsxs(G,{className:"flex-1 gap-2",onClick:Je,children:[e.jsx(Fn,{className:"h-4 w-4"}),"Send Next ",Math.min(Lv,_.length-He)," Contacts"]})]})]}),oe==="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:[ge," emails sent successfully",Be>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Be," failed"]})]})]}),e.jsx(G,{className:"w-full",onClick:Ge,children:"Close"})]}),oe==="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(wn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Er,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx($bs,{onSelect:dt})]}):e.jsxs(G,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>X(!0),children:[e.jsx(wn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(Qo,{}),!g&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"gmail-to",children:"To"}),e.jsx(Le,{id:"gmail-to",value:S,onChange:tt=>M(tt.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Le,{id:"gmail-subject",value:I,onChange:tt=>{P(tt.target.value),ce(tt.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(ye,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(tt=>tt+"{{first_name}}"),re(tt=>tt+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(Ye,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(tt=>tt+"{{last_name}}"),re(tt=>tt+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Tr,{id:"gmail-body",value:O,onChange:tt=>{q(tt.target.value),re(tt.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(G,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var tt;return(tt=document.getElementById("gmail-attachments"))==null?void 0:tt.click()},disabled:$,children:[e.jsx(bS,{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:qe})]}),Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((tt,Ke)=>e.jsxs(Ye,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(bS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:tt.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",Vbs(tt.size),")"]}),e.jsx("button",{type:"button",onClick:()=>ve(Ke),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Er,{className:"h-3 w-3"})})]},Ke))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),g?e.jsxs(G,{onClick:()=>{Oe(_[0]||null),he("reviewing")},disabled:!I||!O,className:"gap-2",children:["Review Emails",e.jsx(ba,{className:"h-4 w-4"})]}):e.jsxs(G,{onClick:Ce,disabled:$||!I||!O,className:"gap-2",children:[$?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"}),$?"Sending...":"Send Email"]})]})]}),oe==="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 ",j," batches of up to ",Lv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{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(tt=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(ke==null?void 0:ke.id)===tt.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Oe(tt),children:[tt.first_name," ",tt.last_name," — ",tt.email]},tt.id))})]}),ke&&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(rr,{className:"h-3.5 w-3.5"}),"Preview for ",ke.first_name," ",ke.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:"})," ",ke.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",Vb(Q,ke)]})]}),e.jsx(Qo,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:Vb(ne,ke)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(G,{variant:"outline",onClick:()=>{he("composing"),Oe(null)},children:[e.jsx(Ga,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(G,{onClick:Ce,disabled:$,className:"gap-2",children:[$?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"}),N?`Send First ${Lv}`:`Send to ${_.length}`]})]})]})]})})}function Gbs(){const t=ar(),{data:s}=nm(),{data:r}=nR(),n=BNe(),{isGmailConnected:a,gmailEmail:o}=Ff(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[m,f]=k.useState(new Set),g=Um(new Date),y=Ll(g,30),_=I=>{if(!I)return null;const P=I.split(/[-/T]/);if(P.length<3)return null;const O=parseInt(P[1],10)-1,q=parseInt(P[2],10);return isNaN(O)||isNaN(q)?null:new Date(g.getFullYear(),O,q)},w=k.useMemo(()=>{if(!s)return[];const I=[];for(const P of s){if(P.birthday){const O=_(P.birthday);O&&(Tl(O,g)||t3(O,g)&&s3(O,y))&&I.push({contact:P,type:"birthday",date:O,daysUntil:ff(O,g),dateStr:P.birthday})}if(P.home_anniversary){const O=_(P.home_anniversary);O&&(Tl(O,g)||t3(O,g)&&s3(O,y))&&I.push({contact:P,type:"anniversary",date:O,daysUntil:ff(O,g),dateStr:P.home_anniversary})}}return I.sort((P,O)=>P.daysUntil-O.daysUntil),I},[s]),j=async I=>{const P=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(P)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:P.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(O=>new Set(O).add(`${I.contact.id}-${I.type}`)),kn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{kn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=I=>{const P=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,O=I.type==="birthday"?"birthday":"home_anniversary",q=new URLSearchParams({cardType:O,contactId:I.contact.id,name:P,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${q.toString()}`)},S=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,M=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Fd,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(Ye,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.length," event",w.length!==1?"s":""]})]})}),e.jsxs(De,{className:"space-y-2",children:[w.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Eh,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),w.map((I,P)=>{var z,V;const O=`${I.contact.id}-${I.type}`,q=m.has(O),$=`${((z=I.contact.first_name)==null?void 0:z[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:Pt("p-3 rounded-lg border transition-colors",I.daysUntil===0&&I.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":I.daysUntil===0&&I.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":I.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(Cn,{className:Pt("h-10 w-10",I.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(Mn,{className:Pt("text-xs font-medium",I.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:$})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:I.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[I.contact.first_name," ",I.contact.last_name||""]}),e.jsx(Ye,{variant:"outline",className:Pt("text-[10px] shrink-0 whitespace-nowrap",M(I.daysUntil)),children:S(I.daysUntil)})]}),e.jsxs("div",{className:Pt("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Eh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(xn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ds(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${I.contact.phone}`,children:e.jsx(Nn,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${I.contact.phone}`,children:e.jsx(Ki,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),u(!0)):window.location.href=`mailto:${I.contact.email}`},children:e.jsx(rr,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${I.contact.id}`),children:e.jsx(An,{className:"h-3.5 w-3.5"})}),e.jsxs(G,{variant:"ghost",size:"sm",className:Pt("h-7 px-2 gap-1 text-xs",I.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${I.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>N(I),children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(G,{variant:"ghost",size:"icon",className:Pt("h-7 w-7",q&&"text-green-600"),title:"Log a touch",disabled:q||n.isPending,onClick:()=>j(I),children:e.jsx(sa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(Tn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${P}`)})]})]}),a&&l&&e.jsx(X1,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}function Wbs(t){const[s,r]=k.useState([]),[n,a]=k.useState(!1),{data:o,isLoading:l}=pt({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await H.rpc("cleanup_stale_visitors")}catch{}const{data:m}=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(!m)return[];const f=m.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(w=>{g[w.id]=w})}const y=m.map(_=>_.auth_user_id).filter(Boolean);if(y.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",y);(_||[]).forEach(w=>{const j=m.find(N=>N.auth_user_id===w.user_id);j&&!j.contact_id&&w.contact_id&&(j.contact_id=w.contact_id),j&&!g[j.contact_id||""]&&w.name&&(g[j.contact_id||j.auth_user_id||""]={first_name:w.name.split(" ")[0],last_name:w.name.split(" ").slice(1).join(" ")||null,email:null,phone:w.phone})})}return m.map(_=>{var w,j;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:((w=g[_.contact_id||_.auth_user_id||""])==null?void 0:w.email)||null,contact_phone:((j=g[_.contact_id||_.auth_user_id||""])==null?void 0:j.phone)||null}})},enabled:!!t,refetchInterval:6e4});k.useEffect(()=>{if(!t)return;const m=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(y=>y.id===f.new.id?{...y,...f.new}:y)):f.eventType==="DELETE"&&r(g=>g.filter(y=>y.id!==f.old.id))}).subscribe(f=>{f==="SUBSCRIBED"&&a(!0)});return()=>{H.removeChannel(m)}},[t]);const i=n&&s.length>0?Kbs([...s,...o||[]]):o||[],c=Date.now(),u=i.filter(m=>c-new Date(m.last_seen_at).getTime()<2*60*1e3);return{activeVisitors:u,isLoading:l,count:u.length}}function Kbs(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const Zbs={property_view:{label:"Viewed",icon:Tn,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:El,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:Ja,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function Ybs(){const{user:t}=Fs(),s=ar(),{isGmailConnected:r,gmailEmail:n}=Ff(),{leadSite:a}=vE(),{count:o}=Wbs(a==null?void 0:a.id),[l,i]=k.useState(!1),[c,u]=k.useState(null),{data:m,isLoading:f}=pt({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||!(m!=null&&m.has_site))return null;const g=(m.activities||[]).filter(N=>N.visitor_name&&N.visitor_name!=="Site Visitor"),y=g.filter(N=>N.activity_type==="new_lead"),_=(m.activities||[]).filter(N=>N.activity_type==="property_view").length,w=(m.activities||[]).filter(N=>N.activity_type==="saved_listing").length,j=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(Nd,{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(G,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(ba,{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(El,{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:y.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(Tn,{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(Ja,{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:w}),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=Zbs[N.activity_type],I=M.icon,P=ql(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(I,{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:["· ",P]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[N.visitor_email&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>j(N),children:e.jsx(rr,{className:"h-3.5 w-3.5"})}),N.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${N.visitor_phone}`,children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${N.visitor_phone}`,children:e.jsx(Ki,{className:"h-3.5 w-3.5"})})]}),N.contact_id&&e.jsx(G,{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(G,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",g.length-5," more activities",e.jsx(ba,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Pe,{children:e.jsxs(De,{className:"p-6 text-center",children:[e.jsx(Mh,{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(G,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(ba,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&c&&e.jsx(X1,{open:l,onOpenChange:i,contact:c,gmailEmail:n})]})}const p7e={Crown:zm,FileText:wn,Users:ur,Globe:Nd,Star:ea,Phone:Nn,MessageSquare:Ki,PenTool:X_,Video:An,Gift:bo},Qbs={"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 Xbs(){var Ge,lt,He,We,tt,Ke;const t=ar(),{user:s}=Fs(),{data:r}=Rf(),{data:n}=LQe(),{data:a}=nm(),{data:o}=nR(),{data:l}=zQe(),i=r8t(),c=$Ne(),u=t8t(90),m=BNe(),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(!1),[N,S]=k.useState(""),[M,I]=k.useState(!1),[P,O]=k.useState(""),[q,$]=k.useState(lle()),[z,V]=k.useState("cards"),[X,Y]=k.useState(!1),[J,Q]=k.useState(null),[ce,ne]=k.useState(null),[re,oe]=k.useState(""),{isGmailConnected:he,gmailEmail:xe}=Ff(),ue=()=>{const rt=parseInt(P,10);if(isNaN(rt)||rt<1){kn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}$(rt),FQe(rt),I(!1),kn({title:"Goal updated",description:`Weekly touch goal set to ${rt}`})},ge=()=>{O(q.toString()),I(!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=Um(new Date),Be=Ll(_e,7),Se=rt=>{if(!rt)return null;const it=rt.split(/[-/T]/);if(it.length<3)return null;const It=parseInt(it[1],10)-1,Vt=parseInt(it[2],10);return isNaN(It)||isNaN(Vt)?null:new Date(_e.getFullYear(),It,Vt)},Ee=(a==null?void 0:a.filter(rt=>{const it=Se(rt.birthday),It=Se(rt.home_anniversary);return it&&Tl(it,_e)||It&&Tl(It,_e)}))||[];a!=null&&a.filter(rt=>{if(!rt.birthday&&!rt.home_anniversary)return!1;const it=It=>{if(!It)return!1;const Vt=Se(It);return Vt?t3(Vt,_e)&&s3(Vt,Be):!1};return it(rt.birthday)||it(rt.home_anniversary)}).slice(0,5);const Ae=[],Me=(o==null?void 0:o.find(rt=>rt.name==="Call"))||(o==null?void 0:o[0]);for(const rt of Ee){const it=Se(rt.birthday),It=Se(rt.home_anniversary),Vt=it&&Tl(it,_e),hs=It&&Tl(It,_e);Vt&&Ae.push({contact:rt,actionType:Me||{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:((He=(lt=(Ge=rt.tags)==null?void 0:Ge[0])==null?void 0:lt.relationship_type)==null?void 0:He.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),hs&&Ae.push({contact:rt,actionType:Me||{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:((Ke=(tt=(We=rt.tags)==null?void 0:We[0])==null?void 0:tt.relationship_type)==null?void 0:Ke.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Oe=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((rt,it)=>{var Vt,hs,Es;const It=o==null?void 0:o[it%((o==null?void 0:o.length)||1)];return It?{contact:rt,actionType:It,planName:"Quick Touch",relationshipTypeName:((Es=(hs=(Vt=rt.tags)==null?void 0:Vt[0])==null?void 0:hs.relationship_type)==null?void 0:Es.name)||"",monthNumber:0}:null}).filter(Boolean))||[],qe=[...Ae,...Oe],ve=async(rt,it,It)=>{await m.mutateAsync({contactId:rt,actionTypeId:it,scriptUsedId:It}),j(!1),_(null)},dt=rt=>{rt.script?(_(rt),j(!0)):ve(rt.contact.id,rt.actionType.id)},pe=rt=>p7e[rt||"Phone"]||Nn,Ue=rt=>p7e[rt||"Users"]||ur,Xe=(rt,it)=>rt.replace(/\{\{FirstName\}\}/g,it.first_name).replace(/\{\{LastName\}\}/g,it.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),et=(rt,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}`})[rt]||`Hello ${it}!`,Ce=(rt,it,It)=>{const Vt=`sms:${rt}`;if(it&&It){const hs=Xe(it,It);return`${Vt}?body=${encodeURIComponent(hs)}`}return Vt},Je=(rt,it,It,Vt,hs)=>{const Es=`mailto:${rt}`,Ts=[];if(hs){const cr=It||et(Vt||"Email",hs.first_name);if(Ts.push(`subject=${encodeURIComponent(cr)}`),it){const zr=Xe(it,hs);Ts.push(`body=${encodeURIComponent(zr)}`)}}return Ts.length>0?`${Es}?${Ts.join("&")}`:Es};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(Ybs,{}),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(rt=>rt.active).map(rt=>{const it=Ue(rt.icon),It=(n==null?void 0:n[rt.id])||0,Vt=f===rt.id,hs=Qbs[rt.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Vt?(g(null),t("/mission-control/contacts")):(g(rt.id),t(`/mission-control/contacts?type=${rt.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:rt.name}),e.jsxs("div",{className:`text-sm ${Vt?"opacity-90":"text-muted-foreground"}`,children:[It," Contacts"]})]})]},rt.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(G,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(_u,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(G,{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(G,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(G,{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(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(nn,{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(G,{variant:z==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(Tp,{className:"h-4 w-4"})}),e.jsx(G,{variant:z==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(nh,{className:"h-4 w-4"})})]})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-4",children:qe.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(G,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):z==="table"?e.jsx(Bbs,{actions:qe,onMarkComplete:ve,onViewScript:dt,isLoading:m.isPending,buildSmsLink:Ce,buildEmailLink:Je,onGmailCompose:he?rt=>{Q(rt),Y(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[qe.map((rt,it)=>{var Ft,Ps,yr,Is,Ar,tn,na;const It=rt.isSpecialDate,Vt=rt.specialDateType,hs=It?Vt==="birthday"?Eh:xn:pe(((Ft=rt.actionType)==null?void 0:Ft.icon)||null),Es=rt.contact.phone,Ts=rt.contact.email,cr=It?Vt==="birthday"?"#EC4899":"#8B5CF6":((Ps=rt.actionType)==null?void 0:Ps.color)||"#3B82F6",zr=It?Vt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(yr=rt.actionType)==null?void 0:yr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${It?"ring-2 ring-offset-2":""}`,style:It?{"--tw-ring-color":cr}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:cr},children:[e.jsx(hs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:zr})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${rt.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[rt.contact.first_name," ",rt.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Es&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${rt.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(Nn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ce(rt.contact.phone,(Is=rt.script)==null?void 0:Is.script_body,rt.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(Ki,{className:"h-3 w-3"}),"Text"]})]}),Ts&&(he?e.jsxs("button",{onClick:()=>{Q({id:rt.contact.id,first_name:rt.contact.first_name,last_name:rt.contact.last_name,email:rt.contact.email}),Y(!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(rr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:Je(rt.contact.email,(Ar=rt.script)==null?void 0:Ar.script_body,(tn=rt.script)==null?void 0:tn.email_subject,(na=rt.actionType)==null?void 0:na.name,rt.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(rr,{className:"h-3 w-3"}),"Email"]}))]}),It&&e.jsxs("button",{onClick:()=>{const Ln=`${rt.contact.first_name}${rt.contact.last_name?" "+rt.contact.last_name:""}`,tr=Vt==="birthday"?"birthday":"home_anniversary",dr=new URLSearchParams({cardType:tr,contactId:rt.contact.id,name:Ln,...rt.contact.address?{address:rt.contact.address}:{},...Vt==="anniversary"&&rt.contact.home_anniversary?{date:rt.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${dr.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(rr,{className:"h-3 w-3"}),"Send ",Vt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Es&&!Ts&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[rt.relationshipTypeName&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:rt.relationshipTypeName}),rt.monthNumber>0&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:["Month ",rt.monthNumber]})]}),rt.script&&e.jsx(G,{size:"sm",variant:"outline",className:"w-full",onClick:()=>dt(rt),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(G,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ne(rt.contact.id),oe(`${rt.contact.first_name} ${rt.contact.last_name||""}`.trim())},children:[e.jsx(Ih,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(G,{size:"sm",className:"flex-1",onClick:()=>{var Ln;return ve(rt.contact.id,rt.actionType.id,(Ln=rt.script)==null?void 0:Ln.id)},disabled:m.isPending,children:"Mark Complete"})]})]})]},rt.contact.id+it)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{variant:"ghost",className:"h-full w-full",children:[e.jsx(bx,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Ud,{children:e.jsx(La,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:M,onOpenChange:I,children:[e.jsx(Oi,{asChild:!0,children:e.jsx("button",{onClick:ge,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(el,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{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(ye,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Le,{id:"weekly-goal-ic",type:"number",min:"1",value:P,onChange:rt=>O(rt.target.value),placeholder:"20",onKeyDown:rt=>{rt.key==="Enter"&&ue()}})]}),e.jsx(G,{onClick:ue,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(qi,{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(rh,{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(mn,{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(eXe,{}),e.jsx(Gbs,{})]})]}),e.jsx(fs,{open:w,onOpenChange:j,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(vs,{className:"flex items-center gap-2",children:y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:y.actionType.color||"#3B82F6"}}),y.actionType.name," Script"]})})}),y&&y.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:[y.contact.first_name," ",y.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:Xe(y.script.script_body,y.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",className:"flex-1",onClick:()=>j(!1),children:"Close"}),e.jsx(G,{className:"flex-1",onClick:()=>{var rt;return ve(y.contact.id,y.actionType.id,(rt=y.script)==null?void 0:rt.id)},disabled:m.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(Lbs,{})]}),he&&J&&e.jsx(X1,{open:X,onOpenChange:Y,contact:J,gmailEmail:xe}),e.jsx(sme,{open:!!ce,onOpenChange:rt=>!rt&&ne(null),contactId:ce||"",contactName:re})]})}var Jat="Toggle",bSe=k.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=lh({prop:r,onChange:a,defaultProp:n??!1,caller:Jat});return e.jsx(cn.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Or(t.onClick,()=>{t.disabled||i(!l)})})});bSe.displayName=Jat;var eit=bSe,Zw="ToggleGroup",[tit]=od(Zw,[Ow]),sit=Ow(),_Se=mt.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(Jbs,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(e_s,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Zw}\``)});_Se.displayName=Zw;var[rit,nit]=tit(Zw),Jbs=mt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=lh({prop:r,defaultProp:n??"",onChange:a,caller:Zw});return e.jsx(rit,{scope:t.__scopeToggleGroup,type:"single",value:mt.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:mt.useCallback(()=>i(""),[i]),children:e.jsx(ait,{...o,ref:s})})}),e_s=mt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=lh({prop:r,defaultProp:n??[],onChange:a,caller:Zw}),c=mt.useCallback(m=>i((f=[])=>[...f,m]),[i]),u=mt.useCallback(m=>i((f=[])=>f.filter(g=>g!==m)),[i]);return e.jsx(rit,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(ait,{...o,ref:s})})});_Se.displayName=Zw;var[t_s,s_s]=tit(Zw),ait=mt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=sit(r),m=Dw(l),f={role:"group",dir:m,...c};return e.jsx(t_s,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Kde,{asChild:!0,...u,orientation:o,dir:m,loop:i,children:e.jsx(cn.div,{...f,ref:s})}):e.jsx(cn.div,{...f,ref:s})})}),ide="ToggleGroupItem",iit=mt.forwardRef((t,s)=>{const r=nit(ide,t.__scopeToggleGroup),n=s_s(ide,t.__scopeToggleGroup),a=sit(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},c=mt.useRef(null);return n.rovingFocus?e.jsx(Zde,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(f7e,{...i,ref:s})}):e.jsx(f7e,{...i,ref:s})});iit.displayName=ide;var f7e=mt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=nit(ide,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(bSe,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),oit=_Se,lit=iit;const cit=S3("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"}}),r_s=k.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(eit,{ref:a,className:Pt(cit({variant:s,size:r,className:t})),...n}));r_s.displayName=eit.displayName;const dit=k.createContext({size:"default",variant:"default"}),uit=k.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(oit,{ref:o,className:Pt("flex items-center justify-center gap-1",t),...a,children:e.jsx(dit.Provider,{value:{variant:s,size:r},children:n})}));uit.displayName=oit.displayName;const hit=k.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=k.useContext(dit);return e.jsx(lit,{ref:o,className:Pt(cit({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});hit.displayName=lit.displayName;const n_s=[{value:"bidirectional",label:"Two-Way",icon:wd,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Tu,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Yh,tooltip:"Only pull BoldTrail → Agent OS"}];function ewe({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(uit,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:n_s.map(a=>e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(hit,{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(sc,{children:a.tooltip})]},a.value))})]})}function a_s(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(0),w=k.useRef(!1),{data:j}=pt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:z,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(V)throw V;return z}}),N=(j==null?void 0:j.sync_direction)||"bidirectional",S=u??N,M=Tt({mutationFn:async()=>{const{data:z,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(V)throw V;if(z!=null&&z.error)throw new Error(z.error);return z},onSuccess:z=>{m(null),a(z),r(!0)},onError:z=>{me.error(z.message||"Failed to generate sync preview")}}),I=Tt({mutationFn:async()=>{w.current=!1,g("Initializing sync..."),_(5);const{data:z,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(V)throw V;if(z!=null&&z.error)throw new Error(z.error);const X=z;let Y=X.sync_log_id,J=X.next_phase,Q=X.next_offset;const ce=X.push_total||0,ne=X.pull_total||0,re=X.update_total||0,oe=ce+ne+re;let he=0,xe=0,ue=0;for(;J!=="finalize"&&!w.current;){J==="push"?(g(`Pushing contacts to BoldTrail... (${he}/${ce})`),_(oe>0?he/oe*90:0)):J==="pull"?(g(`Pulling contacts from BoldTrail... (${xe}/${ne})`),_(oe>0?(ce+xe)/oe*90:0)):J==="update"&&(g(`Updating existing contacts... (${ue}/${re})`),_(oe>0?(ce+ne+ue)/oe*90:0));const{data:Be,error:Se}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:J,offset:Q,sync_log_id:Y,sync_direction:S}});if(Se)throw Se;if(Be!=null&&Be.error)throw new Error(Be.error);const Ee=Be;he+=Ee.chunk_pushed||0,xe+=Ee.chunk_pulled||0,ue+=Ee.chunk_updated||0,Ee.progress&&g(Ee.progress),J=Ee.next_phase,Q=Ee.next_offset}g("Finalizing sync..."),_(95);const{data:ge,error:_e}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Y,sync_direction:S}});if(_e)throw _e;return _(100),ge},onSuccess:z=>{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 ${z.contacts_pushed||0}`,`pulled ${z.contacts_pulled||0}`,`updated ${z.contacts_updated||0}`,`skipped ${z.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${V.join(", ")}.`)},onError:z=>{g(null),_(0),me.error(z.message||"Sync failed")}});if(!(j!=null&&j.connected))return null;const P=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,$=P>0||O>0||q>0;return e.jsxs(e.Fragment,{children:[e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"outline",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,className:"shrink-0",children:M.isPending?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(wd,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(sc,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:z=>{I.isPending||r(z)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(wd,{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(ewe,{value:S,onChange:m,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:P}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Tu,{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(Yh,{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(tT,{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(ur,{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(tT,{className:"h-3 w-3 inline mr-1"}),q," contacts have missing fields that will be filled from the other system"]}),P>0&&e.jsxs(bf,{open:o,onOpenChange:l,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tu,{className:"h-3 w-3 text-emerald-600"}),P," contacts to push to BoldTrail"]}),e.jsx(Ji,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(wf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map((z,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:z.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:z.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(bf,{open:i,onOpenChange:c,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yh,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Ji,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(wf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map((z,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:z.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:z.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"]})]})})]}),!$&&!I.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(qi,{value:y||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(G,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(G,{onClick:()=>I.mutate(),disabled:I.isPending||!$,className:"gap-2",children:[I.isPending?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(wd,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const i_s=()=>{const{user:t}=Fs();return pt({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})},rme=t=>{const{user:s}=Fs();return pt({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})},wSe=()=>{const{user:t}=Fs();return pt({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})},mit=()=>{const{user:t}=Fs();return pt({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})},o_s=()=>{const{data:t}=nm(),{data:s}=Rf(),{data:r}=rme(),{data:n}=mit(),{data:a}=wSe(),o=new Map;r==null||r.forEach(m=>{const f=o.get(m.contact_id);(!f||new Date(m.completed_at)>new Date(f))&&o.set(m.contact_id,m.completed_at)});const l=new Map;a==null||a.forEach(m=>l.set(m.relationship_type_id,m.frequency_days));const i=new Map;n==null||n.filter(m=>m.is_active).forEach(m=>{i.set(m.contact_id,m.frequency_days)});const c=Um(new Date);return(t||[]).map(m=>{let f=90;if(i.has(m.id))f=i.get(m.id);else if(m.tags&&m.tags.length>0){const j=m.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);j.length>0&&(f=Math.min(...j))}const g=o.get(m.id)||null,y=g?dy(c,Um(new Date(g))):null,_=y===null||y>=f,w=_&&y!==null?y-f:0;return{...m,lastPopby:g,daysSinceLastPopby:y,frequencyDays:f,isDue:_,daysOverdue:w}}).sort((m,f)=>f.daysOverdue-m.daysOverdue)},pit=()=>o_s().filter(s=>s.isDue),l_s=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]}),kn({title:"Popby item created!"})},onError:r=>{kn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},c_s=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]}),kn({title:"Popby logged!"})},onError:r=>{kn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},d_s=()=>{const t=Qt(),{user:s}=Fs();return Tt({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"]}),kn({title:"Frequency updated!"})},onError:r=>{kn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},u_s=()=>{const{data:t}=rme(30),s=pit(),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 h_s(){const{user:t}=Fs();return pt({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 fit(t){const{data:s}=h_s(),{data:r}=mit(),{data:n}=wSe(),{data:a}=Dbs();return k.useMemo(()=>{const o=a==null?void 0:a.find(j=>j.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Um(new Date);if(l&&!s3(l,i))return{nextTouchDate:l,daysUntil:dy(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(j=>j.contact_id===t.id))||[]).sort((j,N)=>new Date(N.completed_at).getTime()-new Date(j.completed_at).getTime())[0],m=u?new Date(u.completed_at):null;let f=90;const g=r==null?void 0:r.find(j=>j.contact_id===t.id&&j.is_active);if(g)f=g.frequency_days;else if(t.tags&&t.tags.length>0){const j=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);j.length>0&&(f=Math.min(...j))}if(!m)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const y=Ll(Um(m),f),_=dy(y,i);let w;return _<0?w="overdue":_<=7?w="due-soon":w="on-track",{nextTouchDate:y,daysUntil:_,status:w,frequencyDays:f,lastTouchDate:m,snoozedUntil:null}},[t,s,r,n,a])}function twe({contact:t}){const s=fit(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:ul,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:mn,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:Ih,text:`Snoozed until ${ds(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:fn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(Ye,{variant:n.variant,className:Pt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function m_s({contact:t,onLogTouch:s,onSnooze:r}){const n=fit(t),a=Rbs(),[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(ul,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(mn,{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(Ih,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(fn,{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"}},m=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:Pt("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ds(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:"})," ",ds(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:"})," ",ds(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(G,{size:"sm",variant:"outline",className:"flex-1",onClick:m,disabled:a.isPending,children:[e.jsx(Er,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(G,{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(G,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(Ih,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(G,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(sme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Eye=768;function UE(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Eye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function p_s(){const{user:t}=Fs(),{hasLeadSite:s,leadSite:r}=vE(),{data:n,isLoading:a}=pt({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 f_s={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"}},x_s={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 R8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=f_s[t.status],l=x_s[n],i=e.jsxs("div",{className:Pt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Pt("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(W1,{children:e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:i}),e.jsx(sc,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:Pt("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(qi,{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 g_s=[{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}],d9=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]},y_s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Fs(),{toast:o}=Ra(),l=k.useRef(null),[i,c]=k.useState("upload"),[u,m]=k.useState([]),[f,g]=k.useState([]),[y,_]=k.useState({}),[w,j]=k.useState([]),[N,S]=k.useState([]),[M,I]=k.useState(!1),[P,O]=k.useState(null),q=()=>{c("upload"),m([]),g([]),_({}),j([]),S([]),O(null),l.current&&(l.current.value="")},$=()=>{q(),s(!1)},z=xe=>{const ue=xe.split(` `).map(Se=>Se.trim()).filter(Se=>Se);if(ue.length===0)return{headers:[],data:[]};const ge=Se=>{const Ee=[];let Ae="",Me=!1;for(let ke=0;ke{var _e;const ue=(_e=xe.target.files)==null?void 0:_e[0];if(!ue)return;const ge=new FileReader;ge.onload=Be=>{var ke;const Se=(ke=Be.target)==null?void 0:ke.result,{headers:Ee,data:Ae}=z(Se);if(Ee.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}m(Ee),g(Ae);const Me={};Ee.forEach(Oe=>{const qe=Oe.toLowerCase().replace(/[_\s-]/g,"");qe.includes("firstname")||qe==="first"?Me.first_name=Oe:qe.includes("lastname")||qe==="last"?Me.last_name=Oe:qe.includes("spouse")&&qe.includes("email")?Me.spouse_email=Oe:qe.includes("spouse")||qe.includes("partner")?Me.spouse_name=Oe:qe.includes("email")?Me.email=Oe:qe.includes("phone")||qe.includes("mobile")||qe.includes("cell")?Me.phone=Oe:qe.includes("address")||qe.includes("street")?Me.address=Oe:qe==="city"?Me.city=Oe:qe==="state"||qe==="province"?Me.state=Oe:qe==="zip"||qe==="zipcode"||qe==="postalcode"?Me.zip=Oe:qe.includes("company")||qe.includes("organization")||qe.includes("business")?Me.company_name=Oe:qe.includes("jobtitle")||qe.includes("title")&&!qe.includes("spouse")?Me.job_title=Oe:qe.includes("birthday")||qe.includes("dob")||qe.includes("birthdate")?Me.birthday=Oe:qe.includes("anniversary")||qe.includes("homeanniversary")?Me.home_anniversary=Oe:(qe.includes("notes")||qe.includes("comment"))&&(Me.notes=Oe)}),_(Me),c("mapping")},ge.readAsText(ue)},X=(xe,ue)=>{_(ge=>{if(ue==="none"){const{[xe]:_e,...Be}=ge;return Be}return{...ge,[xe]:ue}})},Y=xe=>{j(ue=>ue.includes(xe)?ue.filter(ge=>ge!==xe):[...ue,xe])},J=async()=>{if(!(a!=null&&a.id))return;const{data:xe}=await H.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ue=new Set((xe||[]).filter(Be=>Be.email).map(Be=>Be.email.toLowerCase())),ge=new Set((xe||[]).filter(Be=>Be.phone).map(Be=>Be.phone.replace(/[^0-9]/g,""))),_e=f.map(Be=>{const Se=qe=>{const ve=y[qe];if(!ve)return"";const dt=u.indexOf(ve);return dt>=0?(Be[dt]||"").trim():""},Ee=Se("first_name"),Ae=Se("email"),Me=Se("phone"),ke=Ee.length>0,Oe=!!(Ae&&ue.has(Ae.toLowerCase())||Me&&ge.has(Me.replace(/[^0-9]/g,"")));return{first_name:Ee,last_name:Se("last_name"),email:Ae,phone:Me,address:Se("address"),city:Se("city"),state:Se("state"),zip:Se("zip"),spouse_name:Se("spouse_name"),spouse_email:Se("spouse_email"),company_name:Se("company_name"),job_title:Se("job_title"),birthday:Se("birthday"),home_anniversary:Se("home_anniversary"),notes:Se("notes"),isValid:ke,isDuplicate:Oe,error:ke?void 0:"First name is required"}});S(_e),c("preview")},Q=xe=>{const ue=xe.trim().split(/\s+/);return{first_name:ue[0],last_name:ue.length>1?ue.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const xe=N.filter(Be=>Be.isValid);if(xe.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let ue=0,ge=0,_e=0;try{for(const Be of xe)try{let Se=null;if(Be.email){const{data:Me}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Be.email).maybeSingle();Se=Me}if(!Se&&Be.phone){const Me=Be.phone.replace(/[^0-9]/g,""),{data:ke}=await H.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(ke){const Oe=ke.find(qe=>qe.phone&&qe.phone.replace(/[^0-9]/g,"")===Me);Oe&&(Se={id:Oe.id})}}const Ee={owner_user_id:a.id,first_name:Be.first_name,last_name:Be.last_name||null,email:Be.email||null,phone:Be.phone||null,address:Be.address||null,city:Be.city||null,state:Be.state||null,zip:Be.zip||null,spouse_name:Be.spouse_name||null,spouse_email:Be.spouse_email||null,company_name:Be.company_name||null,job_title:Be.job_title||null,birthday:d9(Be.birthday),home_anniversary:d9(Be.home_anniversary),notes:Be.notes||null};let Ae=null;if(Se){const{data:Me}=await H.from("innercircle_contacts").select("*").eq("id",Se.id).single();if(Me){const ke={},Oe=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const qe of Oe){const ve=Me[qe],dt=Ee[qe];(!ve||ve==="")&&dt&&(ke[qe]=dt)}Object.keys(ke).length>0&&await H.from("innercircle_contacts").update(ke).eq("id",Se.id)}Ae=Se.id,ge++}else{const{data:Me,error:ke}=await H.from("innercircle_contacts").insert(Ee).select("id").single();ke?(console.error("Insert error for contact:",Be.first_name,ke),_e++):Me?(Ae=Me.id,w.length>0&&await H.from("innercircle_contact_tags").insert(w.map(Oe=>({contact_id:Me.id,relationship_type_id:Oe}))),ue++):_e++}if(Ae&&Be.spouse_name){const Me=Q(Be.spouse_name);let ke=null;if(Be.spouse_email){const{data:qe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Be.spouse_email).maybeSingle();ke=qe}if(!ke){const{data:qe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Me.first_name).eq("last_name",Me.last_name||Be.last_name||"").maybeSingle();ke=qe}let Oe=null;if(ke){Oe=ke.id;const qe=d9(Be.home_anniversary);qe&&await H.from("innercircle_contacts").update({home_anniversary:qe}).eq("id",ke.id).is("home_anniversary",null)}else{const{data:qe}=await H.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Me.first_name,last_name:Me.last_name||Be.last_name||null,email:Be.spouse_email||null,address:Be.address||null,city:Be.city||null,state:Be.state||null,zip:Be.zip||null,home_anniversary:d9(Be.home_anniversary),spouse_name:`${Be.first_name}${Be.last_name?" "+Be.last_name:""}`,spouse_email:Be.email||null,notes:`Spouse of ${Be.first_name} ${Be.last_name||""} (imported via CSV)`.trim()}).select("id").single();qe&&(Oe=qe.id,ue++)}Oe&&(await H.from("innercircle_contacts").update({spouse_contact_id:Oe}).eq("id",Ae),await H.from("innercircle_contacts").update({spouse_contact_id:Ae}).eq("id",Oe))}}catch(Se){console.error("Error importing contact:",Se),_e++}O({created:ue,updated:ge,failed:_e}),c("result"),(ue>0||ge>0)&&n(),o({title:"Import Complete",description:`${ue} created, ${ge} updated${_e>0?`, ${_e} failed`:""}.`})}catch(Be){console.error("Import error:",Be),o({title:"Import Failed",description:Be.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ne=N.filter(xe=>xe.isValid).length,re=N.filter(xe=>!xe.isValid).length,oe=N.filter(xe=>xe.isValid&&xe.isDuplicate).length,he=ne-oe;return e.jsx(fs,{open:t,onOpenChange:$,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(h1,{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(ci,{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(G,{onClick:()=>{var xe;return(xe=l.current)==null?void 0:xe.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(G,{variant:"outline",size:"sm",onClick:()=>{const xe=`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([xe],{type:"text/csv"}),ge=URL.createObjectURL(ue),_e=document.createElement("a");_e.href=ge,_e.download="contact_import_template.csv",_e.click(),URL.revokeObjectURL(ge)},children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:g_s.map(xe=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ye,{className:"w-40 text-sm",children:[xe.label,xe.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Rs,{value:y[xe.key]||"none",onValueChange:ue=>X(xe.key,ue),children:[e.jsx(Ls,{className:"w-48",children:e.jsx($s,{placeholder:"Select column..."})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"-- Not mapped --"}),u.map(ue=>e.jsx(ft,{value:ue,children:ue},ue))]})]})]},xe.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(xe=>e.jsx(Ye,{variant:w.includes(xe.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(xe.id),children:xe.name},xe.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:[he," new"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," existing (will merge gaps)"]})]}),re>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ul,{className:"h-4 w-4"}),e.jsxs("span",{children:[re," invalid"]})]})]}),oe>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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/30",children:[e.jsx(jt,{children:"First Name"}),e.jsx(jt,{children:"Last Name"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Phone"}),e.jsx(jt,{children:"Status"})]})}),e.jsx(qn,{children:N.slice(0,100).map((xe,ue)=>e.jsxs(ks,{children:[e.jsx(ut,{children:xe.first_name}),e.jsx(ut,{children:xe.last_name}),e.jsx(ut,{children:xe.email}),e.jsx(ut,{children:xe.phone}),e.jsx(ut,{children:xe.isValid?xe.isDuplicate?e.jsx(Ye,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(Ye,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(Ye,{variant:"destructive",children:xe.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"&&P&&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:[P.created," created, ",P.updated," merged"]}),P.failed>0&&e.jsxs("p",{className:"text-destructive",children:[P.failed," failed to import"]})]}),e.jsxs(Rn,{children:[i==="upload"&&e.jsx(G,{variant:"outline",onClick:$,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"outline",onClick:q,children:"Back"}),e.jsx(G,{onClick:J,disabled:!y.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"outline",onClick:()=>c("mapping"),children:"Back"}),e.jsx(G,{onClick:ce,disabled:M||ne===0,children:M?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ne} Contact${ne!==1?"s":""}`})]}),i==="result"&&e.jsx(G,{onClick:$,children:"Done"})]})]})})};function v_s(){return"contacts"in navigator&&"ContactsManager"in window}function b_s(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 m of a){const f=m.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const y=f.substring(f.indexOf(":")+1).split(";");l=(y[0]||"").trim(),o=(y[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const y=f.substring(f.indexOf(":")+1).trim().split(" ");o=y[0]||"",l=y.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 __s({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Fs(),{data:a}=nm(),o=Oue(),l=k.useRef(null),[i,c]=k.useState("choose"),[u,m]=k.useState([]),[f,g]=k.useState(new Set),[y,_]=k.useState(0),[w,j]=k.useState(0),N=v_s(),S=k.useCallback(X=>{if(!a)return X;const Y=new Set(a.filter(Q=>Q.email).map(Q=>Q.email.toLowerCase())),J=new Set(a.filter(Q=>Q.phone).map(Q=>Q.phone.replace(/\D/g,"")));return X.map(Q=>{var re,oe;const ce=(re=Q.email)==null?void 0:re.toLowerCase(),ne=(oe=Q.phone)==null?void 0:oe.replace(/\D/g,"");return ce&&Y.has(ce)?{...Q,isDuplicate:!0,duplicateField:"email"}:ne&&ne.length>=7&&J.has(ne)?{...Q,isDuplicate:!0,duplicateField:"phone"}:Q})},[a]),M=async()=>{try{const X=["name","email","tel","address"],Y=await navigator.contacts.select(X,{multiple:!0});if(!Y||Y.length===0)return;const J=Y.map(ne=>{var he,xe,ue,ge;const oe=(((he=ne.name)==null?void 0:he[0])||"").split(" ");return{first_name:oe[0]||"",last_name:oe.slice(1).join(" "),email:((xe=ne.email)==null?void 0:xe[0])||"",phone:((ue=ne.tel)==null?void 0:ue[0])||"",address:(ge=ne.address)!=null&&ge[0]?[ne.address[0].streetAddress,ne.address[0].city,ne.address[0].region,ne.address[0].postalCode].filter(Boolean).join(", "):""}}),Q=S(J);m(Q);const ce=new Set;Q.forEach((ne,re)=>{ne.isDuplicate||ce.add(re)}),g(ce),c("preview")}catch(X){console.error("Contact Picker error:",X),kn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;const J=new FileReader;J.onload=ce=>{var xe;const ne=(xe=ce.target)==null?void 0:xe.result,re=b_s(ne);if(re.length===0){kn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const oe=S(re);m(oe);const he=new Set;oe.forEach((ue,ge)=>{ue.isDuplicate||he.add(ge)}),g(he),c("preview")},J.readAsText(Y),l.current&&(l.current.value="")},P=async()=>{const X=u.filter((J,Q)=>f.has(Q));if(X.length===0)return;c("importing");let Y=0;for(const J of X)try{await o.mutateAsync({first_name:J.first_name,last_name:J.last_name||void 0,email:J.email||void 0,phone:J.phone||void 0,address:J.address||void 0}),Y++,j(Math.round(Y/X.length*100))}catch(Q){console.error(`Failed to import ${J.first_name} ${J.last_name}:`,Q)}_(Y),c("done")},O=X=>{g(Y=>{const J=new Set(Y);return J.has(X)?J.delete(X):J.add(X),J})},q=()=>{f.size===u.length?g(new Set):g(new Set(u.map((X,Y)=>Y)))},$=X=>{X||(c("choose"),m([]),g(new Set),_(0),j(0),i==="done"&&r()),s(X)},z=u.filter(X=>X.isDuplicate).length,V=f.size;return e.jsx(fs,{open:t,onOpenChange:$,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(N0,{className:"h-5 w-5 text-primary"}),i==="choose"&&"Import Phone Contacts",i==="preview"&&"Select Contacts to Import",i==="importing"&&"Importing Contacts...",i==="done"&&"Import Complete"]}),i==="choose"&&e.jsx(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(G,{onClick:M,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(N0,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[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(G,{variant:N?"outline":"default",onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(ci,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:N?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:I,className:"hidden"}),!N&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",z>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",z," already exist)"]})]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:q,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Li,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((X,Y)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${X.isDuplicate?"opacity-60":""}`,onClick:()=>O(Y),children:[e.jsx(Mo,{checked:f.has(Y),onCheckedChange:()=>O(Y),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]}),X.isDuplicate&&e.jsxs(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",X.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[X.phone&&e.jsx("div",{children:X.phone}),X.email&&e.jsx("div",{className:"truncate",children:X.email})]})]})]},Y))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c("choose"),children:"Back"}),e.jsxs(G,{onClick:P,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(ys,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ua,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[y," contact",y!==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(G,{onClick:()=>$(!1),className:"mt-2",children:"Done"})]})]})})}function jSe(){const t=Fa();return pt({queryKey:["drip-campaigns",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_campaigns").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("is_starter",{ascending:!1}).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function w_s(t){return pt({queryKey:["drip-campaign",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("drip_campaigns").select("*").eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function j_s(){const t=Fa(),s=Qt();return Tt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("drip_campaigns").insert({owner_user_id:t,name:r.name,description:r.description??null,category:r.category??"nurture",icon:r.icon??"🌱",cover_color:r.cover_color??"from-emerald-500 to-teal-600",goal:r.goal??null,is_active:!1}).select().single();if(a)throw a;return n},onSuccess:()=>s.invalidateQueries({queryKey:["drip-campaigns"]})})}function xit(){const t=Qt();return Tt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("drip_campaigns").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["drip-campaigns"]}),t.invalidateQueries({queryKey:["drip-campaign",r.id]})}})}function N_s(){const t=Qt();return Tt({mutationFn:async s=>{const{error:r}=await H.from("drip_campaigns").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["drip-campaigns"]})})}function k_s(){const t=Fa(),s=Qt();return Tt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const[{data:n,error:a},{data:o,error:l}]=await Promise.all([H.from("drip_campaigns").select("*").eq("id",r).single(),H.from("drip_campaign_steps").select("*").eq("campaign_id",r).order("step_order")]);if(a)throw a;if(l)throw l;const{data:i,error:c}=await H.from("drip_campaigns").insert({owner_user_id:t,name:n.name,description:n.description,category:n.category,icon:n.icon,cover_color:n.cover_color,goal:n.goal,is_active:!1,is_starter:!1}).select().single();if(c)throw c;if(o&&o.length>0){const u=o.map(f=>({campaign_id:i.id,step_order:f.step_order,channel:f.channel,subject:f.subject,body:f.body,video_url:f.video_url,delay_type:f.delay_type,delay_days:f.delay_days,delay_hours:f.delay_hours,anchor_field:f.anchor_field,anchor_offset_days:f.anchor_offset_days,send_window_start:f.send_window_start,send_window_end:f.send_window_end})),{error:m}=await H.from("drip_campaign_steps").insert(u);if(m)throw m}return i},onSuccess:()=>s.invalidateQueries({queryKey:["drip-campaigns"]})})}function git(t){return pt({queryKey:["drip-campaign-steps",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_campaign_steps").select("*").eq("campaign_id",t).order("step_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function S_s(){const t=Qt();return Tt({mutationFn:async s=>{const{data:r,error:n}=await H.from("drip_campaign_steps").insert({campaign_id:s.campaign_id,step_order:s.step_order,channel:s.channel??"email",subject:s.subject??"",body:s.body??"",video_url:s.video_url??null,delay_type:s.delay_type??"relative",delay_days:s.delay_days??0,delay_hours:s.delay_hours??0,anchor_field:s.anchor_field??null,anchor_offset_days:s.anchor_offset_days??0}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>t.invalidateQueries({queryKey:["drip-campaign-steps",r.campaign_id]})})}function C_s(){const t=Qt();return Tt({mutationFn:async({id:s,campaign_id:r,...n})=>{const{data:a,error:o}=await H.from("drip_campaign_steps").update(n).eq("id",s).select().single();if(o)throw o;return{data:a,campaign_id:r}},onSuccess:s=>t.invalidateQueries({queryKey:["drip-campaign-steps",s.campaign_id]})})}function M_s(){const t=Qt();return Tt({mutationFn:async({id:s,campaign_id:r})=>{const{error:n}=await H.from("drip_campaign_steps").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>t.invalidateQueries({queryKey:["drip-campaign-steps",s]})})}function T_s(t){return pt({queryKey:["campaign-enrollments",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_campaign_enrollments").select("*, contact:innercircle_contacts(id, first_name, last_name, email)").eq("campaign_id",t).order("enrolled_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function A_s(t){return pt({queryKey:["campaign-enrollment-count",t],queryFn:async()=>{if(!t)return 0;const{count:s,error:r}=await H.from("drip_campaign_enrollments").select("id",{count:"exact",head:!0}).eq("campaign_id",t).eq("status","active");if(r)throw r;return s??0},enabled:!!t,staleTime:3e4})}function yit(){const t=Qt();return Tt({mutationFn:async({campaignId:s,contactIds:r})=>{const{data:n,error:a}=await H.functions.invoke("enroll-contacts-in-campaign",{body:{campaign_id:s,contact_ids:r}});if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["campaign-enrollments"]}),t.invalidateQueries({queryKey:["contact-campaigns"]})}})}function E_s(){const t=Qt();return Tt({mutationFn:async({id:s,status:r})=>{const n={status:r};r==="paused"&&(n.paused_at=new Date().toISOString()),r==="exited"&&(n.exited_at=new Date().toISOString(),n.exit_reason="manual");const{data:a,error:o}=await H.from("drip_campaign_enrollments").update(n).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["campaign-enrollments"]}),t.invalidateQueries({queryKey:["contact-campaigns"]})}})}const P_s=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{review_link}}",label:"Review Link"}],nme={nurture:"New Lead Nurture",sphere:"Sphere of Influence",buyer:"Buyer",seller:"Seller",fsbo:"FSBO",past_client:"Past Client",birthday:"Birthday",anniversary:"Home Anniversary",custom:"Custom"},I_s={nurture:"from-emerald-500 to-teal-600",sphere:"from-rose-500 to-pink-600",buyer:"from-cyan-500 to-blue-600",seller:"from-indigo-500 to-purple-600",fsbo:"from-red-500 to-orange-600",past_client:"from-purple-500 to-violet-600",birthday:"from-amber-500 to-orange-600",anniversary:"from-blue-500 to-indigo-600",custom:"from-slate-500 to-gray-600"},L_s=["🌱","💎","🏠","🔑","📧","💌","🎂","🥂","🤝","⭐","🎉","📞"];function vit({open:t,onOpenChange:s,campaignId:r}){const[n,a]=k.useState(r??null),[o,l]=k.useState("details");k.useEffect(()=>{a(r??null),l("details")},[r,t]);const i=n,c=!!i,{data:u}=w_s(i||void 0),{data:m,isLoading:f}=git(i||void 0),g=j_s(),y=xit(),_=S_s(),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState("nurture"),[P,O]=k.useState("🌱"),[q,$]=k.useState("");k.useEffect(()=>{u?(j(u.name),S(u.description||""),I(u.category),O(u.icon),$(u.goal||"")):c||(j(""),S(""),I("nurture"),O("🌱"),$(""))},[u,c,t]);const z=I_s[M],V=async()=>{if(!w.trim()){me.error("Give your campaign a name");return}try{if(c&&i)await y.mutateAsync({id:i,name:w,description:N,category:M,icon:P,goal:q,cover_color:z}),me.success("Campaign updated");else{const Y=await g.mutateAsync({name:w,description:N,category:M,icon:P,goal:q,cover_color:z});return me.success("Campaign created — now add your first step!"),a(Y.id),l("steps"),Y}}catch(Y){me.error(Y.message||"Failed to save")}},X=async()=>{if(!i){me.error("Save the campaign first, then add steps");return}const Y=((m==null?void 0:m.length)||0)+1;try{await _.mutateAsync({campaign_id:i,step_order:Y,channel:"email",subject:"",body:"",delay_type:"relative",delay_days:Y===1?0:2,delay_hours:0})}catch{me.error("Failed to add step")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[e.jsx("div",{className:`bg-gradient-to-br ${z} p-5 text-white shrink-0`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-4xl drop-shadow-sm",children:P}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(vs,{className:"text-lg font-bold text-white",children:c?"Edit Campaign":"Create New Campaign"}),e.jsx(Gr,{className:"text-white/85 text-xs mt-0.5",children:"Design a multi-step nurture sequence. Steps are sent in order with your chosen delays."})]})]})}),e.jsxs(ga,{value:o,onValueChange:Y=>l(Y),className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(fa,{className:"mx-5 mt-4 grid grid-cols-2 w-fit",children:[e.jsx(ss,{value:"details",children:"Details"}),e.jsxs(ss,{value:"steps",disabled:!c,children:["Steps ",m&&m.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-[10px]",children:m.length})]})]}),e.jsx(bs,{value:"details",className:"flex-1 overflow-hidden mt-0",children:e.jsx(Li,{className:"h-full",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Campaign Name *"}),e.jsx(Le,{value:w,onChange:Y=>j(Y.target.value),placeholder:"e.g. New Buyer Lead — 7 Touch Nurture",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Description"}),e.jsx(Tr,{value:N,onChange:Y=>S(Y.target.value),placeholder:"What's this campaign for? When should you use it?",rows:2,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Goal (optional)"}),e.jsx(Le,{value:q,onChange:Y=>$(Y.target.value),placeholder:"e.g. Book a buyer consultation within 14 days",className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Category"}),e.jsxs(Rs,{value:M,onValueChange:Y=>I(Y),children:[e.jsx(Ls,{className:"mt-1",children:e.jsx($s,{})}),e.jsx(Ds,{children:Object.entries(nme).map(([Y,J])=>e.jsx(ft,{value:Y,children:J},Y))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Icon"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap mt-1",children:L_s.map(Y=>e.jsx("button",{type:"button",onClick:()=>O(Y),className:`h-8 w-8 rounded-md text-lg flex items-center justify-center transition-all ${P===Y?"bg-primary/15 ring-2 ring-primary":"hover:bg-muted"}`,children:Y},Y))})]})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"Save changes, then jump to the Steps tab to manage your sequence.":"Save to create the campaign, then you can add steps to it."})})]})})}),e.jsx(bs,{value:"steps",className:"flex-1 overflow-hidden mt-0",children:e.jsx(Li,{className:"h-full",children:e.jsx("div",{className:"p-5 space-y-3",children:f?e.jsx("div",{className:"text-center text-sm text-muted-foreground py-8",children:"Loading steps…"}):!m||m.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl",children:[e.jsx(nn,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No steps yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Build your sequence — each step waits for its delay, then sends."}),e.jsxs(G,{size:"sm",onClick:X,disabled:_.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Add first step"]})]}):e.jsxs(e.Fragment,{children:[m.map((Y,J)=>e.jsx(D_s,{step:Y,index:J,totalSteps:m.length},Y.id)),e.jsxs(G,{variant:"outline",size:"sm",onClick:X,disabled:_.isPending,className:"w-full",children:[_.isPending?e.jsx(ys,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"}),"Add another step"]})]})})})})]}),e.jsxs(Rn,{className:"border-t p-4 shrink-0",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:c?"Done":"Cancel"}),e.jsxs(G,{onClick:V,disabled:g.isPending||y.isPending,children:[(g.isPending||y.isPending)&&e.jsx(ys,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),c?"Save Changes":"Create Campaign"]})]})]})})}function D_s({step:t,index:s,totalSteps:r}){const n=C_s(),a=M_s(),[o,l]=k.useState(!1),[i,c]=k.useState(t),[u,m]=k.useState(!1);k.useEffect(()=>c(t),[t]);const f=JSON.stringify(i)!==JSON.stringify(t),g=async()=>{m(!0);try{await n.mutateAsync({id:t.id,campaign_id:t.campaign_id,channel:i.channel,subject:i.subject,body:i.body,video_url:i.video_url,delay_type:i.delay_type,delay_days:i.delay_days,delay_hours:i.delay_hours,anchor_field:i.anchor_field,anchor_offset_days:i.anchor_offset_days}),me.success(`Step ${s+1} saved`)}catch{me.error("Failed to save step")}finally{m(!1)}},y=async()=>{if(confirm(`Delete step ${s+1}?`))try{await a.mutateAsync({id:t.id,campaign_id:t.campaign_id}),me.success("Step deleted")}catch{me.error("Failed to delete")}},_=j=>{c({...i,body:i.body+j})},w=()=>{if(i.delay_type==="calendar_anchor"){const N=i.anchor_field==="birthday"?"birthday":"home anniversary",S=i.anchor_offset_days||0;return S===0?`On their ${N}`:S<0?`${Math.abs(S)}d before ${N}`:`${S}d after ${N}`}if(s===0&&!i.delay_days&&!i.delay_hours)return"Sends immediately";const j=[];return i.delay_days&&j.push(`${i.delay_days}d`),i.delay_hours&&j.push(`${i.delay_hours}h`),s===0?`After ${j.join(" ")||"0"}`:`+${j.join(" ")||"0"}`};return e.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 hover:bg-muted/30 cursor-pointer",onClick:()=>l(!o),children:[e.jsx("div",{className:"h-7 w-7 shrink-0 rounded-full bg-primary/10 text-primary flex items-center justify-center text-xs font-semibold",children:s+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.delay_type==="calendar_anchor"?e.jsx(fn,{className:"h-3 w-3"}):e.jsx(mn,{className:"h-3 w-3"}),e.jsx("span",{children:w()}),e.jsx("span",{children:"·"}),i.channel==="email"?e.jsx(rr,{className:"h-3 w-3"}):e.jsx(Ki,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:i.channel})]}),e.jsx("p",{className:"text-sm font-medium truncate mt-0.5",children:i.subject||e.jsx("span",{className:"text-muted-foreground italic",children:"No subject"})})]}),o?e.jsx(Sp,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ji,{className:"h-4 w-4 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"border-t p-4 space-y-3 bg-muted/10",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Channel"}),e.jsxs(Rs,{value:i.channel,onValueChange:j=>c({...i,channel:j}),children:[e.jsx(Ls,{className:"mt-1 h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"email",children:"📧 Email"}),e.jsx(ft,{value:"sms",children:"💬 SMS"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Timing Type"}),e.jsxs(Rs,{value:i.delay_type,onValueChange:j=>c({...i,delay_type:j}),children:[e.jsx(Ls,{className:"mt-1 h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"relative",children:"⏱ Relative delay"}),e.jsx(ft,{value:"calendar_anchor",children:"📅 Calendar date"})]})]})]})]}),i.delay_type==="relative"?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Days delay"}),e.jsx(Le,{type:"number",min:0,value:i.delay_days,onChange:j=>c({...i,delay_days:parseInt(j.target.value)||0}),className:"mt-1 h-9"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Hours delay"}),e.jsx(Le,{type:"number",min:0,max:23,value:i.delay_hours,onChange:j=>c({...i,delay_hours:parseInt(j.target.value)||0}),className:"mt-1 h-9"})]})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Anchor"}),e.jsxs(Rs,{value:i.anchor_field||"birthday",onValueChange:j=>c({...i,anchor_field:j}),children:[e.jsx(Ls,{className:"mt-1 h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"birthday",children:"🎂 Birthday"}),e.jsx(ft,{value:"home_anniversary",children:"🏠 Home Anniversary"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Offset (days, negative = before)"}),e.jsx(Le,{type:"number",value:i.anchor_offset_days||0,onChange:j=>c({...i,anchor_offset_days:parseInt(j.target.value)||0}),className:"mt-1 h-9",placeholder:"0 = on the day, -7 = week before"})]})]}),i.channel==="email"&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Subject Line"}),e.jsx(Le,{value:i.subject,onChange:j=>c({...i,subject:j.target.value}),placeholder:"e.g. Quick question about your home search, {{client_first_name}}",className:"mt-1 h-9"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(ye,{className:"text-xs",children:i.channel==="email"?"Email Body":"SMS Message"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:i.channel==="sms"?`${i.body.length}/160`:`${i.body.length} chars`})]}),e.jsx(Tr,{value:i.body,onChange:j=>c({...i,body:j.target.value}),placeholder:i.channel==="email"?`Hi {{client_first_name}}, I wanted to reach out and...`:"Hi {{client_first_name}}, just checking in!",rows:i.channel==="email"?6:3,className:"mt-1 font-mono text-xs"}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground mr-1",children:"Insert:"}),P_s.map(j=>e.jsx("button",{type:"button",onClick:()=>_(j.key),className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary hover:bg-primary/20",children:j.label},j.key))]})]}),i.channel==="email"&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Video URL (optional)"}),e.jsx(Le,{value:i.video_url||"",onChange:j=>c({...i,video_url:j.target.value||null}),placeholder:"https://...",className:"mt-1 h-9"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:y,className:"text-destructive hover:text-destructive",children:[e.jsx(kr,{className:"h-3.5 w-3.5 mr-1"})," Delete step"]}),e.jsxs(G,{size:"sm",onClick:g,disabled:!f||u,children:[u&&e.jsx(ys,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save step"]})]})]})]})}function O_s({open:t,onOpenChange:s,contactIds:r,onSuccess:n}){const{data:a,isLoading:o}=jSe(),l=yit(),[i,c]=k.useState(""),[u,m]=k.useState(null),[f,g]=k.useState(!1),y=(a||[]).filter(j=>!j.is_starter),_=y.filter(j=>j.name.toLowerCase().includes(i.toLowerCase())||(j.description||"").toLowerCase().includes(i.toLowerCase())),w=async()=>{if(u)try{const j=await l.mutateAsync({campaignId:u,contactIds:r}),N=[`${j.enrolled} enrolled`];j.skipped>0&&N.push(`${j.skipped} skipped`),j.errors>0&&N.push(`${j.errors} errors`),me.success(N.join(" · ")),s(!1),m(null),n==null||n()}catch(j){me.error(j.message||"Failed to enroll contacts")}};return e.jsxs(fs,{open:t,onOpenChange:s,children:[e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-primary"}),"Enroll in Drip Campaign"]}),e.jsxs(Gr,{children:[r.length," contact",r.length!==1?"s":""," will be added to the selected campaign. Already-enrolled contacts will be skipped."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search campaigns...",value:i,onChange:j=>c(j.target.value),className:"pl-9 h-9"})]}),e.jsx(Li,{className:"h-[320px] -mx-1 px-1",children:o?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"Loading..."}):_.length===0?e.jsx("div",{className:"text-center py-8",children:y.length===0?e.jsxs(e.Fragment,{children:[e.jsx(nn,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No campaigns yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Build a custom drip campaign to nurture these contacts on autopilot."}),e.jsxs(G,{size:"sm",onClick:()=>g(!0),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Create campaign"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No campaigns match your search."})}):e.jsx("div",{className:"space-y-1.5",children:_.map(j=>e.jsxs("button",{onClick:()=>m(j.id),className:`w-full flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${u===j.id?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/40 hover:bg-muted/30"}`,children:[e.jsx("div",{className:`shrink-0 h-9 w-9 rounded-lg bg-gradient-to-br ${j.cover_color} flex items-center justify-center text-lg`,children:j.icon}),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:j.name}),j.is_active&&e.jsx(Ye,{variant:"outline",className:"text-[9px] bg-emerald-500/10 text-emerald-600 border-emerald-200 px-1 py-0",children:"Active"})]}),j.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:j.description})]}),u===j.id&&e.jsx(ua,{className:"h-4 w-4 text-primary shrink-0 mt-1"})]},j.id))})})]}),e.jsxs(Rn,{className:"gap-2 sm:gap-2",children:[y.length>0&&e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"mr-auto text-xs",children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," New campaign"]}),e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:w,disabled:!u||l.isPending,children:[l.isPending&&e.jsx(ys,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Enroll ",r.length," contact",r.length!==1?"s":""]})]})]}),e.jsx(vit,{open:f,onOpenChange:g})]})}function ame(){const t=Fa();return pt({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 R_s(t){return pt({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 NSe(){const t=Qt(),s=Fa();return Tt({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 F_s(){const t=Qt();return Tt({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 z_s(){const t=Qt();return Tt({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 bit(){const t=Qt();return Tt({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 B_s(){const t=Qt();return Tt({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 $_s(){const t=Fa();return pt({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 q_s({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=ar(),{data:c}=Rf(),u=zNe(),m=Qt(),{isGmailConnected:f}=Ff(),{isReady:g}=vSe(),{data:y}=ame(),_=NSe(),w=bit(),[j,N]=k.useState(!1),[S,M]=k.useState(!1),[I,P]=k.useState(!1),[O,q]=k.useState(!1),[$,z]=k.useState(""),V=t.size;if(V===0)return null;const X=async oe=>{N(!0);try{const xe=Array.from(t).map(ge=>({contact_id:ge,relationship_type_id:oe})),{error:ue}=await H.from("innercircle_contact_tags").upsert(xe,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(ue)throw ue;m.invalidateQueries({queryKey:["innercircle-contacts"]}),m.invalidateQueries({queryKey:["innercircle-contact-counts"]}),kn({title:`Assigned type to ${V} contacts`}),r()}catch(he){kn({title:"Error assigning type",description:he.message,variant:"destructive"})}finally{N(!1)}},Y=async oe=>{N(!0);try{const he=Array.from(t);for(const xe of he)try{await w.mutateAsync({contactId:xe,tagId:oe})}catch{}m.invalidateQueries({queryKey:["all-contact-custom-tags"]}),kn({title:`Tagged ${V} contacts`}),q(!1),z("")}catch(he){kn({title:"Error adding tags",description:he.message,variant:"destructive"})}finally{N(!1)}},J=async()=>{if($.trim()){N(!0);try{const oe=await _.mutateAsync({name:$.trim()});await Y(oe.id)}catch(oe){kn({title:"Error creating tag",description:oe.message,variant:"destructive"}),N(!1)}}},Q=(y==null?void 0:y.filter(oe=>oe.name.toLowerCase().includes($.toLowerCase())))||[],ce=y==null?void 0:y.find(oe=>oe.name.toLowerCase()===$.trim().toLowerCase()),ne=()=>{const oe=s.filter(Se=>t.has(Se.id)),he=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],xe=oe.map(Se=>{var Ee;return[Se.first_name,Se.last_name||"",Se.email||"",Se.phone||"",Se.address||"",Se.birthday||"",Se.home_anniversary||"",Se.notes||"",((Ee=Se.tags)==null?void 0:Ee.map(Ae=>{var Me;return(Me=Ae.relationship_type)==null?void 0:Me.name}).join("; "))||""]}),ue=[he.join(","),...xe.map(Se=>Se.map(Ee=>`"${(Ee||"").replace(/"/g,'""')}"`).join(","))].join(` `),ge=new Blob([ue],{type:"text/csv"}),_e=URL.createObjectURL(ge),Be=document.createElement("a");Be.href=_e,Be.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,Be.click(),URL.revokeObjectURL(_e),kn({title:`Exported ${V} contacts`})},re=async()=>{if(confirm(`Are you sure you want to delete ${V} contacts? This cannot be undone.`)){N(!0);try{const oe=Array.from(t);for(const he of oe)await u.mutateAsync(he);r()}catch(oe){kn({title:"Error deleting contacts",description:oe.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(Ye,{variant:"secondary",className:"font-semibold",children:[V," selected"]}),e.jsxs(Rs,{onValueChange:X,disabled:j,children:[e.jsx(Ls,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Lh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Ds,{children:c==null?void 0:c.filter(oe=>oe.active).map(oe=>e.jsx(ft,{value:oe.id,children:oe.name},oe.id))})]}),e.jsxs(Vo,{open:O,onOpenChange:q,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",disabled:j,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs($o,{className:"w-56 p-2",align:"start",children:[e.jsx(Le,{placeholder:"Search or create tag...",value:$,onChange:oe=>z(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&$.trim()&&!ce?(oe.preventDefault(),J()):oe.key==="Enter"&&ce&&(oe.preventDefault(),Y(ce.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(oe=>e.jsxs("button",{onClick:()=>Y(oe.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:oe.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:oe.name})]},oe.id)),$.trim()&&!ce&&e.jsxs("button",{onClick:J,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),'Create "',$.trim(),'"']}),Q.length===0&&!$.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>M(!0),disabled:j,children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),g&&e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>{const oe=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${oe}`)},disabled:j,children:[e.jsx(Ph,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>P(!0),disabled:j,children:[e.jsx(nn,{className:"h-3.5 w-3.5 mr-1"}),"Enroll in Campaign"]}),a&&n&&e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:j,children:[e.jsx(ey,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:j,children:[e.jsx(l1,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:ne,disabled:j,children:[e.jsx(vi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:re,disabled:j,className:"text-destructive hover:text-destructive",children:[e.jsx(kr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Er,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(O_s,{open:I,onOpenChange:P,contactIds:Array.from(t),onSuccess:r}),e.jsx(X1,{open:S,onOpenChange:M,bulkContacts:Array.from(t).map(oe=>{const he=s.find(xe=>xe.id===oe);return he?{id:he.id,first_name:he.first_name,last_name:he.last_name,email:he.email||""}:null}).filter(oe=>oe!==null&&oe.email!==""),onSendComplete:()=>{M(!1),r()}})]})}function x7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=ar(),{isReady:u}=vSe(),m=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(bx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(La,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(La,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(La,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(La,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(La,{onClick:()=>n(t.id,m),children:[e.jsx(Ih,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(La,{onClick:()=>a(t.id),children:[e.jsx(ey,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(La,{onClick:()=>l(t.id),children:[e.jsx(l1,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(La,{onClick:()=>s(t),children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(La,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function U_s(){const{user:t}=Fs();return pt({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 V_s(){const t=Qt(),{user:s}=Fs();return Tt({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"]}),kn({title:"Smart filter saved"})},onError:r=>{kn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function H_s(){const t=Qt();return Tt({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"]}),kn({title:"Smart filter deleted"})}})}function G_s({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=U_s(),a=V_s(),o=H_s(),[l,i]=k.useState(!1),[c,u]=k.useState(""),m=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(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ty,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(Ye,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Ji,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Ud,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(g=>e.jsxs(La,{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(G,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:y=>{y.stopPropagation(),o.mutate(g.id)},children:e.jsx(kr,{className:"h-3 w-3 text-destructive"})})]},g.id)),e.jsx(yw,{})]}):e.jsx(La,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),m&&e.jsxs(La,{onClick:()=>i(!0),children:[e.jsx(fL,{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(js,{children:e.jsx(vs,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Le,{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(G,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(G,{onClick:f,disabled:!c.trim()||a.isPending,children:"Save"})]})]})]})})]})}function ZI(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 y7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=ar(),i=g7e(t,"birthday",7),c=g7e(s,"anniversary",7);if(!i&&!c)return null;const u=(m,f)=>{f.stopPropagation();const g=new URLSearchParams;n&&g.set("contactId",n),a&&g.set("name",a),o&&g.set("address",o),m==="home_anniversary"&&s&&g.set("date",s),g.set("cardType",m),l(`/mission-control/card-studio?${g.toString()}`)};return e.jsxs("div",{className:Pt("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ye,{variant:"secondary",className:Pt("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:m=>u("birthday",m),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(rr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ye,{variant:"secondary",className:Pt("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:m=>u("home_anniversary",m),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(rr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function v7e({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(Ye,{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 b7e({count:t,className:s}){return!t||t<=0?null:e.jsxs(Ye,{variant:"outline",className:Pt("text-[10px] gap-1 border-emerald-300 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 px-1.5 py-0 h-5",s),title:`Enrolled in ${t} active drip campaign${t===1?"":"s"}`,children:[e.jsx(SS,{className:"h-2.5 w-2.5"}),t===1?"In drip":`${t} drips`]})}function W_s(){const t=Fa();return pt({queryKey:["contacts-campaign-counts",t],queryFn:async()=>{if(!t)return{};const{data:s,error:r}=await H.from("drip_campaign_enrollments").select("contact_id, status").eq("owner_user_id",t).eq("status","active");if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&(n[a.contact_id]=(n[a.contact_id]||0)+1)}),n},enabled:!!t,staleTime:6e4})}function K_s(){const t=Fa();return pt({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 Z_s({contactId:t,compact:s=!1}){const{data:r}=ame(),{data:n}=R_s(t),a=NSe(),o=bit(),l=B_s(),[i,c]=k.useState(!1),[u,m]=k.useState(""),f=k.useRef(null),g=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),y=(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()),w=async N=>{g.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},j=async()=>{if(!(!u.trim()||_))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),m("")}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,I;return e.jsxs(Ye,{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(Lh,{className:"h-2.5 w-2.5"}),(I=N.tag)==null?void 0:I.name,e.jsx("button",{onClick:P=>{P.stopPropagation(),l.mutate({contactId:t,tagId:N.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Er,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs(Vo,{open:i,onOpenChange:c,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{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(qs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs($o,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(Le,{ref:f,placeholder:"Search or create tag...",value:u,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!_?(N.preventDefault(),j()):N.key==="Enter"&&_&&!g.has(_.id)&&(N.preventDefault(),w(_))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[y.map(N=>e.jsxs("button",{onClick:()=>w(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(ua,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!_&&e.jsxs("button",{onClick:j,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),y.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 _7e({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(Ye,{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 u9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Y_s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=ame(),a=NSe(),o=z_s(),l=F_s(),[i,c]=k.useState(""),[u,m]=k.useState(u9[0]),[f,g]=k.useState(null),[y,_]=k.useState(""),[w,j]=k.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),m(u9[0]),kn({title:"Tag created"})}catch(P){kn({title:"Error",description:P.message,variant:"destructive"})}},S=async P=>{if(y.trim())try{await o.mutateAsync({id:P,name:y.trim(),color:w}),g(null),kn({title:"Tag updated"})}catch(O){kn({title:"Error",description:O.message,variant:"destructive"})}},M=async(P,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(P),kn({title:"Tag deleted"})}catch(q){kn({title:"Error",description:q.message,variant:"destructive"})}},I=P=>{g(P.id),_(P.name),j(P.color)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{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(Le,{placeholder:"New tag name...",value:i,onChange:P=>c(P.target.value),onKeyDown:P=>P.key==="Enter"&&N(),className:"flex-1 h-9"}),e.jsxs(G,{size:"sm",onClick:N,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:u9.map(P=>e.jsx("button",{onClick:()=>m(P),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===P?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:P}},P))})]}),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(P=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===P.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:u9.map(O=>e.jsx("button",{onClick:()=>j(O),className:`h-5 w-5 rounded-full border-2 ${w===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(Le,{value:y,onChange:O=>_(O.target.value),onKeyDown:O=>O.key==="Enter"&&S(P.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(P.id),children:e.jsx(ua,{className:"h-4 w-4 text-primary"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>g(null),children:e.jsx(Er,{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:P.color}}),e.jsx("span",{className:"flex-1 text-sm",children:P.name}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(P),children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{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(P.id,P.name),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})},P.id))]})]})})}function Q_s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=_E(),a=qNe(),o=z8t(),l=B8t(),[i,c]=k.useState(""),[u,m]=k.useState(null),[f,g]=k.useState(""),y=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()}),m(null)}catch(S){me.error(S.message||"Failed to update")}},w=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")}},j=N=>{m(N.id),g(N.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(vs,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"New lead source name...",value:i,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&y(),className:"flex-1 h-9"}),e.jsxs(G,{size:"sm",onClick:y,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(qs,{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(Le,{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(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>_(N.id),children:e.jsx(ua,{className:"h-4 w-4 text-primary"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>m(null),children:e.jsx(Er,{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(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>j(N),children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>w(N.id,N.name),children:e.jsx(kr,{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 _it({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=_E(),a=qNe(),[o,l]=k.useState(!1),[i,c]=k.useState(""),u=async()=>{if(i.trim())try{const m=await a.mutateAsync(i.trim());m&&(s(m.id),c(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:t||"_none",onValueChange:m=>s(m==="_none"?"":m),children:[e.jsx(Ls,{className:"flex-1",children:e.jsx($s,{placeholder:"Select lead source"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"_none",children:"No source"}),n==null?void 0:n.map(m=>e.jsx(ft,{value:m.id,children:m.name},m.id))]})]}),e.jsx(G,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Er,{className:"h-4 w-4"}):e.jsx(qs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"New lead source name...",value:i,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),u())},className:"flex-1"}),e.jsx(G,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function swe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=ar(),[c,u]=k.useState(!1),[m,f]=k.useState(""),{data:g}=pt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:_,error:w}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(w)throw w;return _},enabled:!!s}),{data:y}=pt({queryKey:["spouse-search",m],queryFn:async()=>{let _=H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);m.trim()&&(_=_.or(`first_name.ilike.%${m}%,last_name.ilike.%${m}%,email.ilike.%${m}%,phone.ilike.%${m}%`));const{data:w,error:j}=await _;if(j)throw j;return w},enabled:c});if(s&&g){const _=`${g.first_name} ${g.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{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(Zi,{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(G,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(TS,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(ba,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{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(Zi,{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(Vo,{open:c,onOpenChange:u,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(pl,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx($o,{className:"w-72 p-2",align:"end",children:e.jsx(w7e,{search:m,setSearch:f,results:y,onSelect:_=>{a(_),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(Vo,{open:c,onOpenChange:u,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(pl,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx($o,{className:"w-72 p-2",align:"start",children:e.jsx(w7e,{search:m,setSearch:f,results:y,onSelect:_=>{a(_),u(!1),f("")}})})]})]}):null}function w7e({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(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Li,{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 X_s(){var ns;const t=ar(),[s]=Ul(),{user:r}=Fs(),n=UE(),a=Qt(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=zue(),{activeContactIds:m,hasLeadSite:f}=p_s(),{data:g}=W_s(),{data:y}=Rf(),{data:_}=K_s(),{data:w}=ame(),{data:j}=$_s(),[N,S]=k.useState(new Set),[M,I]=k.useState("any"),P=Oue(),O=FNe(),q=zNe(),$=DQe(),[z,V]=k.useState(""),[X,Y]=k.useState(o||"all"),[J,Q]=k.useState(l||"all"),[ce,ne]=k.useState("date-added"),[re,oe]=k.useState(i),[he,xe]=k.useState(null),[ue,ge]=k.useState(!1),[_e,Be]=k.useState(!1),[Se,Ee]=k.useState(null),[Ae,Me]=k.useState(""),[ke,Oe]=k.useState(new Set),[qe,ve]=k.useState(!1),[dt,pe]=k.useState(1),[Ue,Xe]=k.useState(50),[et,Ce]=k.useState("my"),[Je,Ge]=k.useState(!1),[lt,He]=k.useState(!1),{data:We}=Gx(),{addToLeadPond:tt}=Itt(We==null?void 0:We.teamId),Ke=!!((ns=We==null?void 0:We.team)!=null&&ns.lead_pond_enabled&&(We!=null&&We.teamId)),rt=!!(We!=null&&We.teamId),[it,It]=k.useState([]),[Vt,hs]=k.useState(!1),Es=Wt=>{It([Wt]),hs(!0)},Ts=Wt=>{It(Wt),hs(!0)},cr=Wt=>{We!=null&&We.teamId&&tt.mutate({contact_id:Wt,team_id:We.teamId})},zr=Wt=>{We!=null&&We.teamId&&Wt.forEach(Hr=>{tt.mutate({contact_id:Hr,team_id:We.teamId})})},Ft=k.useCallback(Wt=>{ve(!1),Oe(Hr=>{const Mr=new Set(Hr);return Mr.has(Wt)?Mr.delete(Wt):Mr.add(Wt),Mr})},[]);k.useEffect(()=>{if(!(r!=null&&r.id))return;const Wt=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(Wt)}},[a,r==null?void 0:r.id]),k.useEffect(()=>{l&&Q(l)},[l]);const[Ps,yr]=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 Wt;he&&yr({first_name:he.first_name||"",last_name:he.last_name||"",email:he.email||"",phone:he.phone||"",address:he.address||"",city:he.city||"",state:he.state||"",zip_code:he.zip_code||"",birthday:he.birthday||"",home_anniversary:he.home_anniversary||"",spouse_name:he.spouse_name||"",spouse_email:he.spouse_email||"",lead_source_id:he.lead_source_id||"",notes:he.notes||"",tagIds:((Wt=he.tags)==null?void 0:Wt.map(Hr=>Hr.relationship_type_id))||[]})},[he]);const Is=k.useMemo(()=>{if(!c)return[];let Wt=c.filter(Hr=>{var ai,Aa,no;const Mr=z===""||`${Hr.first_name} ${Hr.last_name}`.toLowerCase().includes(z.toLowerCase())||((ai=Hr.email)==null?void 0:ai.toLowerCase().includes(z.toLowerCase()))||((Aa=Hr.phone)==null?void 0:Aa.includes(z)),xr=X==="all"||((no=Hr.tags)==null?void 0:no.some($t=>$t.relationship_type_id===X)),Wn=N.size===0||(()=>{const $t=(j==null?void 0:j.filter(je=>je.contact_id===Hr.id).map(je=>je.tag_id))||[];return M==="any"?$t.some(je=>N.has(je)):Array.from(N).every(je=>$t.includes(je))})();return Mr&&xr&&Wn});return J==="not-touched-90"?Wt=Wt.filter(Hr=>{const Mr=Hr.relationshipScore.daysSinceTouch;return Mr===null||Mr>90}):J==="at-risk"?Wt=Wt.filter(Hr=>Hr.relationshipScore.status==="at-risk"):J==="cooling"?Wt=Wt.filter(Hr=>Hr.relationshipScore.status==="cooling"):J==="warm"?Wt=Wt.filter(Hr=>Hr.relationshipScore.status==="warm"):J==="has-deal"?Wt=Wt.filter(Hr=>_&&_[Hr.id]):J==="no-deal"?Wt=Wt.filter(Hr=>!_||!_[Hr.id]):J==="open-house"?Wt=Wt.filter(Hr=>{var xr;return(((xr=Hr.lead_source_ref)==null?void 0:xr.name)||Hr.lead_source)==="Open House"}):J==="website-active"&&(Wt=Wt.filter(Hr=>m.has(Hr.id))),Wt=[...Wt].sort((Hr,Mr)=>{switch(ce){case"important-dates":{const xr=ZI(Hr.birthday),Wn=ZI(Mr.birthday),ai=ZI(Hr.home_anniversary),Aa=ZI(Mr.home_anniversary),no=[xr,ai].filter(je=>je!==null).sort((je,$e)=>(je??1/0)-($e??1/0))[0]??1/0,$t=[Wn,Aa].filter(je=>je!==null).sort((je,$e)=>(je??1/0)-($e??1/0))[0]??1/0;return no-$t}case"last-touched":{const xr=Hr.relationshipScore.lastTouchDate,Wn=Mr.relationshipScore.lastTouchDate;return!xr&&!Wn?0:xr?Wn?new Date(xr).getTime()-new Date(Wn).getTime():1:-1}case"next-touch":{const xr=Hr.relationshipScore.daysSinceTouch,Wn=Mr.relationshipScore.daysSinceTouch;return xr===null&&Wn===null?0:xr===null?-1:Wn===null?1:Wn-xr}case"score":return Hr.relationshipScore.score-Mr.relationshipScore.score;case"date-added":{const xr=Hr.created_at,Wn=Mr.created_at;return!xr&&!Wn?0:xr?Wn?new Date(Wn).getTime()-new Date(xr).getTime():-1:1}case"name":default:{const xr=`${Hr.first_name||""} ${Hr.last_name||""}`.toLowerCase(),Wn=`${Mr.first_name||""} ${Mr.last_name||""}`.toLowerCase();return xr.localeCompare(Wn)}}}),Wt},[c,z,X,N,M,J,ce,_,j,m]),Ar=Is.length,tn=Math.max(1,Math.ceil(Ar/Ue)),na=Math.min(dt,tn),Ln=k.useMemo(()=>{const Wt=(na-1)*Ue;return Is.slice(Wt,Wt+Ue)},[Is,na,Ue]);k.useEffect(()=>{pe(1)},[z,X,N,M,J,ce]);const tr=k.useCallback(()=>{ve(!1),Oe(Wt=>Wt.size>0?new Set:new Set(Ln.map(Hr=>Hr.id)))},[Ln]),dr=k.useCallback(()=>{ve(!0),Oe(new Set(Is.map(Wt=>Wt.id)))},[Is]),Sr=k.useCallback((Wt,Hr)=>{V(Wt.search||""),Y(Wt.type||"all"),Q(Wt.status||"all"),ne(Hr||"name")},[]),dn=()=>{yr({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Yr=async Wt=>{Wt.preventDefault();const Hr={...Ps,lead_source_id:Ps.lead_source_id||null};he?(await O.mutateAsync({id:he.id,...Hr}),xe(null)):(await P.mutateAsync(Hr),oe(!1)),dn()},ui=async Wt=>{confirm("Are you sure you want to delete this contact?")&&await q.mutateAsync(Wt)};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"})]}),We&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Ce("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${et==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(We.team.contact_visibility==="full_team"||We.team.contact_visibility==="leader_only"&&We.role==="team_leader")&&e.jsxs("button",{onClick:()=>Ce("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${et==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ur,{className:"h-3.5 w-3.5"}),"Team"]}),We.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Ce("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${et==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ey,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(tl,{className:"h-4 w-4 mr-1"}),"Back"]})}),et==="team"?e.jsx(Qke,{}):et==="lead-pond"&&We?e.jsx(Xke,{teamId:We.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:e.jsx(De,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or phone...",value:z,onChange:Wt=>V(Wt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(G,{onClick:()=>oe(!0),className:"shrink-0",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(G,{variant:"outline",onClick:()=>ge(!0),className:"shrink-0",children:[e.jsx(ci,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(G,{variant:"outline",onClick:()=>Be(!0),className:"shrink-0",children:[e.jsx(N0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(a_s,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Rs,{value:X,onValueChange:Y,children:[e.jsx(Ls,{className:"w-[145px] h-9 text-sm",children:e.jsx($s,{placeholder:"Filter by type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),y==null?void 0:y.filter(Wt=>Wt.active).map(Wt=>e.jsx(ft,{value:Wt.id,children:Wt.name},Wt.id))]})]}),w&&w.length>0&&e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Lh,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),N.size===0?"Filter by Tags":`${N.size} tag${N.size>1?"s":""}`]})}),e.jsx($o,{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:()=>I("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${M==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>I("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${M==="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:w.map(Wt=>{const Hr=N.has(Wt.id);return e.jsxs("button",{onClick:()=>{S(Mr=>{const xr=new Set(Mr);return xr.has(Wt.id)?xr.delete(Wt.id):xr.add(Wt.id),xr})},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(Mo,{checked:Hr,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Wt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Wt.name})]},Wt.id)})}),N.size>0&&e.jsx(G,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>S(new Set),children:"Clear tags"})]})})]}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(el,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Ud,{align:"end",children:[e.jsxs(La,{onClick:()=>Ge(!0),children:[e.jsx(Lh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(La,{onClick:()=>He(!0),children:[e.jsx(ey,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Rs,{value:J,onValueChange:Q,children:[e.jsx(Ls,{className:"w-[145px] h-9 text-sm",children:e.jsx($s,{placeholder:"Filter by status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Status"}),e.jsx(ft,{value:"warm",children:"🟢 Warm"}),e.jsx(ft,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(ft,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(ft,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(ft,{value:"no-deal",children:"📭 No Deal"}),e.jsx(ft,{value:"open-house",children:"🏠 Open House"}),f&&e.jsx(ft,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(Rs,{value:ce,onValueChange:ne,children:[e.jsx(Ls,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wd,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx($s,{placeholder:"Sort by"})]})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"name",children:"Name (A-Z)"}),e.jsx(ft,{value:"important-dates",children:"Important Dates"}),e.jsx(ft,{value:"last-touched",children:"Last Touched"}),e.jsx(ft,{value:"next-touch",children:"Next Touch Due"}),e.jsx(ft,{value:"score",children:"Relationship Score"}),e.jsx(ft,{value:"date-added",children:"Date Added"})]})]}),e.jsx(G_s,{currentFilters:{search:z,type:X,status:J},currentSortBy:ce,onApplySmartList:Sr})]})]})})}),e.jsx(q_s,{selectedIds:ke,contacts:Is,onClearSelection:()=>{Oe(new Set),ve(!1)},showLeadPondAction:Ke,onSendToLeadPond:zr,showTransferAction:rt,onTransfer:Ts}),ke.size>0&&ke.size===Ln.length&&!qe&&Ar>Ue&&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 ",Ln.length," contacts on this page are selected."]}),e.jsxs(G,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:dr,children:["Select all ",Ar.toLocaleString()," matching contacts"]})]}),qe&&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 ",Ar.toLocaleString()," matching contacts are selected.",e.jsx(G,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Oe(new Set),ve(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):Is.length===0?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:z||X!=="all"||J!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Ln.map(Wt=>{var Mr,xr,Wn;const{relationshipScore:Hr}=Wt;return e.jsx(Pe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const ai=new URLSearchParams;z&&ai.set("search",z),X!=="all"&&ai.set("type",X),J!=="all"&&ai.set("filter",J);const Aa=ai.toString();t(`/mission-control/contacts/${Wt.id}${Aa?`?${Aa}`:""}`)},children:e.jsx(De,{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 flex-wrap",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Wt.first_name," ",Wt.last_name]}),e.jsx(b7e,{count:(g==null?void 0:g[Wt.id])??0}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground shrink-0 ml-auto"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Wt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(rr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Wt.email})]}),Wt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Wt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(R8,{score:Hr,size:"sm"}),e.jsx(twe,{contact:Wt}),(((Mr=Wt.lead_source_ref)==null?void 0:Mr.name)||Wt.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((xr=Wt.lead_source_ref)==null?void 0:xr.name)||Wt.lead_source}),(Wn=Wt.tags)==null?void 0:Wn.map(ai=>{var Aa;return e.jsx(Ye,{variant:"secondary",className:"text-xs",children:(Aa=ai.relationship_type)==null?void 0:Aa.name},ai.id)}),e.jsx(_7e,{contactId:Wt.id,tags:j==null?void 0:j.filter(ai=>ai.contact_id===Wt.id)}),e.jsx(v7e,{deal:_==null?void 0:_[Wt.id]})]}),e.jsx(y7e,{birthday:Wt.birthday,homeAnniversary:Wt.home_anniversary,className:"mb-2",contactId:Wt.id,contactName:`${Wt.first_name}${Wt.last_name?" "+Wt.last_name:""}`,contactAddress:[Wt.address,Wt.city,Wt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[Hr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),ds(new Date(Hr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Wt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),ds(Fl(Wt.birthday),"MMM d")]}),Wt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),ds(Fl(Wt.home_anniversary),"MMM d")]}),Wt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Added ",ds(new Date(Wt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:ai=>ai.stopPropagation(),children:e.jsx(x7e,{contact:Wt,onEdit:xe,onDelete:ui,onSnooze:(ai,Aa)=>{Ee(ai),Me(Aa)},showLeadPondAction:Ke,onSendToLeadPond:cr,showTransferAction:rt,onTransfer:Es})})]})})},Wt.id)})}):e.jsx(Pe,{children:e.jsx(De,{className:"p-0 overflow-x-auto",children:e.jsxs(Bn,{className:"min-w-[800px]",children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(Mo,{checked:Ln.length>0&&Ln.every(Wt=>ke.has(Wt.id)),onCheckedChange:()=>tr()})}),e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{children:"Contact Info"}),e.jsx(jt,{children:"Types / Pipeline"}),e.jsx(jt,{children:"Last Contact"}),e.jsx(jt,{className:"cursor-pointer select-none",onClick:()=>ne(ce==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",ce==="date-added"&&e.jsx(wd,{className:"h-3 w-3"})]})}),e.jsx(jt,{children:"Important Dates"}),e.jsx(jt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(qn,{children:u?e.jsx(ks,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Is.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:z||X!=="all"||J!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Ln.map(Wt=>{var xr,Wn,ai;const{relationshipScore:Hr}=Wt,Mr=_==null?void 0:_[Wt.id];return e.jsxs(ks,{className:`cursor-pointer hover:bg-accent/50 ${ke.has(Wt.id)?"bg-accent/30":""}`,onClick:()=>{const Aa=new URLSearchParams;z&&Aa.set("search",z),X!=="all"&&Aa.set("type",X),J!=="all"&&Aa.set("status",J);const no=Aa.toString();t(`/mission-control/contacts/${Wt.id}${no?`?${no}`:""}`)},children:[e.jsx(ut,{onClick:Aa=>Aa.stopPropagation(),children:e.jsx(Mo,{checked:ke.has(Wt.id),onCheckedChange:()=>Ft(Wt.id)})}),e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{children:[Wt.first_name," ",Wt.last_name]}),e.jsx(b7e,{count:(g==null?void 0:g[Wt.id])??0})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(R8,{score:Hr,size:"sm"}),e.jsx(twe,{contact:Wt})]})}),e.jsx(ut,{children:e.jsx(R8,{score:Hr,size:"sm",showScore:!0})}),e.jsx(ut,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Wt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(rr,{className:"h-3 w-3"}),Wt.email]}),Wt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Nn,{className:"h-3 w-3"}),Wt.phone]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((xr=Wt.lead_source_ref)==null?void 0:xr.name)||Wt.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Wn=Wt.lead_source_ref)==null?void 0:Wn.name)||Wt.lead_source}),(ai=Wt.tags)==null?void 0:ai.map(Aa=>{var no;return e.jsx(Ye,{variant:"secondary",className:"text-xs",children:(no=Aa.relationship_type)==null?void 0:no.name},Aa.id)}),e.jsx(_7e,{contactId:Wt.id,tags:j==null?void 0:j.filter(Aa=>Aa.contact_id===Wt.id)}),e.jsx(v7e,{deal:Mr})]})}),e.jsx(ut,{children:e.jsx("div",{className:"text-sm",children:Hr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(mn,{className:"h-3 w-3"}),ds(new Date(Hr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Wt.created_at?ds(new Date(Wt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(ut,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(y7e,{birthday:Wt.birthday,homeAnniversary:Wt.home_anniversary,contactId:Wt.id,contactName:`${Wt.first_name}${Wt.last_name?" "+Wt.last_name:""}`,contactAddress:[Wt.address,Wt.city,Wt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Wt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),ds(Fl(Wt.birthday),"MMM d")]}),Wt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),ds(Fl(Wt.home_anniversary),"MMM d")]})]})]})}),e.jsx(ut,{children:e.jsx(x7e,{contact:Wt,onEdit:xe,onDelete:ui,onSnooze:(Aa,no)=>{Ee(Aa),Me(no)},showLeadPondAction:Ke,onSendToLeadPond:cr,showTransferAction:rt,onTransfer:Es})})]},Wt.id)})})]})})}),Ar>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 ",(na-1)*Ue+1,"–",Math.min(na*Ue,Ar)," of ",Ar.toLocaleString()," contacts"]}),e.jsxs(Rs,{value:String(Ue),onValueChange:Wt=>{Xe(Number(Wt)),pe(1)},children:[e.jsx(Ls,{className:"w-[80px] h-8",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"50",children:"50"}),e.jsx(ft,{value:"100",children:"100"}),e.jsx(ft,{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(G,{variant:"outline",size:"sm",disabled:na<=1,onClick:()=>pe(1),children:"First"}),e.jsx(G,{variant:"outline",size:"sm",disabled:na<=1,onClick:()=>pe(Wt=>Wt-1),children:e.jsx(tl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",na," of ",tn]}),e.jsx(G,{variant:"outline",size:"sm",disabled:na>=tn,onClick:()=>pe(Wt=>Wt+1),children:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"sm",disabled:na>=tn,onClick:()=>pe(tn),children:"Last"})]})]}),e.jsx(fs,{open:re||!!he,onOpenChange:Wt=>{Wt||(oe(!1),xe(null),dn())},children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:he?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Yr,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Le,{id:"first_name",value:Ps.first_name,onChange:Wt=>yr({...Ps,first_name:Wt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Le,{id:"last_name",value:Ps.last_name,onChange:Wt=>yr({...Ps,last_name:Wt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",value:Ps.email,onChange:Wt=>yr({...Ps,email:Wt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(Le,{id:"phone",value:Ps.phone,onChange:Wt=>yr({...Ps,phone:Wt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"address",children:"Address"}),e.jsx(Le,{id:"address",value:Ps.address,onChange:Wt=>yr({...Ps,address:Wt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"city",children:"City"}),e.jsx(Le,{id:"city",value:Ps.city,onChange:Wt=>yr({...Ps,city:Wt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(Le,{id:"state",value:Ps.state,onChange:Wt=>yr({...Ps,state:Wt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Le,{id:"zip_code",value:Ps.zip_code,onChange:Wt=>yr({...Ps,zip_code:Wt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Le,{id:"birthday",type:"date",value:Ps.birthday,onChange:Wt=>yr({...Ps,birthday:Wt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Le,{id:"home_anniversary",type:"date",value:Ps.home_anniversary,onChange:Wt=>yr({...Ps,home_anniversary:Wt.target.value})})]})]}),he&&e.jsx(swe,{contactId:he.id,currentSpouseContactId:(he==null?void 0:he.spouse_contact_id)||null,currentSpouseName:(he==null?void 0:he.spouse_name)||null,currentSpouseEmail:(he==null?void 0:he.spouse_email)||null,onLink:Wt=>$.mutate({contactId:he.id,spouseContactId:Wt}),onUnlink:()=>$.mutate({contactId:he.id,spouseContactId:null}),isEditing:!0}),e.jsx(_it,{value:Ps.lead_source_id,onChange:Wt=>yr({...Ps,lead_source_id:Wt})}),e.jsxs("div",{children:[e.jsx(ye,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:y==null?void 0:y.filter(Wt=>Wt.active).map(Wt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Mo,{checked:Ps.tagIds.includes(Wt.id),onCheckedChange:Hr=>{yr(Hr?{...Ps,tagIds:[...Ps.tagIds,Wt.id]}:{...Ps,tagIds:Ps.tagIds.filter(Mr=>Mr!==Wt.id)})}}),e.jsx("span",{className:"text-sm",children:Wt.name})]},Wt.id))})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:Ps.notes,onChange:Wt=>yr({...Ps,notes:Wt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>{oe(!1),xe(null),dn()},children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:P.isPending||O.isPending,children:[he?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(y_s,{open:ue,onOpenChange:ge,relationshipTypes:(y==null?void 0:y.filter(Wt=>Wt.active))||[],onSuccess:()=>{ge(!1)}}),e.jsx(__s,{open:_e,onOpenChange:Be,onComplete:()=>Be(!1)}),e.jsx(sme,{open:!!Se,onOpenChange:Wt=>{Wt||Ee(null)},contactId:Se||"",contactName:Ae}),e.jsx(Y_s,{open:Je,onOpenChange:Ge}),e.jsx(Q_s,{open:lt,onOpenChange:He}),e.jsx(Ltt,{open:Vt,onOpenChange:hs,contactIds:it,contactNames:it.map(Wt=>{const Hr=Is.find(Mr=>Mr.id===Wt);return Hr?`${Hr.first_name} ${Hr.last_name||""}`.trim():""}),onComplete:()=>{It([]),Oe(new Set),ve(!1)}})]})]})})}function J_s(){return pt({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 ews(t){return pt({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 tws(){const{user:t}=Fs();return pt({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 sws(){const{user:t}=Fs(),s=Qt();return Tt({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 rws(t){const{user:s}=Fs();return pt({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 nws(t){return pt({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 B3(){const{user:t}=Fs(),s=Qt();return Tt({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 aws(){const t=Qt();return Tt({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 iws(){const t=Qt();return Tt({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 ime(){const{user:t}=Fs();return pt({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 wit(){const{data:t,isLoading:s}=ime(),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 ER(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 PR(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 FA(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 ows(){const{user:t}=Fs(),s=Qt();return Tt({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 lws(t){return pt({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 cws(t){return pt({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 kSe(){const t=Fa(),s=Qt();return Tt({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 IR(){const t=Qt();return Tt({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 dws(){const t=Qt();return Tt({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 uws(){const t=Qt();return Tt({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 hws(){const t=Qt();return Tt({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 jit(){const t=Qt();return Tt({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 mws(){const t=Fa();return pt({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 pws(){const t=Fa(),s=Qt();return Tt({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 fws(){const t=Qt();return Tt({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 xws(){const t=Qt();return Tt({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 S1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function gws({contactId:t}){const s=ar(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(null),w=IR(),j=jit(),{data:N,isLoading:S}=pt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:$,error:z}=await H.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(z)throw z;if(!$||$.length===0)return[];const V=$.map(J=>J.id),{data:X,error:Y}=await H.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(Y)throw Y;return(X||[]).map(J=>({...J,deal:$.find(Q=>Q.id===J.deal_id)}))},enabled:!!t}),M=(N==null?void 0:N.map($=>$.id))||[],{data:I}=pt({queryKey:["contact-portal-updates",M],queryFn:async()=>{if(M.length===0)return{};const{data:$,error:z}=await H.from("portal_updates").select("*").in("portal_id",M).order("created_at",{ascending:!1});if(z)throw z;const V={};return($||[]).forEach(X=>{V[X.portal_id]||(V[X.portal_id]=X)}),V},enabled:M.length>0}),P=$=>{navigator.clipboard.writeText(S1($)),a($),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async $=>{u.trim()&&(await j.mutateAsync({portal_id:$,title:u,content:f||void 0}),c(!1),m(""),g(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},q=async()=>{y&&(await w.mutateAsync({id:y.id,welcome_message:y.welcome_message,next_step_text:y.next_step_text,is_enabled:y.is_enabled,show_post_close_tips:y.show_post_close_tips,review_url:y.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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(Nd,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(De,{className:"space-y-3",children:N.map($=>{var Y,J,Q;const z=((Y=$.stage_mapping)==null?void 0:Y.length)>0?$.stage_mapping:gNe(((J=$.deal)==null?void 0:J.deal_type)||"buyer"),V=z==null?void 0:z[$.current_stage_index??0],X=I==null?void 0:I[$.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Q=$.deal)==null?void 0:Q.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(Ye,{variant:$.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:$.is_enabled?"Active":"Disabled"})]}),X&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:X.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ds(new Date(X.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>P($.slug),children:[n===$.slug?e.jsx(ua,{className:"h-3 w-3 mr-1"}):e.jsx(yi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(S1($.slug),"_blank"),children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:c,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>c(!0),children:[e.jsx(Ki,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(Le,{value:u,onChange:ce=>m(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Details (optional)"}),e.jsx(Tr,{value:f,onChange:ce=>g(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(G,{onClick:()=>O($.id),disabled:!u.trim()||j.isPending,className:"w-full",children:[e.jsx(Fn,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{_({...$}),l(!0)},children:[e.jsx(el,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Portal Settings"})}),y&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Portal Enabled"}),e.jsx(qr,{checked:y.is_enabled,onCheckedChange:ce=>_({...y,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Welcome Message"}),e.jsx(Tr,{value:y.welcome_message||"",onChange:ce=>_({...y,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Next Step"}),e.jsx(Le,{value:y.next_step_text||"",onChange:ce=>_({...y,next_step_text:ce.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Review URL"}),e.jsx(Le,{value:y.review_url||"",onChange:ce=>_({...y,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Show Post-Close Tips"}),e.jsx(qr,{checked:y.show_post_close_tips,onCheckedChange:ce=>_({...y,show_post_close_tips:ce})})]}),e.jsx(Qo,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{onClick:q,disabled:w.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(G,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${$.deal_id}`),children:[e.jsx(ba,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(Qo,{})]},$.id)})})]})}function yws({contactId:t}){const{data:s}=pt({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}=pt({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(Pe,{className:"overflow-hidden",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{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(Tn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(Ye,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(De,{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(xn,{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(mn,{className:"h-3 w-3"}),e.jsx("span",{title:ds(new Date(l.viewed_at),"PPp"),children:ql(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(rn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const vws=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function j7e({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 m=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(Le,{ref:c,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),m.length>0?r(m[0]):r(t))}}),n.length>0&&e.jsx(Ji,{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(G,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx(qs,{className:"h-4 w-4"})})]}),l&&m.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:m.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(aa,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function bws({contactId:t,contactName:s}){var z,V,X;const{user:r}=Fs(),n=Fa(),{hasLeadSite:a}=vE(),o=Qt(),[l,i]=k.useState(!1),[c,u]=k.useState(""),[m,f]=k.useState(""),{data:g}=pt({queryKey:["agent-lead-site-config",n],queryFn:async()=>{const{data:Y,error:J}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(J||!Y)return{cities:[],zipCodes:[]};const Q=Y.theme_config||{},ce=Array.isArray(Q.searchCities)?Q.searchCities:[];Y.mls_market_area&&!ce.includes(Y.mls_market_area)&&ce.unshift(Y.mls_market_area);const ne=Array.isArray(Q.searchZipCodes)?Q.searchZipCodes:[];return{cities:ce,zipCodes:ne}},enabled:!!n}),{data:y,isLoading:_}=pt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:J}=await H.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(J)throw J;return Y},enabled:!!t&&!!r}),[w,j]=k.useState({}),N=()=>{j({is_active:(y==null?void 0:y.is_active)??!0,min_price:(y==null?void 0:y.min_price)??null,max_price:(y==null?void 0:y.max_price)??null,min_beds:(y==null?void 0:y.min_beds)??null,min_baths:(y==null?void 0:y.min_baths)??null,min_sqft:(y==null?void 0:y.min_sqft)??null,max_sqft:(y==null?void 0:y.max_sqft)??null,cities:(y==null?void 0:y.cities)??[],zip_codes:(y==null?void 0:y.zip_codes)??[],property_types:(y==null?void 0:y.property_types)??[],frequency:(y==null?void 0:y.frequency)??"daily"}),i(!0)},S=Tt({mutationFn:async()=>{const Y={contact_id:t,owner_user_id:n,is_active:w.is_active??!0,min_price:w.min_price||null,max_price:w.max_price||null,min_beds:w.min_beds||null,min_baths:w.min_baths||null,min_sqft:w.min_sqft||null,max_sqft:w.max_sqft||null,cities:w.cities||[],zip_codes:w.zip_codes||[],property_types:w.property_types||[],frequency:w.frequency||"daily"};if(y!=null&&y.id){const{error:J}=await H.from("contact_property_alerts").update(Y).eq("id",y.id);if(J)throw J}else{const{error:J}=await H.from("contact_property_alerts").insert(Y);if(J)throw J}},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert saved!")},onError:Y=>{me.error(Y.message||"Failed to save alert")}}),M=Tt({mutationFn:async()=>{if(!(y!=null&&y.id))return;const{error:Y}=await H.from("contact_property_alerts").delete().eq("id",y.id);if(Y)throw Y},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert removed")}}),I=Y=>{var Q;const J=Y.trim();J&&!((Q=w.cities)!=null&&Q.includes(J))&&j(ce=>({...ce,cities:[...ce.cities||[],J]})),u("")},P=Y=>{var Q;const J=Y.trim();J&&!((Q=w.zip_codes)!=null&&Q.includes(J))&&j(ce=>({...ce,zip_codes:[...ce.zip_codes||[],J]})),f("")},O=Y=>{j(J=>{const Q=J.property_types||[];return{...J,property_types:Q.includes(Y)?Q.filter(ce=>ce!==Y):[...Q,Y]}})};if(!a||_)return null;if(y&&!l)return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${y.is_active?"bg-green-500/10":"bg-muted"}`,children:y.is_active?e.jsx(Fm,{className:"h-4 w-4 text-green-600"}):e.jsx(c1,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(Ye,{variant:y.is_active?"default":"secondary",className:"text-xs ml-auto",children:[y.is_active?"Active":"Paused"," · ",y.frequency]})]})}),e.jsxs(De,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[y.min_price||y.max_price?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(ml,{className:"h-3 w-3"}),y.min_price?`$${(y.min_price/1e3).toFixed(0)}k`:"$0"," - ",y.max_price?`$${(y.max_price/1e3).toFixed(0)}k`:"Any"]}):null,y.min_beds?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(eS,{className:"h-3 w-3"}),y.min_beds,"+ beds"]}):null,y.min_baths?e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(au,{className:"h-3 w-3"}),y.min_baths,"+ baths"]}):null,(z=y.cities)==null?void 0:z.map(Y=>e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(aa,{className:"h-3 w-3"}),Y]},Y)),(V=y.zip_codes)==null?void 0:V.map(Y=>e.jsx(Ye,{variant:"outline",children:Y},Y)),(X=y.property_types)==null?void 0:X.map(Y=>e.jsx(Ye,{variant:"outline",children:Y},Y))]}),y.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(y.last_sent_at).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:N,className:"flex-1",children:"Manage Alert"}),e.jsxs(G,{variant:"destructive",size:"sm",onClick:()=>M.mutate(),disabled:M.isPending,className:"flex-1",children:[M.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Er,{className:"h-4 w-4 mr-1"}),"Remove Alert"]})]})]})]});const q=((g==null?void 0:g.cities)||[]).filter(Y=>{var J;return!((J=w.cities)!=null&&J.includes(Y))}),$=((g==null?void 0:g.zipCodes)||[]).filter(Y=>{var J;return!((J=w.zip_codes)!=null&&J.includes(Y))});return l?e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(Fm,{className:"h-4 w-4 text-primary"}),y?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Alert Active"}),e.jsx(qr,{checked:w.is_active??!0,onCheckedChange:Y=>j(J=>({...J,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ml,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Le,{type:"number",placeholder:"Min price",value:w.min_price??"",onChange:Y=>j(J=>({...J,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(Le,{type:"number",placeholder:"Max price",value:w.max_price??"",onChange:Y=>j(J=>({...J,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(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(eS,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Rs,{value:w.min_beds?String(w.min_beds):"any",onValueChange:Y=>j(J=>({...J,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Any"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"any",children:"Any"}),[1,2,3,4,5].map(Y=>e.jsxs(ft,{value:String(Y),children:[Y,"+"]},Y))]})]})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(au,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Rs,{value:w.min_baths?String(w.min_baths):"any",onValueChange:Y=>j(J=>({...J,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Any"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Y=>e.jsxs(ft,{value:String(Y),children:[Y,"+"]},Y))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ix,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Le,{type:"number",placeholder:"Min sqft",value:w.min_sqft??"",onChange:Y=>j(J=>({...J,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(Le,{type:"number",placeholder:"Max sqft",value:w.max_sqft??"",onChange:Y=>j(J=>({...J,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(aa,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(j7e,{value:c,onChange:u,onAdd:I,suggestions:q,placeholder:"Type to search cities..."}),w.cities&&w.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.cities.map(Y=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(J=>{var Q;return{...J,cities:(Q=J.cities)==null?void 0:Q.filter(ce=>ce!==Y)}}),children:e.jsx(Er,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(j7e,{value:m,onChange:f,onAdd:P,suggestions:$,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),w.zip_codes&&w.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.zip_codes.map(Y=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(J=>{var Q;return{...J,zip_codes:(Q=J.zip_codes)==null?void 0:Q.filter(ce=>ce!==Y)}}),children:e.jsx(Er,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(xn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:vws.map(Y=>{var J;return e.jsx(Ye,{variant:(J=w.property_types)!=null&&J.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>O(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Rs,{value:w.frequency||"daily",onValueChange:Y=>j(J=>({...J,frequency:Y})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"daily",children:"Daily"}),e.jsx(ft,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(G,{onClick:()=>S.mutate(),disabled:S.isPending,className:"flex-1",children:[S.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),y&&e.jsx(G,{variant:"destructive",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,children:e.jsx(Er,{className:"h-4 w-4"})})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(De,{className:"p-4",children:e.jsxs("button",{onClick:N,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(Fm,{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 _ws({contactId:t,contactName:s}){var ne;const{user:r}=Fs(),n=Fa(),{hasLeadSite:a}=vE(),o=Qt(),[l,i]=k.useState(!1),[c,u]=k.useState(""),[m,f]=k.useState([]),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(!1),[S,M]=k.useState(""),I=k.useRef(null),P=k.useRef(null),{data:O}=pt({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:re,error:oe}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(oe||!re)return[];const he=re.theme_config||{},xe=Array.isArray(he.searchCities)?he.searchCities:[];return re.mls_market_area&&!xe.includes(re.mls_market_area)&&xe.unshift(re.mls_market_area),xe},enabled:!!n}),{data:q,isLoading:$}=pt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(oe)throw oe;return re},enabled:!!t&&!!r});k.useEffect(()=>{const re=oe=>{P.current&&!P.current.contains(oe.target)&&I.current&&!I.current.contains(oe.target)&&w(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[]);const z=()=>{y((q==null?void 0:q.market_report_enabled)??!1),f((q==null?void 0:q.market_report_cities)??[]),i(!0)},V=re=>{const oe=(re||c).trim();oe&&!m.includes(oe)&&f([...m,oe]),u(""),w(!1)},X=(O||[]).filter(re=>!m.includes(re)&&re.toLowerCase().includes(c.toLowerCase())),Y=Tt({mutationFn:async()=>{const{data:re,error:oe}=await H.functions.invoke("send-market-report",{body:{action:"preview",agentId:n,cities:(q==null?void 0:q.market_report_cities)??[]}});if(oe)throw new Error(oe.message||"Failed to generate preview");if(re&&!re.ok&&re.error)throw new Error(re.error);return re},onSuccess:re=>{M(re.html),N(!0)},onError:re=>{me.error(re.message||"Failed to generate preview")}}),J=Tt({mutationFn:async()=>{const{data:re,error:oe}=await H.functions.invoke("send-market-report",{body:{action:"send",agentId:n,cities:(q==null?void 0:q.market_report_cities)??[],contactIds:[t]}});if(oe)throw new Error(oe.message||"Failed to send report");if(re&&!re.ok&&re.error)throw new Error(re.error);return re},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:re=>{me.error(re.message||"Failed to send report")}}),Q=Tt({mutationFn:async()=>{const{error:re}=await H.from("innercircle_contacts").update({market_report_enabled:g,market_report_cities:m}).eq("id",t);if(re)throw re},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),me.success(g?"Monthly market report enabled!":"Market report disabled")},onError:re=>{me.error(re.message||"Failed to save")}}),ce=Tt({mutationFn:async()=>{const{error:re}=await H.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(re)throw re},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),y(!1),f([]),me.success("Market report removed")},onError:re=>{me.error(re.message||"Failed to remove market report")}});return!a||$?null:q!=null&&q.market_report_enabled&&!l?e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{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(co,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(Ye,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(De,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ne=q.market_report_cities)==null?void 0:ne.length)>0?q.market_report_cities.map(re=>e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(aa,{className:"h-3 w-3"}),re]},re)):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(G,{variant:"outline",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Tn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(G,{variant:"default",size:"sm",onClick:()=>J.mutate(),disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4 mr-1"}),"Send Now"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:z,className:"flex-1",children:"Manage"}),e.jsxs(G,{variant:"destructive",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,className:"flex-1",children:[ce.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Er,{className:"h-4 w-4 mr-1"}),"Remove"]})]}),e.jsx(fs,{open:j,onOpenChange:N,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(co,{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:S}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(G,{onClick:()=>{N(!1),J.mutate()},disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(G,{variant:"outline",onClick:()=>N(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(co,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Send Monthly Report"}),e.jsx(qr,{checked:g,onCheckedChange:y})]}),g&&e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(aa,{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(Le,{ref:I,value:c,onChange:re=>{u(re.target.value),w(!0)},onFocus:()=>w(!0),placeholder:"Type to search cities...",onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),X.length>0?V(X[0]):V())}}),e.jsx(Ji,{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(G,{type:"button",variant:"outline",size:"sm",onClick:()=>V(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),_&&X.length>0&&e.jsx("div",{ref:P,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:X.map(re=>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:()=>V(re),children:[e.jsx(aa,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),re]},re))})]}),m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:m.map(re=>e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[re,e.jsx("button",{onClick:()=>f(m.filter(oe=>oe!==re)),children:e.jsx(Er,{className:"h-3 w-3"})})]},re))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(G,{onClick:()=>Q.mutate(),disabled:Q.isPending,className:"flex-1",children:[Q.isPending?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(De,{className:"p-4",children:e.jsxs("button",{onClick:z,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(co,{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 wws(t){return pt({queryKey:["contact-drip-activity",t],queryFn:async()=>{if(!t)return{enrollments:[],stepLogs:[]};const{data:s,error:r}=await H.from("drip_campaign_enrollments").select("id, campaign_id, current_step, status, next_send_at, enrolled_at, completed_at, exited_at, exit_reason").eq("contact_id",t).order("enrolled_at",{ascending:!1});if(r)throw console.error("[ContactDripActivity] enrollments error",r),r;const n=(s||[]).map(c=>c.id),a=Array.from(new Set((s||[]).map(c=>c.campaign_id)));let o=new Map;if(a.length>0){const{data:c}=await H.from("drip_campaigns").select("id, name, description, is_active").in("id",a);(c||[]).forEach(u=>o.set(u.id,u))}const l=(s||[]).map(c=>({...c,campaign:o.get(c.campaign_id)||null}));let i=[];if(n.length>0){const{data:c,error:u}=await H.from("drip_campaign_step_log").select("id, enrollment_id, campaign_id, step_order, channel, recipient_email, subject, status, error_message, sent_at").in("enrollment_id",n).order("sent_at",{ascending:!1});u?console.error("[ContactDripActivity] step log error",u):i=(c||[]).map(m=>{var f;return{...m,campaign:{name:((f=o.get(m.campaign_id))==null?void 0:f.name)??""}}})}return{enrollments:l,stepLogs:i}},enabled:!!t})}function jws(t){switch(t){case"active":return e.jsx(Ye,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Active"});case"paused":return e.jsx(Ye,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Paused"});case"completed":return e.jsx(Ye,{variant:"secondary",className:"bg-sky-500/10 text-sky-600 border-sky-500/20",children:"Completed"});case"exited":return e.jsx(Ye,{variant:"outline",children:"Exited"});default:return e.jsx(Ye,{variant:"outline",children:t})}}function N7e(t){return t==="sent"?e.jsx(sa,{className:"h-4 w-4 text-emerald-500"}):t==="failed"?e.jsx(vd,{className:"h-4 w-4 text-destructive"}):t==="skipped"?e.jsx(Ih,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})}function Nws({contactId:t}){const s=ar(),{data:r,isLoading:n}=wws(t),[a,o]=k.useState(null);if(n)return null;const l=(r==null?void 0:r.enrollments)||[],i=(r==null?void 0:r.stepLogs)||[];return l.length===0&&i.length===0?null:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[e.jsx(SS,{className:"h-5 w-5 text-emerald-500"}),"Drip Campaign Activity"]})}),e.jsxs(De,{className:"space-y-4",children:[l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Enrollments"}),l.map(c=>{var u;return e.jsxs("button",{onClick:()=>s("/mission-control/smart-drips"),className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-emerald-500/10 flex items-center justify-center text-emerald-600 flex-shrink-0",children:e.jsx(SS,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((u=c.campaign)==null?void 0:u.name)||"Untitled campaign"}),jws(c.status)]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Step ",c.current_step+1,c.next_send_at&&c.status==="active"&&e.jsxs(e.Fragment,{children:[" · Next: ",ql(new Date(c.next_send_at),{addSuffix:!0})]}),c.completed_at&&e.jsxs(e.Fragment,{children:[" · Completed ",ql(new Date(c.completed_at),{addSuffix:!0})]}),c.exited_at&&!c.completed_at&&e.jsxs(e.Fragment,{children:[" · ",c.exit_reason||"Exited"," ",ql(new Date(c.exited_at),{addSuffix:!0})]})]})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]},c.id)})]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Send History (",i.length,")"]}),e.jsxs("div",{className:"space-y-1",children:[i.slice(0,8).map(c=>{var u,m;return e.jsxs(fs,{open:(a==null?void 0:a.id)===c.id,onOpenChange:f=>!f&&o(null),children:[e.jsx(Oi,{asChild:!0,children:e.jsxs("button",{onClick:()=>o(c),className:"w-full text-left flex items-start gap-3 p-2.5 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:N7e(c.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[c.channel==="sms"?e.jsx(Ki,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}):e.jsx(rr,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),e.jsx("p",{className:"text-sm truncate",children:c.subject||`${c.channel.toUpperCase()} step ${c.step_order+1}`})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:[((u=c.campaign)==null?void 0:u.name)||"Campaign"," · ",ds(new Date(c.sent_at),"MMM d, h:mm a")]}),c.status==="failed"&&c.error_message&&e.jsx("p",{className:"text-xs text-destructive mt-0.5 truncate",children:c.error_message})]})]})}),e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[N7e(c.status),c.subject||"Drip step"]})}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Campaign"}),e.jsx("span",{className:"font-medium",children:((m=c.campaign)==null?void 0:m.name)||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Channel"}),e.jsx("span",{className:"font-medium uppercase",children:c.channel})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Step"}),e.jsxs("span",{className:"font-medium",children:["#",c.step_order+1]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recipient"}),e.jsx("span",{className:"font-medium",children:c.recipient_email||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status"}),e.jsx("span",{className:"font-medium capitalize",children:c.status})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Sent"}),e.jsx("span",{className:"font-medium",children:ds(new Date(c.sent_at),"MMM d, yyyy h:mm a")})]}),c.error_message&&e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 text-destructive text-xs",children:c.error_message})]})]})]},c.id)}),i.length>8&&e.jsx(G,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>s("/mission-control/smart-drips"),children:"View all in Smart Drips"})]})]})]})]})}function kws({videoId:t}){var l;const{data:s,isLoading:r,error:n}=nws(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ws,{className:"w-full aspect-video rounded-lg"}),e.jsx(ws,{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(vd,{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 Sws({contactId:t}){const s=ar(),[r,n]=k.useState(!1),{data:a,isLoading:o}=pt({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 y=g==="done"?"todo":"done";await H.from("deal_tasks").update({status:y,completed_at:y==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=pt({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"))||[],m=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(De,{className:"space-y-1",children:o?e.jsx(ws,{className:"h-8 w-full"}):u.length===0&&m.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:ds(new Date(f.due_date),"MMM d")})]},f.id)),m.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:[m.length," completed"]})})]})}),r&&e.jsx(Cws,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function Cws({contactId:t,open:s,onOpenChange:r}){const[n,a]=k.useState(""),[o,l]=k.useState("medium"),[i,c]=k.useState(),{data:u}=pt({queryKey:["session"],queryFn:async()=>{const{data:f}=await H.auth.getSession();return f.session}}),m=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?ds(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(js,{children:e.jsx(vs,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(Le,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&m()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:"Due Date"}),e.jsx(Le,{type:"date",value:i?ds(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(G,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(G,{onClick:m,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function Mws({contactId:t}){const s=ar(),{data:r,isLoading:n}=pt({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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(sh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(De,{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(Ye,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(Ye,{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(ba,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function Tws(){var Ge,lt,He,We,tt;const{contactId:t}=ao(),s=ar(),[r]=Ul(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=VLt(t||""),{data:c}=Rf(),{data:u}=nR(),{data:m}=aR(3650),{data:f}=rme(365),{data:g}=lws(t),{contactsWithScores:y}=zue(),_=FNe(),w=zNe(),j=BNe(),N=DQe(),[S,M]=k.useState(!1),[I,P]=k.useState({}),[O,q]=k.useState(!1),[$,z]=k.useState(null),[V,X]=k.useState(""),[Y,J]=k.useState(void 0),[Q,ce]=k.useState(""),[ne,re]=k.useState(null),[oe,he]=k.useState(!1),[xe,ue]=k.useState(null),{isGmailConnected:ge,gmailEmail:_e}=Ff(),{data:Be}=pt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ke,error:rt}=await H.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(rt)throw rt;return Ke},enabled:!!t}),Se=Ke=>{if(!Ke)return null;const rt=Ke.match(/Video ID:\s*([a-f0-9-]+)/i);return rt?rt[1]:null},Ee=k.useMemo(()=>{if(!y)return[];let Ke=y.filter(rt=>{var Vt,hs,Es;const it=n===""||`${rt.first_name} ${rt.last_name}`.toLowerCase().includes(n.toLowerCase())||((Vt=rt.email)==null?void 0:Vt.toLowerCase().includes(n.toLowerCase()))||((hs=rt.phone)==null?void 0:hs.includes(n)),It=a==="all"||((Es=rt.tags)==null?void 0:Es.some(Ts=>Ts.relationship_type_id===a));return it&&It});return o==="not-touched-90"?Ke=Ke.filter(rt=>{const it=rt.relationshipScore.daysSinceTouch;return it===null||it>90}):o==="at-risk"?Ke=Ke.filter(rt=>rt.relationshipScore.status==="at-risk"):o==="cooling"?Ke=Ke.filter(rt=>rt.relationshipScore.status==="cooling"):o==="warm"&&(Ke=Ke.filter(rt=>rt.relationshipScore.status==="warm")),Ke.map(rt=>rt.id)},[y,n,a,o]),Ae=Ee.indexOf(t||""),Me=Ae>0?Ee[Ae-1]:null,ke=Ae1&&Ae!==-1,qe=Ke=>{const rt=new URLSearchParams;n&&rt.set("search",n),a!=="all"&&rt.set("type",a),o!=="all"&&rt.set("status",o);const it=rt.toString();return`/mission-control/contacts/${Ke}${it?`?${it}`:""}`},ve=k.useMemo(()=>{const Ke=((m==null?void 0:m.filter(it=>it.contact_id===t))||[]).map(it=>{var Es,Ts,cr;const It=Se(it.notes);let Vt=((Es=it.action_type)==null?void 0:Es.name)||"Touch",hs=it.notes;if(Vt==="Other"&&((Ts=it.notes)!=null&&Ts.startsWith("["))){const zr=it.notes.indexOf("]");zr>0&&(Vt=it.notes.substring(1,zr),hs=it.notes.substring(zr+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:it.id,type:"touch",completed_at:it.completed_at,name:Vt,color:((cr=it.action_type)==null?void 0:cr.color)||"#3B82F6",notes:hs,videoId:It}}),rt=((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[...Ke,...rt].sort((it,It)=>new Date(It.completed_at).getTime()-new Date(it.completed_at).getTime())},[m,f,t]),dt=()=>{var Ke;l&&(P({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:((Ke=l.tags)==null?void 0:Ke.map(rt=>rt.relationship_type_id))||[]}),M(!0))},pe=async()=>{await _.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),M(!1)},Ue=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},et=((Ge=u==null?void 0:u.find(Ke=>Ke.id===$))==null?void 0:Ge.name)==="Other",Ce=async()=>{if(!$||et&&!Q.trim())return;const Ke=Y?new Date(Y.getFullYear(),Y.getMonth(),Y.getDate(),12,0,0).toISOString():void 0,rt=et?`[${Q.trim()}]${V?" — "+V:""}`:V;await j.mutateAsync({contactId:t,actionTypeId:$,notes:rt,completedAt:Ke}),q(!1),z(null),X(""),J(void 0),ce("")},Je=(Ke,rt)=>{ge&&l?(ue({email:Ke,name:rt||`${l.first_name} ${l.last_name||""}`.trim()}),he(!0)):window.location.href=`mailto:${Ke}`};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(G,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(tl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Oe&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>Me&&s(qe(Me)),disabled:!Me,className:"px-2",children:[e.jsx(tl,{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:[Ae+1," of ",Ee.length]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>ke&&s(qe(ke)),disabled:!ke,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(G,{variant:"outline",onClick:()=>Je(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(rr,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(G,{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(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(ps,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ke=>Ke.active).map(Ke=>e.jsxs("button",{onClick:()=>z(Ke.id),className:` p-3 rounded-lg border text-left transition-all ${$===Ke.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ke.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ke.description})]},Ke.id))}),et&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ye,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Le,{id:"custom-action-name",value:Q,onChange:Ke=>ce(Ke.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Date (optional — backdate if needed)"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal mt-2",!Y&&"text-muted-foreground"),children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),Y?ds(Y,"PPP"):"Today (default)"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:Y,onSelect:J,disabled:Ke=>Ke>new Date,initialFocus:!0,className:Pt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Tr,{id:"action-notes",value:V,onChange:Ke=>X(Ke.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(G,{onClick:Ce,disabled:!$||et&&!Q.trim()||j.isPending,className:"w-full",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(G,{variant:"outline",onClick:dt,children:[e.jsx(md,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(G,{variant:"destructive",size:"icon",onClick:Ue,children:e.jsx(kr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((lt=l.lead_source_ref)==null?void 0:lt.name)||l.lead_source)&&e.jsx(Ye,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((He=l.lead_source_ref)==null?void 0:He.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:()=>Je(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(rr,{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(Nn,{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(twe,{contact:l}),(We=l.tags)==null?void 0:We.map(Ke=>{const rt=c==null?void 0:c.find(it=>it.id===Ke.relationship_type_id);return rt?e.jsx(Ye,{variant:"secondary",className:"text-xs",children:rt.name},Ke.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Z_s,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"md:col-span-2",children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Contact Information"})}),e.jsx(De,{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(ye,{htmlFor:"first_name",children:"First Name"}),e.jsx(Le,{id:"first_name",value:I.first_name,onChange:Ke=>P({...I,first_name:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Le,{id:"last_name",value:I.last_name,onChange:Ke=>P({...I,last_name:Ke.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",value:I.email,onChange:Ke=>P({...I,email:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(Le,{id:"phone",value:I.phone,onChange:Ke=>P({...I,phone:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"address",children:"Street Address"}),e.jsx(Le,{id:"address",value:I.address,onChange:Ke=>P({...I,address:Ke.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(ye,{htmlFor:"city",children:"City"}),e.jsx(Le,{id:"city",value:I.city,onChange:Ke=>P({...I,city:Ke.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(Le,{id:"state",value:I.state,onChange:Ke=>P({...I,state:Ke.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Le,{id:"zip_code",value:I.zip_code,onChange:Ke=>P({...I,zip_code:Ke.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(ye,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Le,{id:"birthday",type:"date",value:I.birthday,onChange:Ke=>P({...I,birthday:Ke.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Le,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:Ke=>P({...I,home_anniversary:Ke.target.value})})]})]}),e.jsx(Qo,{}),e.jsx(swe,{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:Ke=>N.mutate({contactId:t,spouseContactId:Ke}),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(ye,{htmlFor:"company_name",children:"Company"}),e.jsx(Le,{id:"company_name",value:I.company_name,onChange:Ke=>P({...I,company_name:Ke.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Le,{id:"job_title",value:I.job_title,onChange:Ke=>P({...I,job_title:Ke.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(_it,{value:I.lead_source_id||"",onChange:Ke=>P({...I,lead_source_id:Ke})}),e.jsxs("div",{children:[e.jsx(ye,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:c==null?void 0:c.filter(Ke=>Ke.active).map(Ke=>{var rt;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Mo,{checked:(rt=I.tagIds)==null?void 0:rt.includes(Ke.id),onCheckedChange:it=>{var It;P(it?{...I,tagIds:[...I.tagIds||[],Ke.id]}:{...I,tagIds:(It=I.tagIds)==null?void 0:It.filter(Vt=>Vt!==Ke.id)})}}),e.jsx("span",{className:"text-sm",children:Ke.name})]},Ke.id)})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:I.notes,onChange:Ke=>P({...I,notes:Ke.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{onClick:pe,disabled:_.isPending,children:"Save Changes"}),e.jsx(G,{variant:"outline",onClick:()=>M(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[ve.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ds(new Date(ve[0].completed_at),"MMM d, yyyy")," ","(",ve[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(rr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>Je(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(Nn,{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(aa,{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(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ds(Fl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ds(Fl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ds(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(Qo,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(swe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ke=>N.mutate({contactId:t,spouseContactId:Ke}),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(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:l.job_title&&l.company_name?`${l.job_title} at ${l.company_name}`:l.job_title||l.company_name})]})]}),e.jsx(Qo,{}),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:(tt=l.tags)!=null&&tt.length?l.tags.map(Ke=>{var rt;return e.jsx(Ye,{variant:"secondary",children:(rt=Ke.relationship_type)==null?void 0:rt.name},Ke.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),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(m_s,{contact:l,onLogTouch:()=>q(!0)}),e.jsx(Mws,{contactId:t}),e.jsx(gws,{contactId:t}),e.jsx(yws,{contactId:t}),e.jsx(bws,{contactId:t,contactName:l.first_name}),e.jsx(_ws,{contactId:t,contactName:l.first_name}),e.jsx(Sws,{contactId:t}),e.jsx(Nws,{contactId:t}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Activity Log"})}),e.jsx(De,{children:ve.length>0?e.jsx("div",{className:"space-y-4",children:ve.map(Ke=>{var rt;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:Ke.color},children:Ke.type==="popby"?e.jsx(bo,{className:"h-4 w-4"}):(rt=Ke.name)==null?void 0:rt.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:Ke.name}),Ke.videoId&&e.jsxs(G,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>re(Ke.videoId),children:[e.jsx(sl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ds(new Date(Ke.completed_at),"MMM d, yyyy h:mm a")}),Ke.notes&&!Ke.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ke.notes})]})]},Ke.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(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Ki,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:g.map(Ke=>{var rt,it;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(rt=Ke.video)!=null&&rt.thumbnail_url?e.jsx("img",{src:Ke.video.thumbnail_url,alt:Ke.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>re(Ke.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:()=>re(Ke.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=Ke.video)==null?void 0:it.title)||"Untitled Video"]}),e.jsxs(G,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>re(Ke.video_id),children:[e.jsx(sl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ds(new Date(Ke.created_at),"MMM d, yyyy h:mm a")}),Ke.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ke.message,'"']})]})]},Ke.id)})})})]}),Be&&Be.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Fn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:Be.map(Ke=>e.jsxs(fs,{children:[e.jsx(Oi,{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(rr,{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:Ke.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ke.to_email," · ",ds(new Date(Ke.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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5 text-sky-500"}),Ke.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ke.to_email," · ",ds(new Date(Ke.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:Ke.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ke.subject}`})})]})]},Ke.id))})})]})]}),e.jsx(fs,{open:!!ne,onOpenChange:Ke=>!Ke&&re(null),children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsx(vs,{children:"Video Preview"})}),ne&&e.jsx(kws,{videoId:ne})]})})]})]})}),ge&&l&&xe&&e.jsx(X1,{open:oe,onOpenChange:he,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:xe.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(G,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const k7e={Crown:zm,FileText:wn,Users:ur,Globe:Nd,Star:ea,Phone:Nn,MessageSquare:Ki,PenTool:X_,Video:An,Gift:bo},Pye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Aws(){var tt,Ke;const t=ar(),{user:s}=Fs(),{data:r}=Rf(),{data:n}=GLt(),{data:a}=JLt(),{data:o}=LQe(),{data:l}=nR(),{data:i}=HLt(),c=e8t(),u=WLt(),m=ZLt(),f=YLt(),g=QLt(),y=XLt(),_=KLt(),[w,j]=k.useState(null),[N,S]=k.useState(!1),[M,I]=k.useState(null),[P,O]=k.useState(""),[q,$]=k.useState(""),[z,V]=k.useState([]),[X,Y]=k.useState(null),[J,Q]=k.useState(null),[ce,ne]=k.useState(!1),[re,oe]=k.useState(""),[he,xe]=k.useState(""),[ue,ge]=k.useState(""),[_e,Be]=k.useState(""),Se=(rt,it)=>a==null?void 0:a.some(It=>It.plan_id===rt&&It.relationship_type_id===it&&It.active),Ee=rt=>a==null?void 0:a.find(it=>it.relationship_type_id===rt&&it.active),Ae=async(rt,it)=>{const It=Se(rt,it);await c.mutateAsync({planId:rt,relationshipTypeId:it,active:!It})},Me=(n==null?void 0:n.filter(rt=>rt.active&&!rt.owner_user_id))||[],ke=(n==null?void 0:n.filter(rt=>rt.owner_user_id===(s==null?void 0:s.id)))||[],Oe=r==null?void 0:r.find(rt=>rt.id===w),qe=w?Ee(w):null,ve=n==null?void 0:n.find(rt=>rt.id===(qe==null?void 0:qe.plan_id)),dt=async()=>{if(!P.trim())return;const rt=await u.mutateAsync({name:P,description:q});rt&&z.length>0&&await g.mutateAsync({planId:rt.id,items:z}),Xe()},pe=async()=>{!P.trim()||!M||(await m.mutateAsync({id:M,name:P,description:q}),await g.mutateAsync({planId:M,items:z}),Xe())},Ue=rt=>{var it;I(rt.id),O(rt.name),$(rt.description||""),V(((it=rt.items)==null?void 0:it.map(It=>({month_number:It.month_number,action_type_id:It.action_type_id,default_script_id:It.default_script_id||void 0,notes:It.notes||void 0})))||[]),S(!0)},Xe=()=>{S(!1),I(null),O(""),$(""),V([])},et=(rt,it)=>{Q(it)},Ce=(rt,it,It)=>{V(Vt=>[...Vt.filter(Es=>Es.month_number!==rt),{month_number:rt,action_type_id:it,default_script_id:It}]),Y(null),Q(null)},Je=rt=>{V(it=>it.filter(It=>It.month_number!==rt))},Ge=async()=>{if(!re.trim()||!he.trim()||!J)return;const rt=await y.mutateAsync({actionTypeId:J,title:re,scriptBody:he,emailSubject:ue||void 0,tone:_e||void 0});rt&&X!==null&&Ce(X,J,rt.id),ne(!1),oe(""),xe(""),ge(""),Be("")},lt=J?i==null?void 0:i.filter(rt=>rt.action_type_id===J&&rt.active):[],He=rt=>k7e[rt||"Phone"]||Nn,We=rt=>k7e[rt||"Users"]||ur;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(G,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(tl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(G,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(qs,{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(rt=>rt.active).map(rt=>{const it=We(rt.icon),It=(o==null?void 0:o[rt.id])||0,Vt=Ee(rt.id),hs=n==null?void 0:n.find(Ts=>Ts.id===(Vt==null?void 0:Vt.plan_id)),Es=w===rt.id;return e.jsxs("button",{onClick:()=>j(rt.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Es?"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:rt.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[It," contacts"]})]}),hs?e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[e.jsx(wi,{className:"h-3 w-3 mr-1"}),hs.name.split(" ")[0]]}):e.jsx(Ye,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},rt.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&Oe?e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[(()=>{const rt=We(Oe.icon);return e.jsx(rt,{className:"h-5 w-5"})})(),Oe.name," Touchpoint Plan"]}),e.jsxs(vr,{children:["Choose a plan for your ",Oe.name," contacts"]})]}),e.jsxs(De,{className:"space-y-6",children:[ve&&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(wi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",ve.name]}),ve.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ve.description})]}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>Ae(ve.id,w),children:"Disable"})]}),ve.items&&ve.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(fn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Pye.map((rt,it)=>{var Es,Ts;const It=((Es=ve.items)==null?void 0:Es.filter(cr=>cr.month_number===it+1))||[],Vt=(Ts=It[0])==null?void 0:Ts.action_type,hs=Vt?He(Vt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${It.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:rt}),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:ve?"Switch to a Different Plan":"Choose a Plan"}),Me.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"}),Me.map(rt=>{var It;const it=(ve==null?void 0:ve.id)===rt.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:rt.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((It=rt.items)==null?void 0:It.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:_.isPending,onClick:()=>{const Vt=`${rt.name} (Copy)`;_.mutate({sourcePlanId:rt.id,newName:Vt})},children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Ae(rt.id,w),children:it?"Active":"Use This"})]})]},rt.id)})]}),ke.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),ke.map(rt=>{var It;const it=(ve==null?void 0:ve.id)===rt.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:rt.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((It=rt.items)==null?void 0:It.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ue(rt),children:e.jsx(r0,{className:"h-4 w-4"})}),e.jsx(G,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(rt.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})}),e.jsx(G,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>Ae(rt.id,w),children:it?"Active":"Use This"})]})]},rt.id)})]}),Me.length===0&&ke.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(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(fn,{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(Pe,{className:"bg-muted/50",children:e.jsx(De,{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:rt=>{rt?S(!0):Xe()},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ye,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Le,{id:"plan-name",value:P,onChange:rt=>O(rt.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Tr,{id:"plan-description",value:q,onChange:rt=>$(rt.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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:Pye.map((rt,it)=>{const It=it+1,Vt=z.find(Ts=>Ts.month_number===It),hs=Vt?l==null?void 0:l.find(Ts=>Ts.id===Vt.action_type_id):null,Es=hs?He(hs.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Y(X===It?null:It),className:` w-full p-3 rounded-lg border text-center transition-all ${Vt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${X===It?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:rt}),Es?e.jsx(Es,{className:"h-5 w-5 mx-auto mt-1",style:{color:(hs==null?void 0:hs.color)||"#3B82F6"}}):e.jsx(qs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Vt&&e.jsx("button",{type:"button",onClick:Ts=>{Ts.stopPropagation(),Je(It)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Er,{className:"h-3 w-3"})})]},it)})}),X!==null&&!J&&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 ",Pye[X-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(rt=>rt.active).map(rt=>{const it=He(rt.icon);return e.jsxs("button",{type:"button",onClick:()=>et(X,rt.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:rt.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:rt.name})]},rt.id)})})]}),X!==null&&J&&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(G,{variant:"ghost",size:"sm",onClick:()=>Q(null),children:[e.jsx(tl,{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:()=>Ce(X,J),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),lt==null?void 0:lt.map(rt=>e.jsx("button",{type:"button",onClick:()=>Ce(X,J,rt.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:rt.title}),rt.tone&&e.jsx(Ye,{variant:"secondary",className:"text-xs mt-1",children:rt.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[rt.script_body.substring(0,100),"..."]})]})},rt.id)),e.jsxs("button",{type:"button",onClick:()=>ne(!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(qs,{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"})]})]})]})]})]}),z.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[z.length," touchpoint",z.length!==1?"s":""," per year"]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:Xe,children:"Cancel"}),e.jsxs(G,{onClick:M?pe:dt,disabled:!P.trim()||u.isPending||m.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),M?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ne,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsx(vs,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Le,{id:"script-title",value:re,onChange:rt=>oe(rt.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Rs,{value:_e,onValueChange:Be,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select tone..."})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"friendly",children:"Friendly"}),e.jsx(ft,{value:"professional",children:"Professional"}),e.jsx(ft,{value:"casual",children:"Casual"}),e.jsx(ft,{value:"formal",children:"Formal"})]})]})]}),((Ke=(tt=l==null?void 0:l.find(rt=>rt.id===J))==null?void 0:tt.name)==null?void 0:Ke.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Le,{id:"script-email-subject",value:ue,onChange:rt=>ge(rt.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Tr,{id:"script-body",value:he,onChange:rt=>xe(rt.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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsxs(G,{onClick:Ge,disabled:!re.trim()||!he.trim()||y.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}function Ews(t,s,r,n){const a=u=>u*Math.PI/180,l=a(r-t),i=a(n-s),c=Math.sin(l/2)**2+Math.cos(a(t))*Math.cos(a(r))*Math.sin(i/2)**2;return 2*3958.8*Math.asin(Math.sqrt(c))}const Nit="popby_geocode_cache_v1";function Pws(){try{return JSON.parse(localStorage.getItem(Nit)||"{}")}catch{return{}}}function Iws(t){try{localStorage.setItem(Nit,JSON.stringify(t))}catch{}}function Lws({contacts:t,onLogPopby:s}){const[r,n]=k.useState(null),[a,o]=k.useState("idle"),[l,i]=k.useState(5),[c,u]=k.useState(""),[m,f]=k.useState(new Map),[g,y]=k.useState(!1);k.useEffect(()=>{(async()=>{const{data:S}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&u(S.value)})()},[]);const _=k.useMemo(()=>t.filter(S=>S.isDue&&(S.address||S.city&&S.state||S.zip)),[t]),w=()=>{if(!("geolocation"in navigator)){o("unavailable");return}o("loading"),navigator.geolocation.getCurrentPosition(S=>{n({lat:S.coords.latitude,lng:S.coords.longitude}),o("ok")},()=>{o("denied")},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})};k.useEffect(()=>{if(!c||!r||_.length===0)return;let S=!1;const M=Pws(),I=new Map;_.forEach(O=>{const q=[O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase();M[q]&&I.set(O.id,M[q])}),f(new Map(I));const P=_.filter(O=>!([O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase()in M));if(P.length!==0)return y(!0),(async()=>{const O=[...P],q=async()=>{var $,z;for(;O.length&&!S;){const V=O.shift(),X=[V.address,V.city,V.state,V.zip].filter(Boolean),Y=X.join("|").toLowerCase(),J=X.join(", ");try{const ce=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(J)}.json?limit=1&access_token=${c}`)).json();if((z=($=ce==null?void 0:ce.features)==null?void 0:$[0])!=null&&z.center){const[ne,re]=ce.features[0].center;M[Y]={lat:re,lng:ne},I.set(V.id,{lat:re,lng:ne})}else M[Y]=null}catch{}}};await Promise.all([q(),q(),q(),q()]),S||(Iws(M),f(new Map(I)),y(!1))})(),()=>{S=!0}},[c,r,_]);const j=k.useMemo(()=>{if(!r)return[];const S=[];return _.forEach(M=>{const I=m.get(M.id);if(!I)return;const P=Ews(r.lat,r.lng,I.lat,I.lng);P<=l&&S.push({...M,distanceMiles:P,lat:I.lat,lng:I.lng})}),S.sort((M,I)=>M.distanceMiles-I.distanceMiles)},[r,_,m,l]),N=S=>{const I=/iPad|iPhone|iPod/.test(navigator.userAgent)?`https://maps.apple.com/?daddr=${S.lat},${S.lng}`:`https://www.google.com/maps/dir/?api=1&destination=${S.lat},${S.lng}`;window.open(I,"_blank","noopener")};return e.jsxs(Pe,{className:"border-primary/30 bg-gradient-to-br from-primary/5 to-transparent",children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(XM,{className:"h-5 w-5 text-primary"}),"Nearby Now"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Due contacts within driving distance — perfect for errand-day pop-bys."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Rs,{value:String(l),onValueChange:S=>i(Number(S)),children:[e.jsx(Ls,{className:"w-[110px] h-9",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"2",children:"2 miles"}),e.jsx(ft,{value:"5",children:"5 miles"}),e.jsx(ft,{value:"10",children:"10 miles"}),e.jsx(ft,{value:"25",children:"25 miles"})]})]}),e.jsxs(G,{size:"sm",variant:a==="ok"?"outline":"default",onClick:w,disabled:a==="loading",children:[a==="loading"?e.jsx(zo,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(XM,{className:"h-4 w-4 mr-1"}),a==="ok"?"Refresh":"Use my location"]})]})]})}),e.jsxs(De,{className:"space-y-3",children:[a==="idle"&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:[e.jsx(aa,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"Tap ",e.jsx("span",{className:"font-medium text-foreground",children:'"Use my location"'})," to see who's close by right now."]}),a==="denied"&&e.jsxs("div",{className:"text-center py-6 text-sm text-destructive flex flex-col items-center gap-2",children:[e.jsx(ul,{className:"h-6 w-6"}),"Location access was blocked. Enable it in your browser to use Nearby Now."]}),a==="unavailable"&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"Geolocation isn't available on this device."}),a==="ok"&&!c&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"Mapping isn't configured yet — ask an admin to add the Mapbox token."}),a==="ok"&&c&&_.length===0&&e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"No due contacts have addresses yet. Add street addresses to your sphere to power this."}),a==="ok"&&c&&_.length>0&&g&&j.length===0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ws,{className:"h-14 w-full"}),e.jsx(ws,{className:"h-14 w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Locating contacts…"})]}),a==="ok"&&c&&!g&&j.length===0&&_.length>0&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:["No due contacts within ",l," miles. Try widening the radius."]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ye,{variant:"secondary",className:"font-medium",children:[j.length," nearby"]}),g&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zo,{className:"h-3 w-3 animate-spin"})," still locating…"]})]}),e.jsx("div",{className:"space-y-2",children:j.map(S=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg bg-card border hover:border-primary/40 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-medium truncate",children:[S.first_name," ",S.last_name]}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:S.distanceMiles<1?`${(S.distanceMiles*5280).toFixed(0)} ft`:`${S.distanceMiles.toFixed(1)} mi`}),S.daysOverdue>0&&e.jsxs(Ye,{variant:"destructive",className:"text-xs",children:[S.daysOverdue,"d overdue"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[S.address,S.city,S.state].filter(Boolean).join(", ")})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[S.phone&&e.jsx(G,{size:"icon",variant:"ghost",asChild:!0,className:"h-9 w-9",title:"Call",children:e.jsx("a",{href:`tel:${S.phone}`,children:e.jsx(Nn,{className:"h-4 w-4"})})}),e.jsx(G,{size:"icon",variant:"ghost",onClick:()=>N(S),className:"h-9 w-9",title:"Directions",children:e.jsx(OL,{className:"h-4 w-4"})}),e.jsxs(G,{size:"sm",onClick:()=>s(S),children:[e.jsx(bo,{className:"h-4 w-4 mr-1"}),"Log"]})]})]},S.id))})]})]})]})}const Dws="0dde5abb-0005-4c8c-a471-30d0cbc9e280",Ows=[{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 Rws(){const t=ar(),s=pit(),{data:r}=i_s(),{data:n}=Rf(),{data:a}=wSe(),{data:o}=rme(90),{data:l}=nm(),i=u_s(),c=c_s(),u=l_s(),m=d_s(),{data:f=[],isLoading:g}=pt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ne}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",Dws).order("publish_date",{ascending:!1});if(ne)throw ne;const{data:re}=await H.from("template_likes").select("template_id"),{data:oe}=await H.from("template_comments").select("template_id"),he=new Map;re==null||re.forEach(ue=>{he.set(ue.template_id,(he.get(ue.template_id)||0)+1)});const xe=new Map;return oe==null||oe.forEach(ue=>{xe.set(ue.template_id,(xe.get(ue.template_id)||0)+1)}),(ce||[]).map(ue=>({...ue,likesCount:he.get(ue.id)||0,commentsCount:xe.get(ue.id)||0}))}}),y=ce=>{const ne=l==null?void 0:l.find(re=>re.id===ce);return ne?`${ne.first_name} ${ne.last_name||""}`.trim():"Unknown"},_=ce=>{if(!ce)return null;const ne=r==null?void 0:r.find(re=>re.id===ce);return(ne==null?void 0:ne.name)||null},[w,j]=k.useState(null),[N,S]=k.useState(!1),[M,I]=k.useState(!1),[P,O]=k.useState(!1),[q,$]=k.useState({popby_item_id:"",notes:""}),[z,V]=k.useState({name:"",description:""}),X=async()=>{w&&(await c.mutateAsync({contact_id:w.id,popby_item_id:q.popby_item_id||void 0,notes:q.notes||void 0}),S(!1),j(null),$({popby_item_id:"",notes:""}))},Y=async()=>{z.name.trim()&&(await u.mutateAsync({name:z.name.trim(),description:z.description.trim()||void 0}),O(!1),V({name:"",description:""}))},J=async(ce,ne)=>{await m.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ne)})},Q=ce=>{var re;const ne=a==null?void 0:a.find(oe=>oe.relationship_type_id===ce);return((re=ne==null?void 0:ne.frequency_days)==null?void 0:re.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(Pe,{children:e.jsxs(De,{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(Pe,{children:e.jsxs(De,{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(Pe,{children:e.jsxs(De,{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(G,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(aa,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(G,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(el,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(G,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ga,{defaultValue:"due",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"due",children:"Due for Popby"}),e.jsx(ss,{value:"activity",children:"Recent Activity"}),e.jsx(ss,{value:"library",children:"Popby Library"}),e.jsx(ss,{value:"templates",children:"Popby Templates"})]}),e.jsxs(bs,{value:"due",className:"space-y-4 mt-4",children:[e.jsx(Lws,{contacts:s||[],onLogPopby:ce=>{j(ce),S(!0)}}),!s||s.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(bo,{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(ce=>e.jsx(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(De,{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:[ce.first_name," ",ce.last_name]}),ce.daysOverdue>0&&e.jsxs(Ye,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(Ye,{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:[ce.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(aa,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(ne=>{var re;return(re=ne.relationship_type)==null?void 0:re.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ds(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(G,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ce.phone}`,children:e.jsx(Nn,{className:"h-4 w-4"})})}),e.jsxs(G,{size:"sm",onClick:()=>{j(ce),S(!0)},children:[e.jsx(wi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})]}),e.jsx(bs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(mn,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(De,{className:"space-y-3",children:o.map(ce=>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(bo,{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:y(ce.contact_id)}),_(ce.popby_item_id)&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:_(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ds(new Date(ce.completed_at),"MMM d, yyyy h:mm a")}),ce.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ce.notes})]})]},ce.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(ce=>e.jsx(Pe,{children:e.jsx(De,{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(bo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ce.description}),!ce.owner_user_id&&e.jsx(Ye,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(Pe,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(De,{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(qs,{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((ce,ne)=>e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsx(ws,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ws,{className:"h-5 w-3/4 mb-2"}),e.jsx(ws,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ws,{className:"h-5 w-16"}),e.jsx(ws,{className:"h-5 w-20"})]})]})},ne))}),!g&&f.length===0&&e.jsx(Pe,{children:e.jsxs(De,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Al,{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(ce=>e.jsxs(Pe,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ce.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ce.preview_image_url?e.jsx("img",{src:ce.preview_image_url,alt:ce.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(De,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Ode(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(Ye,{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(ah,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Uc,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(G,{size:"sm",className:"w-full gap-2",onClick:ne=>{ne.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(fs,{open:N,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsxs(vs,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Popby Item (optional)"}),e.jsxs(Rs,{value:q.popby_item_id,onValueChange:ce=>$(ne=>({...ne,popby_item_id:ce})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a popby item..."})}),e.jsx(Ds,{children:r==null?void 0:r.map(ce=>e.jsx(ft,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Notes (optional)"}),e.jsx(Tr,{placeholder:"Any notes about this popby...",value:q.notes,onChange:ce=>$(ne=>({...ne,notes:ce.target.value}))})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(G,{onClick:X,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:M,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(js,{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(ce=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(ye,{className:"font-medium",children:ce.name}),e.jsxs(Rs,{value:Q(ce.id),onValueChange:ne=>J(ce.id,ne),children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:Ows.map(ne=>e.jsx(ft,{value:ne.value,children:ne.label},ne.value))})]})]},ce.id))]}),e.jsx(Rn,{children:e.jsx(G,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(fs,{open:P,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{children:"Name *"}),e.jsx(Le,{placeholder:"e.g., Homemade cookies",value:z.name,onChange:ce=>V(ne=>({...ne,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{placeholder:"Optional description...",value:z.description,onChange:ce=>V(ne=>({...ne,description:ce.target.value}))})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(G,{onClick:Y,disabled:!z.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const Fws=A3({property_address:wc().min(1,"Property address is required"),city:wc().optional(),state:wc().optional(),zip:wc().optional(),transaction_type:dKe(["buyer","seller"]),close_date:wc().min(1,"Close date is required"),sale_price:c8().min(0,"Sale price must be positive"),commission_amount:c8().optional(),lead_source_id:wc().optional(),client_type_id:wc().optional(),contact_id:wc().optional(),notes:wc().optional(),is_win:VCt()});function kit({open:t,onOpenChange:s,transaction:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,m]=k.useState(""),f=Rue(),g=$8t(),{data:y}=_E(),{data:_}=Rf(),{data:w}=nm(),j=Oue(),N=qNe(),{data:S}=Fue(),M=(S==null?void 0:S.show_commission)??!0,I=Cue({resolver:Mue(Fws),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?I.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):I.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,I]);const P=async z=>{const V={property_address:z.property_address,transaction_type:z.transaction_type,close_date:z.close_date,sale_price:z.sale_price,is_win:z.is_win,commission_amount:z.commission_amount||null,lead_source_id:z.lead_source_id||null,client_type_id:z.client_type_id||null,contact_id:z.contact_id||null,city:z.city||null,state:z.state||null,zip:z.zip||null,notes:z.notes||null};r?await g.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},O=async()=>{if(!o.trim())return;const[z,...V]=o.trim().split(" "),X=V.join(" ")||null,Y=await j.mutateAsync({first_name:z,last_name:X,tagIds:[]});Y&&(I.setValue("contact_id",Y.id),l(""),c(!1),a(!1))},q=async()=>{if(!u.trim())return;const z=await N.mutateAsync(u.trim());z&&(I.setValue("lead_source_id",z.id),m(""))},$=w==null?void 0:w.find(z=>z.id===I.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(js,{children:e.jsx(vs,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Li,{className:"max-h-[70vh] pr-4",children:e.jsx(Tue,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(P),className:"space-y-4",children:[e.jsx(Yc,{control:I.control,name:"property_address",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Property Address *"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"123 Main St",...z})}),e.jsx(Em,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Yc,{control:I.control,name:"city",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"City"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"City",...z})})]})}),e.jsx(Yc,{control:I.control,name:"state",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"State"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"TX",...z})})]})}),e.jsx(Yc,{control:I.control,name:"zip",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Zip"}),e.jsx(Fc,{children:e.jsx(Le,{placeholder:"75001",...z})})]})})]}),e.jsx(Yc,{control:I.control,name:"transaction_type",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Transaction Type *"}),e.jsxs(Rs,{onValueChange:z.onChange,value:z.value,children:[e.jsx(Fc,{children:e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select type"})})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"buyer",children:"Buyer"}),e.jsx(ft,{value:"seller",children:"Seller"})]})]}),e.jsx(Em,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Yc,{control:I.control,name:"close_date",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Close Date *"}),e.jsx(Fc,{children:e.jsx(Le,{type:"date",...z})}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:I.control,name:"sale_price",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Sale Price *"}),e.jsx(Fc,{children:e.jsx(Le,{type:"number",placeholder:"0",...z,onChange:V=>z.onChange(Number(V.target.value))})}),e.jsx(Em,{})]})})]}),M&&e.jsx(Yc,{control:I.control,name:"commission_amount",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Commission"}),e.jsx(Fc,{children:e.jsx(Le,{type:"number",placeholder:"0",...z,value:z.value??"",onChange:V=>z.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Yc,{control:I.control,name:"lead_source_id",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Lead Source"}),e.jsxs(Rs,{onValueChange:z.onChange,value:z.value||"",children:[e.jsx(Fc,{children:e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select source"})})}),e.jsx(Ds,{children:y==null?void 0:y.map(V=>e.jsx(ft,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Add custom source...",value:u,onChange:z=>m(z.target.value),className:"flex-1"}),e.jsx(G,{type:"button",variant:"outline",size:"icon",onClick:q,disabled:!u.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsx(Yc,{control:I.control,name:"client_type_id",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Client Type"}),e.jsxs(Rs,{onValueChange:z.onChange,value:z.value||"",children:[e.jsx(Fc,{children:e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select client type"})})}),e.jsx(Ds,{children:_==null?void 0:_.map(V=>e.jsx(ft,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Yc,{control:I.control,name:"contact_id",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Client Contact"}),e.jsxs(Vo,{open:n,onOpenChange:a,children:[e.jsx(Ho,{asChild:!0,children:e.jsx(Fc,{children:e.jsxs(G,{variant:"outline",role:"combobox",className:Pt("w-full justify-between",!z.value&&"text-muted-foreground"),children:[$?`${$.first_name} ${$.last_name||""}`.trim():"Select contact",e.jsx(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs($o,{className:"w-full p-0",align:"start",children:[e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search contacts..."}),e.jsxs(qx,{children:[e.jsx(Ux,{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(G,{variant:"outline",size:"sm",className:"w-full",onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Vx,{children:w==null?void 0:w.map(V=>e.jsxs(_p,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{z.onChange(V.id),a(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",V.id===z.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(Le,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{size:"sm",onClick:O,disabled:!o.trim()||j.isPending,children:"Add Contact"}),e.jsx(G,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Yc,{control:I.control,name:"notes",render:({field:z})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Notes"}),e.jsx(Fc,{children:e.jsx(Tr,{placeholder:"Any notes about this transaction...",...z})})]})}),e.jsx(Yc,{control:I.control,name:"is_win",render:({field:z})=>e.jsxs(Oc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Rc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Fc,{children:e.jsx(qr,{checked:z.value,onCheckedChange:z.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:f.isPending||g.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function SSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=k.useState(null),[i,c]=k.useState(null),[u,m]=k.useState(""),[f,g]=k.useState("all"),[y,_]=k.useState("all"),[w,j]=k.useState("all"),[N,S]=k.useState(!1),M=q8t(),I=Rue(),{data:P}=_E(),{data:O}=Rf(),q=UE(),$=X=>{const{id:Y,created_at:J,updated_at:Q,lead_source:ce,client_type:ne,contact:re,...oe}=X;I.mutate(oe)},z=()=>{i&&(M.mutate(i),c(null))},V=t.filter(X=>{var re,oe,he,xe;const Y=u===""||X.property_address.toLowerCase().includes(u.toLowerCase())||((oe=(re=X.contact)==null?void 0:re.first_name)==null?void 0:oe.toLowerCase().includes(u.toLowerCase()))||((xe=(he=X.contact)==null?void 0:he.last_name)==null?void 0:xe.toLowerCase().includes(u.toLowerCase())),J=f==="all"||X.transaction_type===f,Q=y==="all"||X.lead_source_id===y,ce=w==="all"||X.client_type_id===w,ne=!N||X.is_win;return Y&&J&&Q&&ce&&ne});return r?e.jsx(Pe,{children:e.jsx(De,{className:"p-6 space-y-4",children:[1,2,3].map(X=>e.jsx(ws,{className:"h-16 w-full"},X))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{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(Lt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search...",value:u,onChange:X=>m(X.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Rs,{value:f,onValueChange:g,children:[e.jsx(Ls,{className:"w-[100px]",children:e.jsx($s,{placeholder:"Type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),e.jsx(ft,{value:"buyer",children:"Buyer"}),e.jsx(ft,{value:"seller",children:"Seller"})]})]}),e.jsxs(Rs,{value:y,onValueChange:_,children:[e.jsx(Ls,{className:"w-[130px]",children:e.jsx($s,{placeholder:"Lead Source"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Sources"}),P==null?void 0:P.map(X=>e.jsx(ft,{value:X.id,children:X.name},X.id))]})]}),e.jsxs(G,{variant:N?"default":"outline",size:"sm",onClick:()=>S(!N),children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(De,{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(X=>e.jsxs(Pe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:X.property_address}),X.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]}),e.jsx(Ye,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),JAe(X.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),ec(X.sale_price)]}),s&&X.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),ec(X.commission_amount)]}),X.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),X.lead_source.name]}),X.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),X.contact.first_name," ",X.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[X.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>l(X),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>$(X),children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(X.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})]},X.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[n&&e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Type"}),e.jsx(jt,{children:"Close Date"}),e.jsx(jt,{children:"Sale Price"}),s&&e.jsx(jt,{children:"Commission"}),e.jsx(jt,{children:"Lead Source"}),e.jsx(jt,{children:"Client"}),!a&&e.jsx(jt,{className:"w-[50px]"})]})}),e.jsx(qn,{children:V.map(X=>{var Y;return e.jsxs(ks,{children:[n&&e.jsx(ut,{className:"font-medium text-sm",children:n[X.owner_user_id]||"Unknown"}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.is_win&&e.jsx(rc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:X.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]})]})}),e.jsx(ut,{children:e.jsx(Ye,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})}),e.jsx(ut,{children:JAe(X.close_date)}),e.jsx(ut,{children:ec(X.sale_price)}),s&&e.jsx(ut,{children:X.commission_amount?ec(X.commission_amount):"-"}),e.jsx(ut,{children:((Y=X.lead_source)==null?void 0:Y.name)||"-"}),e.jsx(ut,{children:X.contact?`${X.contact.first_name} ${X.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(ut,{children:e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",children:e.jsx(vx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",children:[e.jsxs(La,{onClick:()=>l(X),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(La,{onClick:()=>$(X),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(La,{onClick:()=>c(X.id),className:"text-destructive",children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},X.id)})})]})})})]}),e.jsx(kit,{open:!!o,onOpenChange:X=>!X&&l(null),transaction:o||void 0}),e.jsx(Tc,{open:!!i,onOpenChange:X=>!X&&c(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Transaction?"}),e.jsx(lc,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:z,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function Sit({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,y)=>{if(!y||y===0)return null;const _=Math.min(g/y*100,100),w=Math.max(y-g,0),j=l>0?w/l:0,N=o/12*100,S=_>=N?"ahead":_>=N*.8?"on-track":"behind";return{percent:_,remaining:w,pace:j,status:S}},c=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),m=n?i(s.totalCommission,t.gci_goal):null,f=g=>{switch(g){case"ahead":return e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(Bo,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(Ye,{variant:"secondary",children:[e.jsx(v0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(Ye,{variant:"destructive",children:[e.jsx(CS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xh,{className:"h-5 w-5 text-primary"}),e.jsxs(Lt,{children:[r," Goals Progress"]})]})}),e.jsx(De,{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(qi,{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(qi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[ec(s.totalVolume,!0)," of ",ec(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 ",ec(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&m&&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(m.status)]}),e.jsx(qi,{value:m.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[ec(s.totalCommission,!0)," of ",ec(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(m.percent),"%"]})]}),m.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",ec(m.pace,!0),"/month"]})]})]})})]})}const zws={light:"",dark:".dark"},Cit=k.createContext(null);function Mit(){const t=k.useContext(Cit);if(!t)throw new Error("useChart must be used within a ");return t}const Tit=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(Cit.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Pt("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(Bws,{id:i,config:n}),e.jsx(wT,{children:r})]})})});Tit.displayName="Chart";const Bws=({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(zws).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},Ait=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:m,nameKey:f,labelKey:g},y)=>{const{config:_}=Mit(),w=k.useMemo(()=>{var P;if(a||!(s!=null&&s.length))return null;const[N]=s,S=`${g||N.dataKey||N.name||"value"}`,M=rwe(_,N,S),I=!g&&typeof l=="string"?((P=_[l])==null?void 0:P.label)||l:M==null?void 0:M.label;return i?e.jsx("div",{className:Pt("font-medium",c),children:i(I,s)}):I?e.jsx("div",{className:Pt("font-medium",c),children:I}):null},[l,i,s,a,c,_,g]);if(!t||!(s!=null&&s.length))return null;const j=s.length===1&&n!=="dot";return e.jsxs("div",{ref:y,className:Pt("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[j?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,S)=>{const M=`${f||N.name||N.dataKey||"value"}`,I=rwe(_,N,M),P=m||N.payload.fill||N.color;return e.jsx("div",{className:Pt("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,S,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Pt("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":j&&n==="dashed"}),style:{"--color-bg":P,"--color-border":P}}),e.jsxs("div",{className:Pt("flex flex-1 justify-between leading-none",j?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[j?w:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});Ait.displayName="ChartTooltip";const $ws=k.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=Mit();return r!=null&&r.length?e.jsx("div",{ref:o,className:Pt("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const c=`${a||i.dataKey||"value"}`,u=rwe(l,i,c);return e.jsxs("div",{className:Pt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});$ws.displayName="ChartLegend";function rwe(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 h9=["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 CSe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{className:"overflow-hidden",children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(De,{className:"overflow-hidden",children:e.jsx(Tit,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(wT,{width:"100%",height:"100%",children:e.jsxs(Zat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(Pat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(y3,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(v3,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(mp,{content:e.jsx(Ait,{})}),e.jsx(B1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(De,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(wT,{width:"100%",height:"100%",children:e.jsxs(Yat,{children:[e.jsx(Y0,{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(jR,{fill:h9[o%h9.length]},`cell-${o}`))}),e.jsx(mp,{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:h9[o%h9.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function qws(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=Lje(s,n,new Date);if(Wve(a))return ds(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Wve(n))return ds(n,"yyyy-MM-dd")}catch{}return null}const Uws=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Vws({open:t,onOpenChange:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!1),[l,i]=k.useState(0),{data:c}=_E(),{data:u}=Rf(),m=Rue(),f=()=>{const N=Uws.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),M=`${N} ${S}`,I=new Blob([M],{type:"text/csv"}),P=URL.createObjectURL(I),O=document.createElement("a");O.href=P,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(P)},g=N=>{const S=N.split(` `).filter(I=>I.trim());if(S.length<2)return[];const M=S[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((I,P)=>{var re,oe,he,xe;const O=[];let q="",$=!1;for(const ue of I)ue==='"'?$=!$:ue===","&&!$?(O.push(q.trim()),q=""):q+=ue;O.push(q.trim());const z=ue=>{var _e;const ge=M.indexOf(ue);return ge>=0?(_e=O[ge])==null?void 0:_e.replace(/^["']|["']$/g,"").trim():""},V=(re=z("transaction_type"))==null?void 0:re.toLowerCase(),X=(oe=z("sale_price"))==null?void 0:oe.replace(/[$,]/g,""),Y=(he=z("commission_amount"))==null?void 0:he.replace(/[$,]/g,""),J=(xe=z("is_win"))==null?void 0:xe.toLowerCase(),Q=z("close_date"),ce=qws(Q);let ne;return z("property_address")?["buyer","seller"].includes(V)?ce?(!X||isNaN(Number(X)))&&(ne="Invalid sale price"):ne=`Invalid date format: "${Q}" - use MM/DD/YYYY or YYYY-MM-DD`:ne='Transaction type must be "buyer" or "seller"':ne="Missing property address",{property_address:z("property_address"),city:z("city"),state:z("state"),zip:z("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(X)||0,commission_amount:Y?Number(Y):null,lead_source_name:z("lead_source"),client_type_name:z("client_type"),is_win:["yes","true","1"].includes(J),notes:z("notes"),error:ne}})},y=N=>{var I;const S=(I=N.target.files)==null?void 0:I[0];if(!S)return;const M=new FileReader;M.onload=P=>{var $;const O=($=P.target)==null?void 0:$.result,q=g(O);n(q)},M.readAsText(S)},_=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let S=0,M=0;for(let I=0;I$.name.toLowerCase()===P.lead_source_name.toLowerCase()),q=u==null?void 0:u.find($=>$.name.toLowerCase()===P.client_type_name.toLowerCase());await m.mutateAsync({property_address:P.property_address,city:P.city||null,state:P.state||null,zip:P.zip||null,transaction_type:P.transaction_type,close_date:P.close_date,sale_price:P.sale_price,commission_amount:P.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:P.notes||null,is_win:P.is_win}),S++}catch(O){M++,console.error("Failed to import transaction:",O)}i(Math.round((I+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)},w=r.filter(N=>!N.error).length,j=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(js,{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(G,{variant:"outline",onClick:f,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(Le,{id:"csv-file",type:"file",accept:".csv",onChange:y})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ye,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),w," valid"]}),j>0&&e.jsxs(Ye,{variant:"destructive",children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),j," errors"]})]}),e.jsx(Li,{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(Ye,{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(Wke,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(Kke,{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(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:_,disabled:w===0||a,children:[e.jsx(ci,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const Hws=A3({transactions_goal:c8().min(0).optional(),volume_goal:c8().min(0).optional(),gci_goal:c8().min(0).optional()});function Gws({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=U8t(),{data:o}=Fue(),l=(o==null?void 0:o.show_commission)??!0,i=Cue({resolver:Mue(Hws),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(js,{children:[e.jsxs(vs,{children:[r," Goals"]}),e.jsx(Gr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Tue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Yc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Transactions Goal"}),e.jsx(Fc,{children:e.jsx(Le,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:m=>u.onChange(m.target.value?Number(m.target.value):void 0)})}),e.jsx(Die,{children:"Total number of deals you want to close"}),e.jsx(Em,{})]})}),e.jsx(Yc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"Volume Goal ($)"}),e.jsx(Fc,{children:e.jsx(Le,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:m=>u.onChange(m.target.value?Number(m.target.value):void 0)})}),e.jsx(Die,{children:"Total sales volume you want to achieve"}),e.jsx(Em,{})]})}),l&&e.jsx(Yc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(Oc,{children:[e.jsx(Rc,{children:"GCI Goal ($)"}),e.jsx(Fc,{children:e.jsx(Le,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:m=>u.onChange(m.target.value?Number(m.target.value):void 0)})}),e.jsx(Die,{children:"Gross commission income target"}),e.jsx(Em,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function MSe({transactions:t,isLoading:s}){const r=k.useRef(null),n=k.useRef(null),a=k.useRef([]),o=k.useRef(null),{isAdmin:l}=Fs(),[i,c]=k.useState(""),[u,m]=k.useState(!0),[f,g]=k.useState(0),[y,_]=k.useState(!1),w=t.filter(N=>N.latitude!=null&&N.longitude!=null),j=t.filter(N=>N.latitude==null||N.longitude==null);return k.useEffect(()=>{(async()=>{m(!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)}m(!1)})()},[]),k.useEffect(()=>{if(!i||j.length===0||y)return;(async()=>{var M;_(!0);let S=0;for(const I of j){const P=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(P)try{const q=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(P)}.json?access_token=${i}&limit=1`)).json();if((M=q.features)!=null&&M[0]){const[$,z]=q.features[0].center;await H.from("scorecard_transactions").update({latitude:z,longitude:$}).eq("id",I.id),I.latitude=z,I.longitude=$,S++}}catch(O){console.error("Geocode error:",O)}}g(S),_(!1)})()},[i,t]),k.useEffect(()=>{if(!r.current||!i||n.current)return;Io.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let S=[-98.5795,39.8283],M=4;if(N.length>0){const I=N.reduce((O,q)=>O+q.longitude,0)/N.length,P=N.reduce((O,q)=>O+q.latitude,0)/N.length;S=[I,P],M=N.length===1?12:10}return n.current=new Io.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:S}),n.current.addControl(new Io.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.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 z;const I=M.transaction_type==="buyer",P=I?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${I?'':''}
`;const q=new Io.Popup({offset:25,closeButton:!0}).setHTML(`
${M.property_address}
${M.city?`
${M.city}${M.state?", "+M.state:""} ${M.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(M.sale_price).toLocaleString()}
Closed: ${Fl(M.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(z=M.lead_source)!=null&&z.name?" · "+M.lead_source.name:""}
${M.contact?`
Client: ${M.contact.first_name} ${M.contact.last_name||""}
`:""}
`),$=new Io.Marker(O).setLngLat([M.longitude,M.latitude]).setPopup(q).addTo(n.current);a.current.push($)}),N.length>1){const M=new Io.LngLatBounds;N.forEach(I=>M.extend([I.longitude,I.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,y]),u||s?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(aa,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",y&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ul,{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 Eit=()=>{const{data:t}=Gx();return pt({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"})},Wws=t=>{const{data:s}=Gx(),{data:r}=Eit();return pt({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 Kws(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 Zws(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function Yws({year:t}){var g;const{data:s,isLoading:r}=Eit(),{data:n,isLoading:a}=Wws(t),o=ar(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:m,teamChartStats:f}=k.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const y=s.map(V=>Kws(V,n));y.sort((V,X)=>X.totalVolume-V.totalVolume);const _={};s.forEach(V=>{_[V.id]=V.name||V.email});const w=n.length,j=n.reduce((V,X)=>V+Number(X.sale_price),0),N=n.reduce((V,X)=>V+(Number(X.commission_amount)||0),0),S=n.filter(V=>V.transaction_type==="buyer").length,M=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var Y;const X=((Y=V.lead_source)==null?void 0:Y.name)||"Unknown";I[X]=(I[X]||0)+1});const P=Object.entries(I).sort((V,X)=>X[1]-V[1])[0],O={};n.forEach(V=>{const X=Fl(V.close_date).toLocaleString("default",{month:"short"});O[X]=(O[X]||0)+1});const $=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:O[V]||0})),z=Object.entries(I).map(([V,X])=>({name:V,count:X})).sort((V,X)=>X.count-V.count);return{aggregate:{totalTxns:w,buyerCount:S,sellerCount:M,totalVolume:j,avgPrice:w>0?j/w:0,totalGCI:N,topSource:P?{name:P[0],count:P[1]}:null,memberCount:s.length},memberStats:y,topPerformer:y[0]||null,agentNameMap:_,teamChartStats:{transactionsByMonth:$,leadSourceBreakdown:z}}},[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(y=>e.jsx(ws,{className:"h-24"},y))}),e.jsx(ws,{className:"h-64"})]}):!i||c.length===0?e.jsx(Pe,{className:"py-12",children:e.jsxs(De,{className:"text-center space-y-2",children:[e.jsx(ur,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ur,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xn,{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(Pe,{children:e.jsxs(De,{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:"Team Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ec(i.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Bo,{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:ec(i.avgPrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{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:"Team GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ec(i.totalGCI,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((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(Pe,{className:"border-primary/30 bg-primary/5",children:e.jsxs(De,{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(_o,{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:ec(u.totalVolume,!0)})]})]})}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Member Performance"})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Transactions"}),e.jsx(jt,{className:"text-center",children:"B / S"}),e.jsx(jt,{className:"text-right",children:"Volume"}),e.jsx(jt,{className:"text-right",children:"Avg Price"}),e.jsx(jt,{className:"text-right",children:"GCI"}),e.jsx(jt,{className:"text-right"})]})}),e.jsx(qn,{children:c.map((y,_)=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[_===0&&y.totalTransactions>0&&e.jsx(_o,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:y.member.avatar_url||void 0}),e.jsx(Mn,{className:"text-xs",children:Zws(y.member.name,y.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:y.member.name||y.member.email}),y.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:y.member.email})]})]})}),e.jsx(ut,{className:"text-center font-semibold",children:y.totalTransactions}),e.jsxs(ut,{className:"text-center text-sm",children:[y.buyerCount," / ",y.sellerCount]}),e.jsx(ut,{className:"text-right font-medium",children:ec(y.totalVolume,!0)}),e.jsx(ut,{className:"text-right text-sm",children:ec(y.averagePrice,!0)}),e.jsx(ut,{className:"text-right font-medium",children:ec(y.totalGCI,!0)}),e.jsx(ut,{className:"text-right",children:e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${y.member.id}`),children:e.jsx(Tn,{className:"h-4 w-4"})})})]},y.member.id))})]})})})]}),e.jsxs(ga,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"transactions",children:[e.jsx(nh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ss,{value:"charts",children:[e.jsx(co,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ss,{value:"map",children:[e.jsx(aa,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(SSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:m,readOnly:!0})}),e.jsx(bs,{value:"charts",children:f&&e.jsx(CSe,{stats:f,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(MSe,{transactions:n||[],isLoading:a})})]})]})}const Pit=new Date().getFullYear(),S7e=Array.from({length:10},(t,s)=>Pit-s);function Qws(){var z;const[t,s]=k.useState(Pit),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[m,f]=k.useState("my"),{data:g}=Gx(),y=(g==null?void 0:g.role)==="team_leader",{data:_,isLoading:w}=UNe(t),{yearStats:j,lifetimeStats:N,showCommission:S}=JQe(t),{data:M,isLoading:I}=XQe(t),{data:P}=Fue(),O=V8t(),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"],X=_.map(ne=>{var re,oe;return[ne.property_address,ne.city||"",ne.state||"",ne.zip||"",ne.transaction_type,ne.close_date,ne.sale_price,...S?[ne.commission_amount||""]:[],((re=ne.lead_source)==null?void 0:re.name)||"",((oe=ne.client_type)==null?void 0:oe.name)||"",ne.contact?`${ne.contact.first_name} ${ne.contact.last_name||""}`.trim():"",ne.is_win?"Yes":"No",ne.notes||""]}),Y=[V,...X].map(ne=>ne.map(re=>`"${String(re).replace(/"/g,'""')}"`).join(",")).join(` `),J=new Blob([Y],{type:"text/csv"}),Q=URL.createObjectURL(J),ce=document.createElement("a");ce.href=Q,ce.download=`transactions-${t}.csv`,ce.click(),URL.revokeObjectURL(Q)},$=!_||_.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"})]}),y&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(G,{variant:m==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(G,{variant:m==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(ur,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),m==="team"&&y?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(Rs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Ls,{className:"w-[120px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:S7e.map(V=>e.jsx(ft,{value:String(V),children:V},V))})]})]}),e.jsx(Yws,{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(Rs,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Ls,{className:"w-[120px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:S7e.map(V=>e.jsx(ft,{value:String(V),children:V},V))})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(el,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsx(Lt,{className:"text-lg",children:"Settings"})}),e.jsx(De,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ye,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(qr,{checked:(P==null?void 0:P.show_commission)??!0,onCheckedChange:V=>O.mutate({show_commission:V})})]})})]}),$&&!w?e.jsx(Pe,{className:"py-12",children:e.jsxs(De,{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(co,{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(G,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(G,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ci,{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(G,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(G,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Xh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(G,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ci,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(G,{variant:"outline",onClick:q,disabled:$,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(G,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:j.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[j.buyerCount,"/",j.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Pe,{children:e.jsxs(De,{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:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ec(j.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ec(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Bo,{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:ec(j.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((z=j.topLeadSource)==null?void 0:z.name)||"-"}),j.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.topLeadSource.count," deals"]})]})}),S&&e.jsx(Pe,{children:e.jsxs(De,{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:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ec(j.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ec(N.totalCommission,!0)," lifetime"]})]})}),S&&j.totalNetToAgent>0&&j.totalNetToAgent!==j.totalCommission&&e.jsx(Pe,{children:e.jsxs(De,{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(ml,{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:ec(j.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ec(N.totalNetToAgent,!0)," lifetime"]})]})})]}),M&&e.jsx(Sit,{goals:M,stats:j,year:t,showCommission:S}),e.jsxs(ga,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"transactions",children:"Transactions"}),e.jsx(ss,{value:"charts",children:"Charts"}),e.jsxs(ss,{value:"map",children:[e.jsx(aa,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(SSe,{transactions:_||[],showCommission:S,isLoading:w})}),e.jsx(bs,{value:"charts",children:e.jsx(CSe,{stats:j,year:t})}),e.jsx(bs,{value:"map",children:e.jsx(MSe,{transactions:_||[],isLoading:w})})]})]})]})]}),e.jsx(kit,{open:r,onOpenChange:n}),e.jsx(Vws,{open:a,onOpenChange:o}),e.jsx(Gws,{open:l,onOpenChange:i,year:t,existingGoals:M})]})}function Iit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Fs(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[m,f]=k.useState(!1);k.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:j,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(j&&j.share_token)i(j);else if(j&&!j.share_token){const{data:S,error:M}=await H.from("listing_shares").update({share_type:"referral_link"}).eq("id",j.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(j){console.error("Error creating share link:",j),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}`:"",y=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")}},_=w=>{const j=encodeURIComponent(g),N=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${N}&body=${j}`);break;case"text":window.open(`sms:?body=${N}%20${j}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${j}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(nn,{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(ye,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:c?"Generating...":g,readOnly:!0,className:"font-mono text-sm"}),e.jsx(G,{onClick:y,disabled:c||!g,variant:m?"default":"outline",children:m?e.jsx(ua,{className:"h-4 w-4"}):e.jsx(yi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{variant:"outline",className:"flex-1",onClick:()=>_("email"),disabled:c,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(G,{variant:"outline",className:"flex-1",onClick:()=>_("text"),disabled:c,children:[e.jsx(Ki,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(G,{variant:"outline",className:"flex-1",onClick:()=>_("facebook"),disabled:c,children:[e.jsx(Au,{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(ye,{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(Tn,{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(ur,{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 Xws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Jws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},e2s={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function m9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,j;const{user:o}=Fs(),{data:l}=GQe(t.id),i=HQe(),[c,u]=k.useState(!1),m=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),f=((w=t.photos)==null?void 0:w.find(N=>N.is_primary))||((j=t.photos)==null?void 0:j[0]),g=(o==null?void 0:o.id)===t.agent_id,y=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(Pe,{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(k0,{className:"h-12 w-12"})}),e.jsx(Ye,{className:`absolute top-2 left-2 ${Xws[t.status]} text-white border-0`,children:Jws[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(ea,{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(G,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:y,children:e.jsx(Ja,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(G,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,title:g?"Copy link":"Share & earn leads",children:g?e.jsx(nd,{className:"h-4 w-4"}):e.jsx(nn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(Iit,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(De,{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:m(t.price)}),t.open_to_referrals&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:[e.jsx(ur,{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(aa,{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(Th,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(au,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(k0,{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(Ye,{variant:"secondary",className:"text-xs",children:e2s[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(Tn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ja,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(G,{variant:"outline",size:"sm",className:"flex-1",onClick:N=>{N.stopPropagation(),r()},children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(G,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(kr,{className:"h-4 w-4"})})]})]})]})}const t2s=[{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"}],s2s=[{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 r2s({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Lt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(G,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Er,{className:"h-4 w-4"})})]})]}),e.jsxs(De,{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(ye,{children:"Status"}),e.jsxs(Rs,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"All statuses"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Statuses"}),t2s.map(a=>e.jsx(ft,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Type"}),e.jsxs(Rs,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"All types"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),s2s.map(a=>e.jsx(ft,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Min Price"}),e.jsx(Le,{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(ye,{children:"Max Price"}),e.jsx(Le,{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(ye,{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 n2s({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(_o,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(f1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(rc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(Ye,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(_o,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(De,{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(nd,{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(xn,{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(f1,{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(_o,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Community Leaderboard"})}),e.jsx(De,{children:e.jsxs(ga,{defaultValue:"sharers",children:[e.jsxs(fa,{className:"w-full",children:[e.jsxs(ss,{value:"sharers",className:"flex-1",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ss,{value:"listers",className:"flex-1",children:[e.jsx(xn,{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 C7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},M7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function a2s(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function i2s({listings:t,isLoading:s}){const r=ar(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),{isAdmin:l}=Fs(),[i,c]=k.useState(""),[u,m]=k.useState(!0),[f,g]=k.useState(!1),y=t.filter(w=>w.latitude!=null&&w.longitude!=null),_=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return k.useEffect(()=>{(async()=>{m(!0);try{const{data:j}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&c(j.value)}catch(j){console.error("Error fetching mapbox token:",j)}m(!1)})()},[]),k.useEffect(()=>{if(!i||_.length===0||f)return;(async()=>{var j;g(!0);for(const N of _){const S=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(S)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((j=I.features)!=null&&j[0]){const[P,O]=I.features[0].center;await H.from("listings").update({latitude:O,longitude:P}).eq("id",N.id),N.latitude=O,N.longitude=P}}catch(M){console.error("Geocode error:",M)}}g(!1)})()},[i,t]),k.useEffect(()=>{if(!n.current||!i||a.current)return;Io.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let j=[-98.5795,39.8283],N=4;if(w.length>0){const S=w.reduce((I,P)=>I+P.longitude,0)/w.length,M=w.reduce((I,P)=>I+P.latitude,0)/w.length;j=[S,M],N=w.length===1?12:10}return a.current=new Io.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:j}),a.current.addControl(new Io.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(j=>j.remove()),o.current=[];const w=t.filter(j=>j.latitude!=null&&j.longitude!=null);if(w.forEach(j=>{var O,q,$;const N=C7e[j.status]||"#10B981",S=((O=j.photos)==null?void 0:O.find(z=>z.is_primary))||((q=j.photos)==null?void 0:q[0]),M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const I=new Io.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${a2s(j.price)}
${j.property_address||""}
${j.city}, ${j.state}
${M7e[j.status]||j.status} ${j.bedrooms?`${j.bedrooms} bed`:""} ${j.bathrooms?`${j.bathrooms} bath`:""}
${($=j.agent)!=null&&$.name?`
Listed by ${j.agent.name}
`:""}
Click to view details →
`),P=new Io.Marker(M).setLngLat([j.longitude,j.latitude]).setPopup(I).addTo(a.current);o.current.push(P)}),w.length>1){const j=new Io.LngLatBounds;w.forEach(N=>j.extend([N.longitude,N.latitude])),a.current.fitBounds(j,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,f]),k.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(aa,{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(C7e).map(([w,j])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:j}}),e.jsx("span",{className:"text-xs",children:M7e[w]})]},w)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[y.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ul,{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 o2s(){var z,V,X,Y,J,Q,ce,ne;const t=ar(),{brokerageId:s}=Fs(),{data:r,isLoading:n}=BQe(),[a,o]=k.useState("feed"),[l,i]=k.useState(!1),[c,u]=k.useState(""),[m,f]=k.useState({sortBy:"newest"}),{data:g,isLoading:y}=$Qe({...m,city:c||m.city}),{data:_,isLoading:w}=S8t(),{data:j,isLoading:N}=qQe(),{data:S,isLoading:M}=A8t(),{data:I,isLoading:P}=I8t(),{data:O}=P8t(),q=VQe(),$=async re=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await q.mutateAsync(re),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(G,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{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(Pe,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(xn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("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(Pe,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Ja,{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(Pe,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(sS,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(ur,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((z=S==null?void 0:S.sent)==null?void 0:z.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(ga,{value:a,onValueChange:o,children:[e.jsxs(fa,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ss,{value:"feed",children:"Community Feed"}),s&&e.jsx(ss,{value:"brokerage",children:"Brokerage"}),e.jsx(ss,{value:"my-listings",children:"My Listings"}),e.jsx(ss,{value:"saved",children:"Saved"}),e.jsx(ss,{value:"referrals",children:"Referrals"}),e.jsx(ss,{value:"map",children:"Map"}),e.jsx(ss,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by city or neighborhood...",value:c,onChange:re=>u(re.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:m.sortBy,onValueChange:re=>f({...m,sortBy:re}),children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Sort by"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"newest",children:"Newest First"}),e.jsx(ft,{value:"updated",children:"Recently Updated"}),e.jsx(ft,{value:"price_asc",children:"Price: Low to High"}),e.jsx(ft,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(G,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(ty,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(r2s,{filters:m,onFiltersChange:f,onClose:()=>i(!1)}),y?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((re,oe)=>e.jsxs(Pe,{children:[e.jsx(ws,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ws,{className:"h-5 w-3/4"}),e.jsx(ws,{className:"h-4 w-1/2"}),e.jsx(ws,{className:"h-4 w-1/4"})]})]},oe))}):(g==null?void 0:g.length)===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(xn,{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(G,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{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(re=>e.jsx(m9,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.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((re,oe)=>e.jsxs(Pe,{children:[e.jsx(ws,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ws,{className:"h-5 w-3/4"}),e.jsx(ws,{className:"h-4 w-1/2"})]})]},oe))}):(j==null?void 0:j.length)===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(sS,{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(G,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j==null?void 0:j.map(re=>e.jsx(m9,{listing:re,showActions:!0,onClick:()=>t(`/mission-control/listings/${re.id}`),onEdit:()=>t(`/mission-control/listings/${re.id}/edit`),onDelete:()=>$(re.id)},re.id))})}),e.jsx(bs,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,oe)=>e.jsxs(Pe,{children:[e.jsx(ws,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ws,{className:"h-5 w-3/4"}),e.jsx(ws,{className:"h-4 w-1/2"})]})]},oe))}):(_==null?void 0:_.length)===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(Ja,{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(re=>e.jsx(m9,{listing:re.listing,onClick:()=>t(`/mission-control/listings/${re.listing.id}`)},re.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(nd,{className:"h-4 w-4"}),"Referrals Sent (",((X=S==null?void 0:S.sent)==null?void 0:X.length)||0,")"]}),((Y=S==null?void 0:S.sent)==null?void 0:Y.length)===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(J=S==null?void 0:S.sent)==null?void 0:J.map(re=>{var oe,he;return e.jsx(Pe,{children:e.jsx(De,{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:re.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((oe=re.listing)==null?void 0:oe.property_address)||((he=re.listing)==null?void 0:he.city)})]}),e.jsx(Ye,{variant:re.status==="closed"?"default":"secondary",children:re.status.replace("_"," ")})]})})},re.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),"Referrals Received (",((Q=S==null?void 0:S.received)==null?void 0:Q.length)||0,")"]}),((ce=S==null?void 0:S.received)==null?void 0:ce.length)===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ne=S==null?void 0:S.received)==null?void 0:ne.map(re=>{var oe;return e.jsx(Pe,{children:e.jsxs(De,{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:re.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(oe=re.sender)==null?void 0:oe.name]})]}),e.jsx(Ye,{variant:re.status==="closed"?"default":"secondary",children:re.status.replace("_"," ")})]}),e.jsx(G,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${re.listing_id}`),children:"View Listing"})]})},re.id)})})]})]})}),s&&e.jsx(bs,{value:"brokerage",className:"space-y-4",children:P?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,oe)=>e.jsxs(Pe,{children:[e.jsx(ws,{className:"h-48 w-full"}),e.jsxs(De,{className:"p-4 space-y-2",children:[e.jsx(ws,{className:"h-5 w-3/4"}),e.jsx(ws,{className:"h-4 w-1/2"})]})]},oe))}):(I==null?void 0:I.length)===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(sS,{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(G,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:I==null?void 0:I.map(re=>e.jsx(m9,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.id))})}),e.jsx(bs,{value:"map",children:e.jsx(i2s,{listings:g||[],isLoading:y})}),e.jsx(bs,{value:"leaderboard",children:e.jsx(n2s,{leaderboard:O})})]})]})}):e.jsx(Ms,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(xn,{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 l2s(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}const c2s={single_family:"Single Family Home",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury Home",commercial:"Commercial",other:"Property"};function d2s({open:t,onOpenChange:s,listing:r}){const{user:n}=Fs(),{data:a=[],isLoading:o}=nm(),{data:l=[]}=Rf(),[i,c]=k.useState(""),[u,m]=k.useState("all"),[f,g]=k.useState(new Set),[y,_]=k.useState(!1),[w,j]=k.useState(null);k.useEffect(()=>{t||(c(""),m("all"),g(new Set),_(!1))},[t]),k.useEffect(()=>{!t||!n||(async()=>{const{data:$}=await H.from("gmail_integrations").select("gmail_email").eq("user_id",n.id).maybeSingle();j(($==null?void 0:$.gmail_email)||null)})()},[t,n]);const N=k.useMemo(()=>a.filter($=>$.email),[a]),S=k.useMemo(()=>{let $=N;if(u!=="all"&&($=$.filter(z=>{var V;return(V=z.tags)==null?void 0:V.some(X=>X.relationship_type_id===u)})),i.trim()){const z=i.toLowerCase();$=$.filter(V=>`${V.first_name||""} ${V.last_name||""}`.toLowerCase().includes(z)||(V.email||"").toLowerCase().includes(z))}return $},[N,i,u]),M=()=>{f.size===S.length?g(new Set):g(new Set(S.map($=>$.id)))},I=$=>{const z=new Set(f);z.has($)?z.delete($):z.add($),g(z)},P=k.useMemo(()=>N.filter($=>f.has($.id)).map($=>({id:$.id,first_name:$.first_name||"there",last_name:$.last_name,email:$.email})),[N,f]),{defaultSubject:O,defaultBody:q}=k.useMemo(()=>{var ue,ge,_e,Be;const $=r.property_address||`${r.city}, ${r.state}`,z=l2s(r.price),V=c2s[r.property_type]||"home",X=r.bedrooms?`${r.bedrooms} bed`:"",Y=r.bathrooms?`${r.bathrooms} bath`:"",J=r.square_footage?`${r.square_footage.toLocaleString()} sqft`:"",Q=[X,Y,J].filter(Boolean).join(" • "),ce=`https://listings.relevelup.com/${r.slug||r.id}`,ne=((ge=(ue=r.photos)==null?void 0:ue.find(Se=>Se.is_primary))==null?void 0:ge.photo_url)||((Be=(_e=r.photos)==null?void 0:_e[0])==null?void 0:Be.photo_url)||"",oe={active:"Just Listed",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"}[r.status]||"New Listing",he=`${oe}: ${$} — ${z}`,xe=`

Hi {{first_name}},

I wanted to share a property I think you might love. Take a look:

${ne?` ${$} `:""}
${oe}

${z}

${$}

${r.city}, ${r.state}

${Q?`

${Q} • ${V}

`:""} View Photos & Details →

If this catches your eye — or you know someone who'd love it — just hit reply. I'd be happy to set up a private showing.

Talk soon,

`;return{defaultSubject:he,defaultBody:xe}},[r]);return y?e.jsx(X1,{open:y,onOpenChange:$=>{_($),$||s(!1)},bulkContacts:P,defaultSubject:O,defaultBody:q,gmailEmail:w}):e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[640px] max-h-[90vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-amber-500"}),"Email this listing to your sphere"]}),e.jsx(Gr,{children:"Pick which contacts should hear about this property. We'll personalize each email with their name."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search contacts...",value:i,onChange:$=>c($.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:u,onValueChange:m,children:[e.jsx(Ls,{className:"sm:w-[180px]",children:e.jsx($s,{placeholder:"Filter by tag"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All contacts"}),l.map($=>e.jsx(ft,{value:$.id,children:$.name},$.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm border-y py-2",children:[e.jsxs("button",{type:"button",onClick:M,className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Mo,{checked:S.length>0&&f.size===S.length,className:"pointer-events-none"}),e.jsx("span",{children:f.size===S.length&&S.length>0?"Deselect all":`Select all (${S.length})`})]}),e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(ur,{className:"h-3 w-3"}),f.size," selected"]})]}),e.jsx(Li,{className:"flex-1 -mx-6 px-6",children:o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(ys,{className:"h-5 w-5 animate-spin mr-2"}),"Loading your contacts..."]}):S.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:N.length===0?"No contacts with email addresses yet.":"No contacts match your search."}):e.jsx("div",{className:"space-y-1 py-2",children:S.map($=>e.jsxs("label",{className:"flex items-center gap-3 p-2 rounded-md hover:bg-muted/50 cursor-pointer",children:[e.jsx(Mo,{checked:f.has($.id),onCheckedChange:()=>I($.id)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[$.first_name," ",$.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:$.email})]}),$.tags&&$.tags.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap justify-end max-w-[40%]",children:$.tags.slice(0,2).map(z=>{var V;return e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:(V=z.relationship_type)==null?void 0:V.name},z.id)})})]},$.id))})}),e.jsx(Qo,{}),e.jsxs("div",{className:"flex justify-between items-center gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:w?`Sending from ${w}`:"Connect Gmail in Settings to send"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:()=>_(!0),disabled:f.size===0,className:"gap-2",children:[e.jsx(rr,{className:"h-4 w-4"}),"Compose Email (",f.size,")"]})]})]})]})})}function Nx(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 ome(){const t=Fa();return pt({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 Lit(){const t=Fa(),s=Qt();return Tt({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 lme(){const t=Fa();return pt({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 Dit(){const t=Fa(),s=Qt();return Tt({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 Oit(){const t=Qt();return Tt({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 u2s(){const t=Qt();return Tt({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 h2s(){const t=Qt();return Tt({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 m2s(t){return pt({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 p2s(){const t=Qt();return Tt({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 f2s(t){return pt({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 x2s(){const t=Qt();return Tt({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 g2s(){const t=Qt();return Tt({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 y2s(){const t=Fa();return pt({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,m;return!((c=i.deal_pipeline_stages)!=null&&c.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((m=i.deal_pipeline_stages)==null?void 0:m.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+(Nx(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+(Nx(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(Nx(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(Nx(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(Nx(c)||0)*u},0)}},enabled:!!t})}function v2s(t){const s=Fa();return pt({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 b2s(){const t=Qt();return Tt({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 _2s(){const t=Qt();return Tt({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 w2s({listing:t}){const s=ar(),[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l,isLoading:i}=v2s(t.id),{data:c,isLoading:u}=ome(),{data:m,isLoading:f}=lme(),g=Lit(),y=b2s(),_=_2s(),w=Dit(),j=(m==null?void 0:m.filter(P=>!P.listing_id))||[],N=P=>{if(!(c!=null&&c.length))return null;switch(P){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 P=N(t.status);await w.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(P==null?void 0:P.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(P){console.error("Failed to create deal:",P),me.error("Failed to create deal")}finally{o(!1)}},M=async()=>{if(!r){me.error("Please select a deal");return}try{await y.mutateAsync({dealId:r,listingId:t.id}),me.success("Listing linked to deal!"),n("")}catch{me.error("Failed to link listing")}},I=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(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[e.jsx(x0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(De,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ys,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Pe,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[e.jsx(pl,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(De,{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(Ye,{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(G,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(ba,{className:"h-3 w-3 ml-1"})]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:I,disabled:_.isPending,children:_.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(TS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"flex items-center gap-2 text-base",children:[e.jsx(x0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(De,{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(G,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Rs,{value:r,onValueChange:n,children:[e.jsx(Ls,{className:"flex-1 text-sm",children:e.jsx($s,{placeholder:"Link to existing deal..."})}),e.jsx(Ds,{children:j.map(P=>e.jsx(ft,{value:P.id,children:P.deal_name},P.id))})]}),e.jsx(G,{variant:"secondary",size:"icon",onClick:M,disabled:!r||y.isPending,children:y.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(pl,{className:"h-4 w-4"})})]})]})]})]})}const j2s={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},N2s={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},T7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function k2s(){var ce,ne,re,oe,he,xe,ue,ge,_e;const{listingId:t}=ao(),s=ar(),{user:r}=Fs(),{data:n,isLoading:a}=UQe(t||""),{data:o}=GQe(t||""),{data:l}=M8t(t||""),i=HQe(),c=C8t(),u=T8t(),m=VQe(),f=E8t(),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(!1),[S,M]=k.useState(!1),[I,P]=k.useState(null),[O,q]=k.useState({buyerName:"",buyerType:"",notes:""}),$=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),z=Be=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Be),V=async Be=>{const Se=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ee=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:Be});try{switch(Be){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Se)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Se),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ee} ${Se}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ee)}&body=${encodeURIComponent(`Check out this listing: ${Se}`)}`);break}}catch(Ae){console.error("Share error:",Ae),me.error("Failed to share")}},X=async()=>{try{await m.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},Y=async()=>{if(!O.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:O.buyerName,buyerType:O.buyerType||void 0,notes:O.notes||void 0}),me.success("Referral sent successfully!"),w(!1),q({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},J=Be=>{var qe,ve;const Se=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ee=z((n==null?void 0:n.price)||0),Ae=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Me=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",ke=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Oe=[Ae,Me,ke].filter(Boolean).join(" | ");switch(Be){case"just_listed":return`🏡 JUST LISTED! ${Se} ${Ee} ${Oe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(qe=n==null?void 0:n.city)==null?void 0:qe.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Se} Now ${Ee}! ${Oe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${T7e[(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! ${Oe} DM me for details! 📩 #ComingSoon #RealEstate #${(ve=n==null?void 0:n.city)==null?void 0:ve.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(ws,{className:"h-10 w-32"}),e.jsx(ws,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(ws,{className:"h-48"}),e.jsx(ws,{className:"h-48"}),e.jsx(ws,{className:"h-48"})]})]})});if(!n)return e.jsx(Ms,{title:"Listing Not Found",description:"",children:e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(G,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const Q=((ce=n.photos)==null?void 0:ce.find(Be=>Be.is_primary))||((ne=n.photos)==null?void 0:ne[0]);return e.jsxs(Ms,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(G,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Ga,{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&&P(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:(re=n.photos)==null?void 0:re.slice(1,5).map((Be,Se)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>P(Be.photo_url),children:e.jsx("img",{src:Be.photo_url,alt:`Photo ${Se+2}`,className:"w-full h-full object-cover"})},Be.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(Pe,{children:e.jsxs(De,{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(Ye,{className:`${j2s[n.status]} text-white border-0`,children:N2s[n.status]}),n.is_featured&&e.jsxs(Ye,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(ea,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(Ye,{variant:"outline",children:[e.jsx(ur,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:z(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(aa,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Ja,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(G,{variant:"outline",size:"icon",onClick:()=>c.mutate(n.id),children:l?e.jsx(c1,{className:"h-4 w-4"}):e.jsx(Fm,{className:"h-4 w-4"})}),!$&&e.jsxs(G,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{variant:"outline",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Ud,{children:[e.jsxs(La,{onClick:()=>V("copy"),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(La,{onClick:()=>V("facebook"),children:[e.jsx(Au,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(La,{onClick:()=>V("text"),children:[e.jsx(Ki,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(La,{onClick:()=>V("email"),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),$&&e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",onClick:()=>M(!0),className:"gap-2",children:[e.jsx(rr,{className:"h-4 w-4"}),"Email My Sphere"]}),e.jsxs(G,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(G,{variant:"destructive",size:"icon",onClick:()=>y(!0),children:e.jsx(kr,{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(Th,{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(au,{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(k0,{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(fn,{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(Ye,{variant:"secondary",children:[e.jsx(Ta,{className:"h-3 w-3 mr-1"}),T7e[n.property_type]]}),n.lot_size&&e.jsxs(Ye,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(Ye,{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(G,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]}),e.jsxs("div",{className:"flex items-center gap-4 pt-4 mt-4 border-t text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ja,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Share Content"})}),e.jsx(De,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(Be=>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:[Be.replace("_"," ")," Caption"]}),e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(Be)),me.success("Caption copied!")},children:e.jsx(yi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:J(Be)})]},Be))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(De,{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:((he=(oe=n.agent)==null?void 0:oe.name)==null?void 0:he.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((xe=n.agent)==null?void 0:xe.name)||"Unknown"}),((ge=(ue=n.agent)==null?void 0:ue.brokerage)==null?void 0:ge.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!$&&e.jsx("div",{className:"space-y-2",children:((_e=n.agent)==null?void 0:_e.email)&&e.jsx(G,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),$&&e.jsx(w2s,{listing:n}),!$&&n.open_to_referrals&&e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(De,{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(G,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(fs,{open:!!I,onOpenChange:()=>P(null),children:e.jsx(ps,{className:"max-w-4xl",children:e.jsx("img",{src:I||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(fs,{open:g,onOpenChange:y,children:e.jsxs(ps,{children:[e.jsxs(js,{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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:X,disabled:m.isPending,children:m.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:_,onOpenChange:w,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Buyer Name *"}),e.jsx(Le,{value:O.buyerName,onChange:Be=>q({...O,buyerName:Be.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Buyer Type"}),e.jsxs(Rs,{value:O.buyerType,onValueChange:Be=>q({...O,buyerType:Be}),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select type"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"first_time",children:"First-Time Buyer"}),e.jsx(ft,{value:"investor",children:"Investor"}),e.jsx(ft,{value:"relocating",children:"Relocating"}),e.jsx(ft,{value:"upgrade",children:"Upgrading"}),e.jsx(ft,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Notes"}),e.jsx(Tr,{value:O.notes,onChange:Be=>q({...O,notes:Be.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(G,{onClick:Y,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(Iit,{open:j,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}`}),n&&e.jsx(d2s,{open:S,onOpenChange:M,listing:n})]})}function S2s({onImport:t}){const[s,r]=k.useState(""),[n,a]=k.useState([]),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=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 y=async S=>{if(S.trim().length<3){a([]),c(!1);return}l(!0);try{const{data:M,error:I}=await H.functions.invoke("mls-listing-search",{body:{query:S}});if(I)throw I;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(()=>y(S),400)},w=S=>{m(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."}),m(null)},j=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(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{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(De,{children:e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(ys,{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(Er,{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:()=>w(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(aa,{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:j(S.price)}),S.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Th,{className:"h-3 w-3"})," ",S.bedrooms]}),S.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(au,{className:"h-3 w-3"})," ",S.bathrooms]}),S.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ix,{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(Ye,{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 C2s({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=u4e({id:t.id}),u={transform:u3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Pt("relative aspect-square rounded-lg overflow-hidden bg-muted group",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(Eu,{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(Er,{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(ea,{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 M2s({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=r4e(sce(yR,{activationConstraint:{distance:5}})),i=[...t].sort((u,m)=>(u.sort_order??0)-(m.sort_order??0)),c=u=>{const{active:m,over:f}=u;if(!f||m.id===f.id)return;const g=i.findIndex(N=>N.id===m.id),y=i.findIndex(N=>N.id===f.id),_=[...i],[w]=_.splice(g,1);_.splice(y,0,w);const j=_.map((N,S)=>({...N,sort_order:S}));a(j)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(l4e,{sensors:l,collisionDetection:n4e,onDragEnd:c,children:e.jsx(d4e,{items:i.map(u=>u.id),strategy:vR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(C2s,{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(ys,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{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 T2s({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=ar(),{user:a}=Fs(),[o,l]=k.useState(!1),[i,c]=k.useState([]),[u,m]=k.useState(!1),[f,g]=k.useState(null),[y,_]=k.useState({});k.useEffect(()=>{t&&a?w():g(null)},[t,a]);const w=async()=>{if(!t)return;const{data:z,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&&z&&(g(z),j(z))},j=async z=>{try{const{data:V,error:X}=await H.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:z.bunny_video_id,isAgentVideo:!0}});!X&&(V!=null&&V.thumbnailUrl)&&_(Y=>({...Y,[z.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=async()=>{if(a){m(!0);try{const{data:z,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(z||[]),z!=null&&z.length&&S(z)}catch(z){console.error("Error fetching videos:",z),me.error("Failed to load videos")}finally{m(!1)}}},S=async z=>{var V;try{const X=z.map(ne=>ne.bunny_video_id),{data:Y,error:J}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:X,isAgentVideo:!0}});if(J)throw J;const Q=(Y==null?void 0:Y.assets)||{},ce={};for(const ne of z)(V=Q[ne.bunny_video_id])!=null&&V.thumbnailUrl&&(ce[ne.id]={thumbnailUrl:Q[ne.bunny_video_id].thumbnailUrl});_(ne=>({...ne,...ce}))}catch(X){console.warn("Failed to bulk-fetch signed URLs",X)}},M=()=>{l(!0),N()},I=z=>{s(z.id),g(z),l(!1),me.success("Video selected")},P=()=>{s(null),g(null)},O=()=>{const z=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(z)}`)},q=z=>{if(!z)return"0:00";const V=Math.floor(z/60),X=z%60;return`${V}:${X.toString().padStart(2,"0")}`},$=z=>{var V;return((V=y[z.id])==null?void 0:V.thumbnailUrl)||z.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(De,{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:[$(f)?e.jsx("img",{src:$(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(sl,{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(G,{type:"button",variant:"outline",size:"sm",onClick:M,children:"Change"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:P,className:"text-destructive hover:text-destructive",children:e.jsx(Er,{className:"h-4 w-4"})})]})]})})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(De,{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(G,{type:"button",variant:"outline",onClick:M,className:"gap-2",children:[e.jsx(YM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(G,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(gf,{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(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(YM,{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(ys,{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(G,{onClick:O,className:"gap-2",children:[e.jsx(gf,{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(z=>e.jsxs("button",{type:"button",onClick:()=>I(z),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===z.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:[$(z)?e.jsx("img",{src:$(z),alt:z.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(sl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),z.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(z.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:z.title||"Untitled Video"})})]},z.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(G,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(gf,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(G,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const A2s=[{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"}],E2s=[{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 P2s({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:u}=u4e({id:t}),m={transform:u3.Transform.toString(i),transition:c};return e.jsxs("div",{ref:l,style:m,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(Eu,{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(Er,{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(ea,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function I2s({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=r4e(sce(yR,{activationConstraint:{distance:5}})),i=t.map((u,m)=>`pending-${m}`),c=u=>{const{active:m,over:f}=u;if(!f||m.id===f.id)return;const g=i.indexOf(m.id),y=i.indexOf(f.id),_=[...t],w=[...s],[j]=_.splice(g,1),[N]=w.splice(g,1);_.splice(y,0,j),w.splice(y,0,N),n(_,w)};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(l4e,{sensors:l,collisionDetection:n4e,onDragEnd:c,children:e.jsx(d4e,{items:i,strategy:vR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,m)=>e.jsx(P2s,{id:i[m],url:u,index:m,onRemove:r},i[m])),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(ys,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{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 A7e(){const{listingId:t}=ao(),[s]=Ul(),r=s.get("brokerage"),n=ar(),{user:a}=Fs(),{hasLeadSite:o}=vE(),l=!!t&&t!=="new",i=!!r&&!l,[c,u]=k.useState([]),{data:m,isLoading:f}=UQe(l?t:""),g=v8t(),y=b8t(),_=_8t(),w=w8t(),j=j8t(),N=N8t(),S=k8t(),{data:M=[]}=pt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ue,error:ge}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(ge)throw ge;return ue||[]},enabled:i}),[I,P]=k.useState(""),[O,q]=k.useState(!1),[$,z]=k.useState([]),[V,X]=k.useState([]),[Y,J]=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,ge,_e,Be,Se;m&&l&&J({property_address:m.property_address||"",city:m.city||"",state:m.state||"",neighborhood:m.neighborhood||"",price:((ue=m.price)==null?void 0:ue.toString())||"",property_type:m.property_type,status:m.status,bedrooms:((ge=m.bedrooms)==null?void 0:ge.toString())||"",bathrooms:((_e=m.bathrooms)==null?void 0:_e.toString())||"",square_footage:((Be=m.square_footage)==null?void 0:Be.toString())||"",lot_size:m.lot_size||"",year_built:((Se=m.year_built)==null?void 0:Se.toString())||"",has_hoa:m.has_hoa,description:m.description||"",agent_notes:m.agent_notes||"",agent_notes_public:m.agent_notes_public,mls_link:m.mls_link||"",video_link:m.video_link||"",video_id:m.video_id||null,allow_sharing:m.allow_sharing,open_to_referrals:m.open_to_referrals,open_to_social_promotion:m.open_to_social_promotion,share_with_brokerage:m.share_with_brokerage??!1,is_public:m.is_public})},[m,l]);const Q=ue=>{var Se,Ee;const ge={"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(),Be=((Se=Object.entries(ge).find(([Ae])=>_e.includes(Ae)))==null?void 0:Se[1])||"other";J(Ae=>({...Ae,property_address:ue.address||Ae.property_address,city:ue.city||Ae.city,state:ue.state||Ae.state,price:ue.price?String(ue.price):Ae.price,property_type:Be,bedrooms:ue.bedrooms?String(ue.bedrooms):Ae.bedrooms,bathrooms:ue.bathrooms?String(ue.bathrooms):Ae.bathrooms,square_footage:ue.sqft?String(ue.sqft):Ae.square_footage,lot_size:ue.lotSize?String(ue.lotSize):Ae.lot_size,year_built:ue.yearBuilt?String(ue.yearBuilt):Ae.year_built,description:ue.description||Ae.description})),((Ee=ue.photos)==null?void 0:Ee.length)>0&&(u(ue.photos),V.forEach(Ae=>URL.revokeObjectURL(Ae)),z([]),X([]))},ce=ue=>{if(!ue)return;const ge=Array.from(ue);z(Be=>[...Be,...ge]);const _e=ge.map(Be=>URL.createObjectURL(Be));X(Be=>[...Be,..._e])},ne=ue=>{URL.revokeObjectURL(V[ue]),z(ge=>ge.filter((_e,Be)=>Be!==ue)),X(ge=>ge.filter((_e,Be)=>Be!==ue))},re=async ue=>{var ge;if(!(!ue||!m)){q(!0);try{for(const _e of Array.from(ue)){const Be=_e.name.split(".").pop(),Se=`${a==null?void 0:a.id}/${m.id}/${Date.now()}.${Be}`,{error:Ee}=await H.storage.from("listing-photos").upload(Se,_e);if(Ee)throw Ee;const{data:{publicUrl:Ae}}=H.storage.from("listing-photos").getPublicUrl(Se);await w.mutateAsync({listingId:m.id,photoUrl:Ae,isPrimary:!((ge=m.photos)!=null&&ge.length)})}me.success("Photos uploaded!")}catch(_e){console.error("Upload error:",_e),me.error("Failed to upload photos")}finally{q(!1)}}},oe=async ue=>{for(let ge=0;ge<$.length;ge++){const _e=$[ge],Be=_e.name.split(".").pop(),Se=`${a==null?void 0:a.id}/${ue}/${Date.now()}-${ge}.${Be}`,{error:Ee}=await H.storage.from("listing-photos").upload(Se,_e);if(Ee)throw Ee;const{data:{publicUrl:Ae}}=H.storage.from("listing-photos").getPublicUrl(Se);await w.mutateAsync({listingId:ue,photoUrl:Ae,isPrimary:ge===0})}},he=async ue=>{if(m)try{await j.mutateAsync({photoId:ue,listingId:m.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},xe=async ue=>{if(ue.preventDefault(),!Y.city.trim()||!Y.state.trim()||!Y.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!I){me.error("Please select an agent to assign this listing to");return}try{const ge={property_address:Y.property_address||null,city:Y.city,state:Y.state,neighborhood:Y.neighborhood||null,price:Number(Y.price),property_type:Y.property_type,status:Y.status,bedrooms:Y.bedrooms?Number(Y.bedrooms):null,bathrooms:Y.bathrooms?Number(Y.bathrooms):null,square_footage:Y.square_footage?Number(Y.square_footage):null,lot_size:Y.lot_size||null,year_built:Y.year_built?Number(Y.year_built):null,has_hoa:Y.has_hoa,description:Y.description||null,agent_notes:Y.agent_notes||null,agent_notes_public:Y.agent_notes_public,mls_link:Y.mls_link||null,video_link:Y.video_link||null,video_id:Y.video_id||null,allow_sharing:Y.allow_sharing,open_to_referrals:Y.open_to_referrals,open_to_social_promotion:Y.open_to_social_promotion,share_with_brokerage:Y.share_with_brokerage,is_public:Y.is_public};if(l)await _.mutateAsync({id:t,...ge}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{q(!0);let _e;if(i&&I?_e=await y.mutateAsync({agentId:I,...ge}):_e=await g.mutateAsync(ge),$.length>0)try{await oe(_e.id),V.forEach(Be=>URL.revokeObjectURL(Be)),z([]),X([])}catch(Be){console.error("Photo upload error:",Be),me.error("Listing created but some photos failed to upload")}if(c.length>0)try{for(let Be=0;Ben(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Ga,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Assign to Agent *"})}),e.jsxs(De,{children:[e.jsxs(Rs,{value:I,onValueChange:P,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select an agent..."})}),e.jsx(Ds,{children:M.map(ue=>e.jsx(ft,{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(S2s,{onImport:Q}),c.length>0&&e.jsxs(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{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(De,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[c.slice(0,12).map((ue,ge)=>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"})},ge)),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(G,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(Er,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Property Details"})}),e.jsx(De,{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(ye,{children:"Property Address"}),e.jsx(Le,{value:Y.property_address,onChange:ue=>J({...Y,property_address:ue.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"City *"}),e.jsx(Le,{value:Y.city,onChange:ue=>J({...Y,city:ue.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"State *"}),e.jsx(Le,{value:Y.state,onChange:ue=>J({...Y,state:ue.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Neighborhood"}),e.jsx(Le,{value:Y.neighborhood,onChange:ue=>J({...Y,neighborhood:ue.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Price *"}),e.jsx(Le,{type:"number",value:Y.price,onChange:ue=>J({...Y,price:ue.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Type"}),e.jsxs(Rs,{value:Y.property_type,onValueChange:ue=>J({...Y,property_type:ue}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:E2s.map(ue=>e.jsx(ft,{value:ue.value,children:ue.label},ue.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Status"}),e.jsxs(Rs,{value:Y.status,onValueChange:ue=>J({...Y,status:ue}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:A2s.map(ue=>e.jsx(ft,{value:ue.value,children:ue.label},ue.value))})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Property Specs (Optional)"})}),e.jsx(De,{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(ye,{children:"Bedrooms"}),e.jsx(Le,{type:"number",value:Y.bedrooms,onChange:ue=>J({...Y,bedrooms:ue.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Bathrooms"}),e.jsx(Le,{type:"number",step:"0.5",value:Y.bathrooms,onChange:ue=>J({...Y,bathrooms:ue.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Sq Ft"}),e.jsx(Le,{type:"number",value:Y.square_footage,onChange:ue=>J({...Y,square_footage:ue.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Lot Size"}),e.jsx(Le,{value:Y.lot_size,onChange:ue=>J({...Y,lot_size:ue.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Year Built"}),e.jsx(Le,{type:"number",value:Y.year_built,onChange:ue=>J({...Y,year_built:ue.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(qr,{checked:Y.has_hoa,onCheckedChange:ue=>J({...Y,has_hoa:ue})}),e.jsx(ye,{children:"Has HOA"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Description & Links"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:Y.description,onChange:ue=>J({...Y,description:ue.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Agent Notes"}),e.jsx(Tr,{value:Y.agent_notes,onChange:ue=>J({...Y,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:Y.agent_notes_public,onCheckedChange:ue=>J({...Y,agent_notes_public:ue})}),e.jsx(ye,{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(ye,{children:"MLS Link"}),e.jsx(Le,{value:Y.mls_link,onChange:ue=>J({...Y,mls_link:ue.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Video Link"}),e.jsx(Le,{value:Y.video_link,onChange:ue=>J({...Y,video_link:ue.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(De,{children:e.jsx(T2s,{selectedVideoId:Y.video_id,onVideoSelect:ue=>J({...Y,video_id:ue}),listingId:l?t:void 0})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Photos"})}),e.jsx(De,{children:l&&(m!=null&&m.photos)?e.jsx(M2s,{photos:m.photos,uploading:O,onUpload:ue=>re(ue),onRemove:ue=>he(ue),onReorder:ue=>{N.mutate({photos:ue.map(ge=>({id:ge.id,sort_order:ge.sort_order,is_primary:ge.is_primary}))})},onSetPrimary:ue=>{m&&S.mutate({photoId:ue,listingId:m.id})}}):e.jsx(I2s,{photoUrls:V,onRemove:ne,onReorder:(ue,ge)=>{X(ue),z(ge)},pendingPhotos:$,uploading:O,onUpload:ce})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Sharing & Collaboration"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(qr,{checked:Y.allow_sharing,onCheckedChange:ue=>J({...Y,allow_sharing:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(qr,{checked:Y.open_to_referrals,onCheckedChange:ue=>J({...Y,open_to_referrals:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(qr,{checked:Y.open_to_social_promotion,onCheckedChange:ue=>J({...Y,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(ye,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(qr,{checked:Y.share_with_brokerage,onCheckedChange:ue=>J({...Y,share_with_brokerage:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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:Y.is_public,onCheckedChange:ue=>J({...Y,is_public:ue})})]})]})]}),e.jsx(G,{type:"submit",className:"w-full",size:"lg",disabled:g.isPending||_.isPending,children:g.isPending||_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let lp=null;function L2s(){if(lp)return lp;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return lp={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},lp;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 lp={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},lp;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(lp={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},lp):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(lp={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},lp):(lp={canRunVirtualBg:!0,renderer:n},lp)}catch{return lp={canRunVirtualBg:!0},lp}}const D2s=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function O2s({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(()=>L2s()),u=!c.canRunVirtualBg,{data:m=[],refetch:f}=pt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:j}}=await H.auth.getUser();if(!j)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=m.map(j=>({type:"image",label:j.name,imageUrl:j.image_url,thumbnail:j.thumbnail_url||j.image_url})),y=[...D2s,...g],_=j=>j.type!==t.type?!1:j.type==="image"?j.imageUrl===t.imageUrl:!0,w=async j=>{var S;const N=(S=j.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 I=N.name.split(".").pop()||"jpg",P=`${M.id}/${crypto.randomUUID()}.${I}`,{error:O}=await H.storage.from("video-backgrounds").upload(P,N,{contentType:N.type});if(O)throw O;const{data:q}=H.storage.from("video-backgrounds").getPublicUrl(P),$=q.publicUrl,{error:z}=await H.from("video_backgrounds").insert({name:N.name.replace(/\.[^.]+$/,""),image_url:$,thumbnail_url:$,category:"custom",is_stock:!1,user_id:M.id});if(z)throw z;await f(),s({type:"image",imageUrl:$,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:Pt("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(vd,{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(ys,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),y.map((j,N)=>{const S=_(j);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:j.type,imageUrl:j.imageUrl,blurRadius:15}),className:Pt("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:[j.type==="none"&&e.jsx(pL,{className:"h-4 w-4 text-muted-foreground"}),j.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"})}),j.type==="image"&&j.thumbnail&&e.jsx("img",{src:j.thumbnail,alt:j.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:j.label})]},`${j.type}-${j.imageUrl||N}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var j;return(j=o.current)==null?void 0:j.click()},className:Pt("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(ys,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(qs,{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:w}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:Pt("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(NL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var zA=typeof self<"u"?self:{};function Rit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=zA,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 zit(t){zA.setTimeout(()=>{throw t},0)}var nwe,B2s=Rit(610401301,!1),P7e=Rit(748402147,!0);function I7e(){var t=zA.navigator;return t&&(t=t.userAgent)?t:""}const L7e=zA.navigator;function cme(t){return cme[" "](t),t}nwe=L7e&&L7e.userAgentData||null,cme[" "]=function(){};const Bit={};let YI=null;function $2s(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(m<<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 $it(){if(!YI){YI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));Bit[r]=n;for(let a=0;a0)&&(I7e().indexOf("Trident")!=-1||I7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const D7e=/[-_.]/g,U2s={"-":"+",_:"/",".":"="};function V2s(t){return U2s[t]||""}function Uit(t){if(!qit)return $2s(t);t=D7e.test(t)?t.replace(D7e,V2s):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,Hit(t=Error(),"incident"),zit(t))}}function VE(){return typeof BigInt=="function"}var HE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function Q0(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 W2s=Q0("jas",void 0,!0),O7e=Q0(void 0,"0di"),MI=Q0(void 0,"1oa"),Cf=Q0(void 0,Symbol()),K2s=Q0(void 0,"0ub"),Z2s=Q0(void 0,"0ubs"),iwe=Q0(void 0,"0ubsb"),Y2s=Q0(void 0,"0actk"),qA=Q0("m_m","Pa",!0),R7e=Q0();const Git={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Wit=Object.defineProperties,Da=HE?W2s:"Ga";var $3;const F7e=[];function LR(t,s){HE||Da in t||Wit(t,Git),t[Da]|=s}function Ou(t,s){HE||Da in t||Wit(t,Git),t[Da]=s}function DR(t){return LR(t,34),t}function _O(t){return LR(t,8192),t}Ou(F7e,7),$3=Object.freeze(F7e);var UA={};function Ef(t,s){return s===void 0?t.h!==_3&&!!(2&(0|t.v[Da])):!!(2&s)&&t.h!==_3}const _3={};function ESe(t,s){if(t!=null){if(typeof t=="string")t=t?new I0(t,BA):b3();else if(t.constructor!==I0)if(TSe(t))t=t.length?new I0(new Uint8Array(t),BA):b3();else{if(!s)throw Error();t=void 0}}return t}class z7e{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 Q2s=Object.freeze({});function Kit(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"),B7e=dme(t=>typeof t=="string"),J2s=dme(t=>typeof t=="boolean"),ume=typeof zA.BigInt=="function"&&typeof zA.BigInt(0)=="bigint";function Mf(t){var s=t;if(B7e(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(X2s(s)&&!Number.isSafeInteger(s))throw Error(String(s));return ume?BigInt(t):t=J2s(t)?t?"1":"0":B7e(t)?t.trim()||"0":String(t)}var owe=dme(t=>ume?t>=tjs&&t<=rjs:t[0]==="-"?$7e(t,ejs):$7e(t,sjs));const ejs=Number.MIN_SAFE_INTEGER.toString(),tjs=ume?BigInt(Number.MIN_SAFE_INTEGER):void 0,sjs=Number.MAX_SAFE_INTEGER.toString(),rjs=ume?BigInt(Number.MAX_SAFE_INTEGER):void 0;function $7e(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Xc=s,tu=(t-s)/4294967296>>>0}function VA(t){if(t<0){q7e(-t);const[s,r]=LSe(Xc,tu);Xc=s>>>0,tu=r>>>0}else q7e(t)}function PSe(t){const s=ajs||(ajs=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),tu=0,Xc=s.getUint32(0,!0)}function Yit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:wO(t,s)}function ijs(t,s){return Mf(VE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):wO(t,s))}function Qit(t,s){return VE()?Mf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else VE()?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+U7e(r)+U7e(t));return r}function U7e(t){return t=String(t),"0000000".slice(t.length)+t}function ISe(t,s){if(2147483648&s)if(VE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=LSe(t,s);t="-"+wO(r,n)}else t=wO(t,s);return t}function hme(t){if(t.length<16)VA(Number(t));else if(VE())t=BigInt(t),Xc=Number(t&BigInt(4294967295))>>>0,tu=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");tu=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));tu*=1e6,Xc=1e6*Xc+o,Xc>=4294967296&&(tu+=Math.trunc(Xc/4294967296),tu>>>=0,Xc>>>=0)}if(s){const[n,a]=LSe(Xc,tu);Xc=n,tu=a}}}function LSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function iy(t){return Array.prototype.slice.call(t)}const OR=typeof BigInt=="function"?BigInt.asIntN:void 0,ojs=typeof BigInt=="function"?BigInt.asUintN:void 0,w3=Number.isSafeInteger,mme=Number.isFinite,HA=Math.trunc,ljs=Mf(0);function QI(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 m0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function jO(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 Xit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const cjs=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function RR(t){switch(typeof t){case"bigint":return!0;case"number":return mme(t);case"string":return cjs.test(t);default:return!1}}function WE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return mme(t)?0|t:void 0}function Jit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return mme(t)?t>>>0:void 0}function eot(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(hme(t),ISe(Xc,tu))}function DSe(t){if(t=HA(t),!w3(t)){VA(t);var s=Xc,r=tu;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=Yit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function tot(t){var s=HA(Number(t));return w3(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),eot(t))}function sot(t){var s=HA(Number(t));return w3(s)?Mf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),VE()?Mf(OR(64,BigInt(t))):Mf(eot(t)))}function rot(t){return w3(t)?t=Mf(DSe(t)):(t=HA(t),w3(t)?t=String(t):(VA(t),t=ISe(Xc,tu)),t=Mf(t)),t}function ode(t){const s=typeof t;return t==null?t:s==="bigint"?Mf(OR(64,t)):RR(t)?s==="string"?sot(t):rot(t):void 0}function not(t){if(typeof t!="string")throw Error();return t}function FR(t){if(t!=null&&typeof t!="string")throw Error();return t}function Dh(t){return t==null||typeof t=="string"?t:void 0}function OSe(t,s,r,n){return t!=null&&t[qA]===UA?t:Array.isArray(t)?((n=(r=0|t[Da])|32&n|2&n)!==r&&Ou(t,n),new s(t)):(r?2&n?((t=s[O7e])||(DR((t=new s).v),t=s[O7e]=t),s=t):s=new s:s=void 0,s)}function djs(t,s,r){if(s)e:{if(!RR(s=t))throw awe("int64");switch(typeof s){case"string":s=sot(s);break e;case"bigint":s=Mf(OR(64,s));break e;default:s=rot(s)}}else s=ode(t);return(t=s)==null?r?ljs:void 0:t}const ujs={};let hjs=function(){try{return cme(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Lye{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 mjs=hjs?(Object.setPrototypeOf(Lye.prototype,Map.prototype),Object.defineProperties(Lye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Lye):class extends Map{constructor(){super()}};function V7e(t){return t}function Dye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var $1=class extends mjs{constructor(t,s,r=V7e,n=V7e){super(),this.J=0|t[Da],this.K=s,this.S=r,this.fa=this.K?pjs:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return Dye(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 pjs(t,s,r,n,a,o){return t=OSe(t,n,r,o),a&&(t=FSe(t)),t}function fjs(t){return[t,this.get(t)]}let xjs;function H7e(){return xjs||(xjs=new $1(DR([]),void 0,void 0,void 0,ujs))}function pme(t){return Cf?t[Cf]:void 0}function lde(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}$1.prototype.toJSON=void 0;var lwe=class{};const gjs={Ka:!0};function yjs(t,s){s<100||$A(Z2s,1)}function fme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=Cf;!a&&HE&&l&&(o=t[l])&&lde(o,yjs),l=[];var i=t.length;let c;o=4294967295;let u=!1;const m=!!(64&s),f=m?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,!m||128&s||a||(u=!0,o=o-f+f)),s=void 0;for(var g=0;g=o){const _=g-f;(s??(s={}))[_]=y}else l[g]=y}if(c)for(let y in c){if((i=c[y])==null||(i=r(i,n))==null)continue;let _;g=+y,m&&!Number.isNaN(g)&&(_=g+f){_[j]=iy(N)}),_.da=y.da,_}(t)),l}function vjs(t){return t[0]=NO(t[0]),t[1]=NO(t[1]),t}function NO(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return owe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[Da];return t.length===0&&1&s?void 0:fme(t,s,NO)}if(t!=null&&t[qA]===UA)return aot(t);if(t instanceof I0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(qit){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[m++]=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[m]=r[s>>2]+r[(3&s)<<4|c>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof $1?t=t.size!==0?t.V(vjs):void 0:void 0}return t}let bjs,_js;function aot(t){return fme(t=t.v,0|t[Da],NO)}function zS(t,s){return iot(t,s[0],s[1])}function iot(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[Da],P7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(P7e)throw Error("carr");$A(Y2s,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&Ou(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 Ou(t,64|a|n),t}function wjs(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[Da];return t.length===0&&1&r?void 0:G7e(t,r,s)}if(t!=null&&t[qA]===UA)return W7e(t);if(t instanceof $1){if(2&(s=t.J))return t;if(!t.size)return;if(r=DR(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 Ml(t,s,r,n){YE(t),Lu(t=t.v,0|t[Da],s,r,n)}function Lu(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[Da]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function O4(){return Q2s===void 0?2:4}function R4(t,s,r,n,a){let o=t.v,l=0|o[Da];n=Ef(t,l)?1:n,a=!!a||n===3,n===2&&ZE(t)&&(o=t.v,l=0|o[Da]);let i=(t=BSe(o,s))===$3?7:0|t[Da],c=$Se(i,l);var u=!(4&c);if(u){4&c&&(t=iy(t),i=0,c=$S(c,l),l=Lu(o,l,s,t));let m=0,f=0;for(;m{const i=OSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!Ef(n)&&q3(t,s),n}function Jo(t,s,r,n){let a=t.v,o=0|a[Da];if((s=hot(a,o,s,r,n))==null)return s;if(o=0|a[Da],!Ef(t,o)){const l=FSe(s);l!==s&&(ZE(t)&&(a=t.v,o=0|a[Da]),o=Lu(a,o,r,s=l,n),q3(a,o))}return s}function mot(t,s,r,n,a,o,l,i){var c=Ef(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&ZE(t)&&(r=0|(s=t.v)[Da]);var u=(t=BSe(s,a))===$3?7:0|t[Da],m=$Se(u,r);if(i=!(4&m)){var f=t,g=r;const y=!!(2&m);y&&(g|=2);let _=!y,w=!0,j=0,N=0;for(;j32)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 KSe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function dde(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],qS(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 jjs(t){return Sw(t)}function qS(t,s){if(t.g=s,s>t.l)throw Error()}function fot(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 xot(t,s){if(s==0)return b3();var r=fot(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):njs?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?b3():new I0(r,BA)}var K7e=[];function got(t,s,r,n){if(ude.length){const a=ude.pop();return a.o(n),a.g.init(t,s,r,n),a}return new Njs(t,s,r,n)}function yot(t){t.g.clear(),t.l=-1,t.h=-1,ude.length<100&&ude.push(t)}function vot(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=q0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Gie(t){switch(t.h){case 0:t.h!=0?Gie(t):KSe(t.g);break;case 1:qS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Gie(t);else{var s=q0(t.g);qS(t=t.g,t.g+s)}break;case 5:qS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!vot(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Gie(t)}break;default:throw Error()}}function zR(t,s,r){const n=t.g.l;var a=q0(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 ZSe(t){var s=q0(t.g),r=fot(t=t.g,s);if(t=t.h,R2s){var n,a=t;(n=Iye)||(n=Iye=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(p9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),p9=!0}catch{p9=!1}}throw!p9&&(Iye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?Z2():(i=t[o++],l<194||(192&i)!=128?(o--,Z2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?Z2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,Z2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?Z2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,Z2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):Z2(),r.length>=8192&&(c=E7e(c,r),r.length=0)}o=E7e(c,r)}return o}function bot(t){const s=q0(t.g);return xot(t.g,s)}function gme(t,s,r){var n=q0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let kjs;function Y7e(t){return t?/^-?\d+$/.test(t)?(hme(t),new dwe(Xc,tu)):null:Sjs||(Sjs=new dwe(0,0))}var dwe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let Sjs;function kT(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 XE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function yme(t,s){if(s>=0)XE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function YSe(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 GA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Qx(t,s,r){XE(t.g,8*s+r)}function QSe(t,s){return Qx(t,s,2),s=t.g.end(),GA(t,s),s.push(t.h),s}function XSe(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 vme(t,s,r){Qx(t,s,2),XE(t.g,r.length),GA(t,t.g.end()),GA(t,r)}function hde(t,s,r,n){r!=null&&(s=QSe(t,s),n(r,t),XSe(t,s))}function X0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var JSe=X0(),_ot=X0(),e3e=X0(),t3e=X0(),s3e=X0(),wot=X0(),Cjs=X0(),bme=X0(),jot=X0(),Not=X0();function J0(t,s,r){var n=t.v;Cf&&Cf in n&&(n=n[Cf])&&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 Oa=class{constructor(t,s){this.v=iot(t,s,void 0,2048)}toJSON(){return aot(this)}j(){var a;var t=lNs,s=this.v,r=t.g,n=Cf;if(HE&&n&&((a=s[n])==null?void 0:a[r])!=null&&$A(K2s,3),s=t.g,R7e&&Cf&&R7e===void 0&&(n=(r=this.v)[Cf])&&(n=n.da))try{n(r,s,gjs)}catch(o){zit(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[Da];return zSe(this,t,s)?RSe(this,t,!0):new this.constructor(KE(t,s,!1))}};Oa.prototype[qA]=UA,Oa.prototype.toString=function(){return this.v.toString()};var JE=class{constructor(t,s,r){this.g=t,this.h=s,t=JSe,this.l=!!t&&r===t||!1}};function _me(t,s){return new JE(t,s,JSe)}function kot(t,s,r,n,a){hde(t,r,Tot(s,n),a)}const Mjs=_me(function(t,s,r,n,a){return t.h===2&&(zR(t,VSe(s,n,r),a),!0)},kot),Tjs=_me(function(t,s,r,n,a){return t.h===2&&(zR(t,VSe(s,n,r),a),!0)},kot);var wme=Symbol(),jme=Symbol(),uwe=Symbol(),Q7e=Symbol(),X7e=Symbol();let Sot,Cot;function U3(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 bjs||(bjs=[0,void 0,!0]);case"number":return f>0?void 0:f===0?_js||(_js=[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,Sot??(Sot=o),Cot??(Cot=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 n3e(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,m)=>o(c,u,m,i||(i=U3(jme,r3e,n3e,n).T),l||(l=a3e(n)),a)}function a3e(t){let s=t[uwe];if(s!=null)return s;const r=U3(jme,r3e,n3e,t);return s=r.ma?(n,a)=>Sot(n,a,r):(n,a)=>{for(;vot(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=Ejs(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Gie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=xot(i.g,c);l=void 0,i=n,c&&((l=i[Cf]??(i[Cf]=new lwe))[o]??(l[o]=[])).push(c)}}return(n=pme(n))&&(n.da=r.qa[X7e]),!0},t[uwe]=s,t[X7e]=Ajs.bind(t),s}function Ajs(t,s,r,n){var a=this[jme];const o=this[uwe],l=zS(void 0,a.T),i=pme(t);if(i){var c=!1,u=a.ba;if(u){if(a=(m,f,g)=>{if(g.length!==0)if(u[f])for(const y of g){m=got(y);try{c=!0,o(l,m)}finally{yot(m)}}else n==null||n(t,f,g)},s==null)lde(i,a);else if(i!=null){const m=i[s];m&&a(i,s,m)}if(c){let m=0|t[Da];if(2&m&&2048&m&&!(r!=null&&r.Ka))throw Error();const f=GE(m),g=(y,_)=>{if(q1(t,y,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}_!=null&&(m=Lu(t,m,y,_,f)),delete i[y]};s==null?Kit(l,0|l[Da],(y,_)=>{g(y,_)}):g(s,q1(l,s,f))}}}}function Ejs(t){const s=(t=Mot(t))[0].g;if(t=t[1]){const r=a3e(t),n=U3(jme,r3e,n3e,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function Nme(t,s,r){t[s]=r.h}function kme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=U3(wme,Nme,kme,n).T),a||(a=Aot(n)))}function Aot(t){let s=t[Q7e];if(!s){const r=U3(wme,Nme,kme,t);s=(n,a)=>Eot(n,a,r),t[Q7e]=s}return s}function Eot(t,s,r){Kit(t,0|t[Da],(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=Mot(c))[0].h;if(c=c[1]){const m=Aot(c),f=U3(wme,Nme,kme,c).T;c=l.ma?Cot(f,m):(g,y,_)=>u(g,y,_,f,m)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||$A(iwe,3)}}),(t=pme(t))&&lde(t,(n,a,o)=>{for(GA(s,s.g.end()),n=0;n{hde(t,r,zS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),kT(t.g,r.h,r.g);break;default:r=Y7e(s),kT(t.g,r.h,r.g)}}function Lot(t,s,r){(s=WE(s))!=null&&s!=null&&(Qx(t,r,0),yme(t.g,s))}function Dot(t,s,r){(s=Xit(s))!=null&&(Qx(t,r,0),t.g.g.push(s?1:0))}function Oot(t,s,r){(s=Dh(s))!=null&&vme(t,r,Fit(s))}function Rot(t,s,r,n,a){hde(t,r,Tot(s,n),a)}function Fot(t,s,r){(s=s==null||typeof s=="string"||s instanceof I0?s:void 0)!=null&&vme(t,r,GSe(s,!0).buffer)}function zot(t,s,r){(s=Jit(s))!=null&&s!=null&&(Qx(t,r,0),XE(t.g,s))}function Bot(t,s,r){return(t.h===5||t.h===2)&&(s=QE(s,0|s[Da],r),t.h==2?gme(t,dde,s):s.push(dde(t.g)),!0)}var nu=lm(function(t,s,r){return t.h===5&&(cm(s,r,dde(t.g)),!0)},Pot,bme),Ljs=t6(Bot,function(t,s,r){if((s=e6(m0,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"))||(hme(n),n=wO(Xc,tu))),n;if(a==="number")return(n=HA(n))>=0&&w3(n)||(VA(n),n=Yit(Xc,tu)),n}}(s),s!=null&&(typeof s=="string"&&Z7e(s),s!=null))switch(Qx(t,r,0),typeof s){case"number":t=t.g,VA(s),kT(t,Xc,tu);break;case"bigint":r=BigInt.asUintN(64,s),r=new cwe(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),kT(t.g,r.h,r.g);break;default:r=Z7e(s),kT(t.g,r.h,r.g)}},Cjs),Mu=lm(function(t,s,r){return t.h===0&&(cm(s,r,Sw(t.g)),!0)},Lot,t3e),BR=t6(function(t,s,r){return(t.h===0||t.h===2)&&(s=QE(s,0|s[Da],r),t.h==2?gme(t,Sw,s):s.push(Sw(t.g)),!0)},function(t,s,r){if((s=e6(WE,s))!=null&&s.length){r=QSe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=got(r,void 0,void 0,o);try{const l=new t,i=l.v;a3e(s)(i,r);var a=l}finally{yot(r)}}return a}}function Sme(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}}}};Eot(this.v,s,U3(wme,Nme,kme,t)),GA(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=tze.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=Fye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function f9(t,...s){if(s.length===0)return sze(t[0]);let r=t[0];for(let n=0;n({index:Mx(n,1)??0??-1,score:Ld(n,2)??0,categoryName:Dh(td(n,3))??""??"",displayName:Dh(td(n,4))??""??""})),headIndex:s,headName:r}}function hNs(t){const s={classifications:U1(t,Wjs,1).map(r=>{var n;return p3e(((n=Jo(r,Zot,4))==null?void 0:n.g())??[],Mx(r,2)??0,Dh(td(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(owe(r)?r=Number(r):(r=OR(64,r),r=owe(r)?Number(r):String(r)),r):RR(r)?typeof r=="number"?DSe(r):tot(r):void 0}(td(t,2,void 0,void 0,ode))!=null&&(s.timestampMs=wlt(td(t,2,void 0,void 0,ode)??oot)),s}function jlt(t){var l,i;var s=R4(t,3,m0,O4()),r=R4(t,2,WE,O4()),n=R4(t,1,Dh,O4()),a=R4(t,9,Dh,O4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function pze(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 fze(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 Slt(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 qa(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 xze(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]=Slt(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 gze(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 Vy(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function Gb(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)}}iM.forVisionTasks=function(t,s=!1){return g9("vision",t??f9``,s)},iM.forTextTasks=function(t,s=!1){return g9("text",t??f9``,s)},iM.forGenAiTasks=function(t,s=!1){return g9("genai",t??f9``,s)},iM.forAudioTasks=function(t,s=!1){return g9("audio",t??f9``,s)},iM.isSimdSupported=function(t=!1){return Nlt(t)};async function pNs(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await fze(o),!self.ModuleFactory||l&&(await fze(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 $ye(t,s){const r=Jo(t.baseOptions,mde,1)||new mde;typeof s=="string"?(Ml(r,2,FR(s)),Ml(r,1)):s instanceof Uint8Array&&(Ml(r,1,ESe(s,!1)),Ml(r,2)),mi(t.baseOptions,0,1,r)}function yze(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 pa(t,s){t.C=Math.max(t.C,s)}function Ame(t,s){t.B=new Op,Pf(t.B,2,"PassThroughCalculator"),Hc(t.B,"free_memory"),Fo(t.B,"free_memory_unused_out"),ad(s,"free_memory"),Xx(s,t.B)}function WA(t,s){Hc(t.B,s),Fo(t.B,s+"_unused_out")}function Eme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var xwe=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=Jo(this.baseOptions,mde,1))!=null&&a.g()||(o=Jo(this.baseOptions,mde,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,m){let f=Jo(u.baseOptions,cze,3);if(!f){var g=f=new cze,y=new rze;F8(g,4,Wie,y)}"delegate"in m&&(m.delegate==="GPU"?(m=f,g=new Bjs,F8(m,2,Wie,g)):(m=f,g=new rze,F8(m,4,Wie,g))),mi(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),$ye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)$ye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const m=[];for(var f=0;;){const{done:g,value:y}=await u.read();if(g)break;m.push(y),f+=y.length}if(m.length===0)return new Uint8Array(0);if(m.length===1)return m[0];u=new Uint8Array(f),f=0;for(const g of m)u.set(g,f),f+=g.length;return u}(c.modelAssetBuffer).then(u=>{$ye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=$js(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,yze(this)}finishProcessing(){this.g.finishProcessing(),yze(this)}close(){this.B=void 0,this.g.closeGraph()}};function uw(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}xwe.prototype.close=xwe.prototype.close;class fNs{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 vze(t,s,r){const n=t.g;if(r=uw(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 bze(t,s){const r=t.g,n=uw(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=uw(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=uw(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 fNs(r,n,a,o)}function f3e(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function xNs(t,s,r,n){return f3e(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=bze(t,!0)),r=t.u):(t.A||(t.A=bze(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function Clt(t,s,r){return f3e(t,s),t=uw(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 Mlt(t,s,r){f3e(t,s),t.B||(t.B=uw(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 gNs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Tlt=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=uw(t.createProgram(),"Failed to create WebGL program"),this.X=vze(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=vze(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 Xv(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 gwe(t){var s=Xv(t,1);if(!s){if(s=Xv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=KA(t);var r=x3e(t);if(Mlt(r,n,Alt(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 gwe(this)}N(){return Alt(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=KA(this),a=x3e(this);n.activeTexture(n.TEXTURE1),r=Clt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Elt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Mlt(a,n,r),xNs(a,n,!1,()=>{Plt(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),ywe(this)}),gNs(a),ywe(this)}}t.push(r)}return new Wu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&KA(this).deleteTexture(Xv(this,2)),_ze=-1}};Wu.prototype.close=Wu.prototype.close,Wu.prototype.clone=Wu.prototype.clone,Wu.prototype.getAsWebGLTexture=Wu.prototype.N,Wu.prototype.getAsFloat32Array=Wu.prototype.ia,Wu.prototype.getAsUint8Array=Wu.prototype.ja,Wu.prototype.hasWebGLTexture=Wu.prototype.R,Wu.prototype.hasFloat32Array=Wu.prototype.ka,Wu.prototype.hasUint8Array=Wu.prototype.Fa;var _ze=250;function yy(...t){return t.map(([s,r])=>({start:s,end:r}))}const yNs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((wze=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:klt()?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?'),qa(this,n||"input_audio",o=>{qa(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){Vy(this,"__graph_config__",s=>{t(s)}),qa(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),qa(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){qa(this,s,n=>{const[a,o]=xze(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){qa(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){qa(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){qa(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){qa(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){qa(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){qa(this,s,n=>{qa(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){qa(this,s,n=>{gze(this,Object.keys(t),a=>{gze(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){qa(this,r,a=>{qa(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){qa(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){qa(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){qa(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){qa(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){qa(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){qa(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){qa(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)qa(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){qa(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){qa(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){qa(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){qa(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){qa(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){qa(this,s,r=>{qa(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){qa(this,r,n=>{qa(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){qa(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){qa(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){qa(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){qa(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){qa(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){qa(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)qa(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){Vy(this,t,s),qa(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){Gb(this,t,s),qa(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){Vy(this,t,s),qa(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){Gb(this,t,s),qa(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?'),Vy(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),qa(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 wze{get ga(){return this.i}pa(t,s,r){qa(this,s,n=>{const[a,o]=xze(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){Vy(this,t,s),qa(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){Gb(this,t,s),qa(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var wze,vy=class extends yNs{};async function Go(t,s,r){return async function(n,a,o,l){return pNs(n,a,o,l)}(t,r.canvas??(klt()?void 0:document.createElement("canvas")),s,r)}function Ilt(t,s,r,n){if(t.U){const o=new elt;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].");Ya(o,1,(a.left+a.right)/2),Ya(o,2,(a.top+a.bottom)/2),Ya(o,4,a.right-a.left),Ya(o,3,a.bottom-a.top)}else Ya(o,1,.5),Ya(o,2,.5),Ya(o,4,1),Ya(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(Ya(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=Slt(s);r=Ld(o,3)*i/l,a=Ld(o,4)*l/i,Ya(o,4,r),Ya(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 by(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'.");Ilt(t,s,r,t.C+1)}function tv(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'.");Ilt(t,s,r,n)}function ZA(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 Wu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var If=class extends xwe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Tlt}l(t,s=!0){if("runningMode"in t&&Ml(this.baseOptions,2,jO(!!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()}};If.prototype.close=If.prototype.close;var ix=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},mi(t=this.h=new Mme,0,1,s=new Cd),Ya(this.h,2,.5),Ya(this.h,3,.3)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Ya(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Ya(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},by(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},tv(this,t,r,s),this.j}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect_in"),ol(t,"detections");const s=new zf;J0(s,Jjs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect_in"),Fo(r,"DETECTIONS:detections"),r.o(s),Xx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Qot(o),this.j.detections.push(jlt(n));pa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ix.prototype.detectForVideo=ix.prototype.G,ix.prototype.detect=ix.prototype.F,ix.prototype.setOptions=ix.prototype.o,ix.createFromModelPath=async function(t,s){return Go(ix,t,{baseOptions:{modelAssetPath:s}})},ix.createFromModelBuffer=function(t,s){return Go(ix,t,{baseOptions:{modelAssetBuffer:s}})},ix.createFromOptions=function(t,s){return Go(ix,t,s)};var g3e=yy([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]),y3e=yy([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]),v3e=yy([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Llt=yy([474,475],[475,476],[476,477],[477,474]),b3e=yy([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]),_3e=yy([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Dlt=yy([469,470],[470,471],[471,472],[472,469]),w3e=yy([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]),Olt=[...g3e,...y3e,...v3e,...b3e,..._3e,...w3e],Rlt=yy([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 jze(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var dd=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,mi(t=this.h=new alt,0,1,s=new Cd),this.A=new nlt,mi(this.h,0,3,this.A),this.u=new Mme,mi(this.h,0,2,this.u),V1(this.u,4,1),Ya(this.u,2,.5),Ya(this.A,2,.5),Ya(this.h,4,.5)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return"numFaces"in t&&V1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Ya(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Ya(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Ya(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 jze(this),by(this,t,s),this.j}G(t,s,r){return jze(this),tv(this,t,r,s),this.j}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect"),ol(t,"face_landmarks");const s=new zf;J0(s,tNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Xx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=$R(o),this.j.faceLandmarks.push(Tme(n));pa(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{pa(this,n)}),this.outputFaceBlendshapes&&(ol(t,"blendshapes"),Fo(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Cme(o),this.j.faceBlendshapes.push(p3e(n.g()??[]));pa(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{pa(this,n)})),this.outputFacialTransformationMatrixes&&(ol(t,"face_geometry"),Fo(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Jo(n=eNs(o),Hjs,2))&&this.j.facialTransformationMatrixes.push({rows:Mx(n,1)??0??0,columns:Mx(n,2)??0??0,data:R4(n,3,m0,O4()).slice()??[]});pa(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{pa(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};dd.prototype.detectForVideo=dd.prototype.G,dd.prototype.detect=dd.prototype.F,dd.prototype.setOptions=dd.prototype.o,dd.createFromModelPath=function(t,s){return Go(dd,t,{baseOptions:{modelAssetPath:s}})},dd.createFromModelBuffer=function(t,s){return Go(dd,t,{baseOptions:{modelAssetBuffer:s}})},dd.createFromOptions=function(t,s){return Go(dd,t,s)},dd.FACE_LANDMARKS_LIPS=g3e,dd.FACE_LANDMARKS_LEFT_EYE=y3e,dd.FACE_LANDMARKS_LEFT_EYEBROW=v3e,dd.FACE_LANDMARKS_LEFT_IRIS=Llt,dd.FACE_LANDMARKS_RIGHT_EYE=b3e,dd.FACE_LANDMARKS_RIGHT_EYEBROW=_3e,dd.FACE_LANDMARKS_RIGHT_IRIS=Dlt,dd.FACE_LANDMARKS_FACE_OVAL=w3e,dd.FACE_LANDMARKS_CONTOURS=Olt,dd.FACE_LANDMARKS_TESSELATION=Rlt;var j3e=yy([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 Nze(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function kze(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=Cme(a);t=[];for(const o of n.g())n=s&&Mx(o,1)!=null?Mx(o,1)??0:-1,t.push({score:Ld(o,2)??0,index:n,categoryName:Dh(td(o,3))??""??"",displayName:Dh(td(o,4))??""??""});r.push(t)}return r}var Kp=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],mi(t=this.j=new llt,0,1,s=new Cd),this.u=new d3e,mi(this.j,0,2,this.u),this.D=new c3e,mi(this.u,0,3,this.D),this.A=new olt,mi(this.u,0,2,this.A),this.h=new sNs,mi(this.j,0,3,this.h),Ya(this.A,2,.5),Ya(this.u,4,.5),Ya(this.D,2,.5)}get baseOptions(){return Jo(this.j,Cd,1)}set baseOptions(t){mi(this.j,0,1,t)}o(t){var a,o,l,i;if(V1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ya(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ya(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ya(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new K5,r=s,n=fwe(t.cannedGesturesClassifierOptions,(a=Jo(this.h,K5,3))==null?void 0:a.l());mi(r,0,2,n),mi(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Jo(this.h,K5,3))==null||o.g());return t.customGesturesClassifierOptions?(mi(r=s=new K5,0,2,n=fwe(t.customGesturesClassifierOptions,(l=Jo(this.h,K5,4))==null?void 0:l.l())),mi(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Jo(this.h,K5,4))==null||i.g()),this.l(t)}Ha(t,s){return Nze(this),by(this,t,s),kze(this)}Ia(t,s,r){return Nze(this),tv(this,t,r,s),kze(this)}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect"),ol(t,"hand_gestures"),ol(t,"hand_landmarks"),ol(t,"world_hand_landmarks"),ol(t,"handedness");const s=new zf;J0(s,rNs,this.j);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"HAND_GESTURES:hand_gestures"),Fo(r,"LANDMARKS:hand_landmarks"),Fo(r,"WORLD_LANDMARKS:world_hand_landmarks"),Fo(r,"HANDEDNESS:handedness"),r.o(s),Xx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=$R(o);const l=[];for(const i of U1(n,Jot,1))l.push({x:Ld(i,1)??0,y:Ld(i,2)??0,z:Ld(i,3)??0,visibility:Ld(i,4)??0});this.landmarks.push(l)}pa(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{pa(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=ST(o);const l=[];for(const i of U1(n,Xot,1))l.push({x:Ld(i,1)??0,y:Ld(i,2)??0,z:Ld(i,3)??0,visibility:Ld(i,4)??0});this.worldLandmarks.push(l)}pa(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{pa(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...Sze(n,!1)),pa(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{pa(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...Sze(n)),pa(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Cze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Kp.prototype.recognizeForVideo=Kp.prototype.Ia,Kp.prototype.recognize=Kp.prototype.Ha,Kp.prototype.setOptions=Kp.prototype.o,Kp.createFromModelPath=function(t,s){return Go(Kp,t,{baseOptions:{modelAssetPath:s}})},Kp.createFromModelBuffer=function(t,s){return Go(Kp,t,{baseOptions:{modelAssetBuffer:s}})},Kp.createFromOptions=function(t,s){return Go(Kp,t,s)},Kp.HAND_CONNECTIONS=j3e;var Zp=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],mi(t=this.h=new d3e,0,1,s=new Cd),this.u=new c3e,mi(this.h,0,3,this.u),this.j=new olt,mi(this.h,0,2,this.j),V1(this.j,3,1),Ya(this.j,2,.5),Ya(this.u,2,.5),Ya(this.h,4,.5)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return"numHands"in t&&V1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ya(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ya(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ya(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],by(this,t,s),Cze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],tv(this,t,r,s),Cze(this)}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect"),ol(t,"hand_landmarks"),ol(t,"world_hand_landmarks"),ol(t,"handedness");const s=new zf;J0(s,nNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"LANDMARKS:hand_landmarks"),Fo(r,"WORLD_LANDMARKS:world_hand_landmarks"),Fo(r,"HANDEDNESS:handedness"),r.o(s),Xx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=$R(o),this.landmarks.push(Tme(n));pa(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{pa(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=ST(o),this.worldLandmarks.push(B8(n));pa(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{pa(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=Cme(c);const u=[];for(const m of n.g())u.push({score:Ld(m,2)??0,index:Mx(m,1)??0??-1,categoryName:Dh(td(m,3))??""??"",displayName:Dh(td(m,4))??""??""});i.push(u)}l.call(o,...i),pa(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{pa(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 Go(Zp,t,{baseOptions:{modelAssetPath:s}})},Zp.createFromModelBuffer=function(t,s){return Go(Zp,t,{baseOptions:{modelAssetBuffer:s}})},Zp.createFromOptions=function(t,s){return Go(Zp,t,s)},Zp.HAND_CONNECTIONS=j3e;var Flt=yy([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 Mze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Tze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{Eme(t)}}function v9(t,s){t=$R(t),s.push(Tme(t))}var Lc=class extends If{constructor(t,s){super(new vy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,mi(t=this.j=new mlt,0,1,s=new Cd),this.I=new c3e,mi(this.j,0,2,this.I),this.W=new aNs,mi(this.j,0,3,this.W),this.u=new Mme,mi(this.j,0,4,this.u),this.O=new nlt,mi(this.j,0,5,this.O),this.A=new ult,mi(this.j,0,6,this.A),this.M=new hlt,mi(this.j,0,7,this.M),Ya(this.u,2,.5),Ya(this.u,3,.3),Ya(this.O,2,.5),Ya(this.A,2,.5),Ya(this.A,3,.3),Ya(this.M,2,.5),Ya(this.I,2,.5)}get baseOptions(){return Jo(this.j,Cd,1)}set baseOptions(t){mi(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Ya(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Ya(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Ya(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Ya(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Ya(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Ya(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Ya(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,Mze(this),by(this,t,n),Tze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,Mze(this),tv(this,t,a,s),Tze(this)}m(){var t=new Bf;ad(t,"input_frames_image"),ol(t,"pose_landmarks"),ol(t,"pose_world_landmarks"),ol(t,"face_landmarks"),ol(t,"left_hand_landmarks"),ol(t,"left_hand_world_landmarks"),ol(t,"right_hand_landmarks"),ol(t,"right_hand_world_landmarks");const s=new zf,r=new J7e;Pf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))Ml(a,2,fme(o,0,NO));else{if(!(typeof o=="string"||o instanceof I0||TSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");c_(a,2,ESe(o,!1),b3())}}(r,this.j.g());const n=new Op;Pf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),HSe(n,8,J7e,r),Hc(n,"IMAGE:input_frames_image"),Fo(n,"POSE_LANDMARKS:pose_landmarks"),Fo(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Fo(n,"FACE_LANDMARKS:face_landmarks"),Fo(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Fo(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Fo(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Fo(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Xx(t,n),Ame(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{v9(a,this.h.poseLandmarks),pa(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{pa(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=ST(a),l.push(B8(a)),pa(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{pa(this,a)}),this.outputPoseSegmentationMasks&&(Fo(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),WA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[ZA(this,a,!0,!this.D)],pa(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],pa(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{v9(a,this.h.faceLandmarks),pa(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{pa(this,a)}),this.outputFaceBlendshapes&&(ol(t,"extra_blendshapes"),Fo(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Cme(a),l.push(p3e(a.g()??[]))),pa(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{pa(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{v9(a,this.h.leftHandLandmarks),pa(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{pa(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=ST(a),l.push(B8(a)),pa(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{pa(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{v9(a,this.h.rightHandLandmarks),pa(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{pa(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=ST(a),l.push(B8(a)),pa(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{pa(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Lc.prototype.detectForVideo=Lc.prototype.G,Lc.prototype.detect=Lc.prototype.F,Lc.prototype.setOptions=Lc.prototype.o,Lc.createFromModelPath=function(t,s){return Go(Lc,t,{baseOptions:{modelAssetPath:s}})},Lc.createFromModelBuffer=function(t,s){return Go(Lc,t,{baseOptions:{modelAssetBuffer:s}})},Lc.createFromOptions=function(t,s){return Go(Lc,t,s)},Lc.HAND_CONNECTIONS=j3e,Lc.POSE_CONNECTIONS=Flt,Lc.FACE_LANDMARKS_LIPS=g3e,Lc.FACE_LANDMARKS_LEFT_EYE=y3e,Lc.FACE_LANDMARKS_LEFT_EYEBROW=v3e,Lc.FACE_LANDMARKS_LEFT_IRIS=Llt,Lc.FACE_LANDMARKS_RIGHT_EYE=b3e,Lc.FACE_LANDMARKS_RIGHT_EYEBROW=_3e,Lc.FACE_LANDMARKS_RIGHT_IRIS=Dlt,Lc.FACE_LANDMARKS_FACE_OVAL=w3e,Lc.FACE_LANDMARKS_CONTOURS=Olt,Lc.FACE_LANDMARKS_TESSELATION=Rlt;var ox=class extends If{constructor(t,s){super(new vy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},mi(t=this.h=new plt,0,1,s=new Cd)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return mi(this.h,0,2,fwe(t,Jo(this.h,o3e,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},by(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},tv(this,t,r,s),this.j}m(){var t=new Bf;ad(t,"input_image"),ad(t,"norm_rect"),ol(t,"classifications");const s=new zf;J0(s,iNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Hc(r,"IMAGE:input_image"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"CLASSIFICATIONS:classifications"),r.o(s),Xx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=hNs(Kjs(n)),pa(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ox.prototype.classifyForVideo=ox.prototype.ta,ox.prototype.classify=ox.prototype.sa,ox.prototype.setOptions=ox.prototype.o,ox.createFromModelPath=function(t,s){return Go(ox,t,{baseOptions:{modelAssetPath:s}})},ox.createFromModelBuffer=function(t,s){return Go(ox,t,{baseOptions:{modelAssetBuffer:s}})},ox.createFromOptions=function(t,s){return Go(ox,t,s)};var Yp=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!0),this.h=new flt,this.embeddings={embeddings:[]},mi(t=this.h,0,1,s=new Cd)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){var s=this.h,r=Jo(this.h,lze,2);return r=r?r.clone():new lze,t.l2Normalize!==void 0?Ml(r,1,jO(t.l2Normalize)):"l2Normalize"in t&&Ml(r,1),t.quantize!==void 0?Ml(r,2,jO(t.quantize)):"quantize"in t&&Ml(r,2),mi(s,0,2,r),this.l(t)}za(t,s){return by(this,t,s),this.embeddings}Aa(t,s,r){return tv(this,t,r,s),this.embeddings}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect"),ol(t,"embeddings_out");const s=new zf;J0(s,oNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"EMBEDDINGS:embeddings_out"),r.o(s),Xx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=Qjs(n),this.embeddings=function(o){return{embeddings:U1(o,Yjs,1).map(l=>{var u,m;const i={headIndex:Mx(l,3)??0??-1,headName:Dh(td(l,4))??""??""};var c=l.v;return hot(c,0|c[Da],oze,Oye(l,1))!==void 0?(l=R4(l=Jo(l,oze,Oye(l,1),void 0),1,m0,O4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((m=(u=Jo(l,Zjs,Oye(l,2),void 0))==null?void 0:u.na())==null?void 0:m.h())??c),i}),timestampMs:wlt(td(o,2,void 0,void 0,ode)??oot)}}(n),pa(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Yp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=pze(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=pze(mze(t.quantizedEmbedding),mze(s.quantizedEmbedding))}return t},Yp.prototype.embedForVideo=Yp.prototype.Aa,Yp.prototype.embed=Yp.prototype.za,Yp.prototype.setOptions=Yp.prototype.o,Yp.createFromModelPath=function(t,s){return Go(Yp,t,{baseOptions:{modelAssetPath:s}})},Yp.createFromModelBuffer=function(t,s){return Go(Yp,t,{baseOptions:{modelAssetBuffer:s}})},Yp.createFromOptions=function(t,s){return Go(Yp,t,s)};var vwe=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 vNs(t){var r,n;const s=function(a){return U1(a,Op,1)}(t.ca()).filter(a=>(Dh(td(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=Jo(s[0],zf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=Dh(td(a,1))??""})}function Aze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Eze(t){try{const s=new vwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{Eme(t)}}vwe.prototype.close=vwe.prototype.close;var _m=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new m3e,this.A=new xlt,mi(this.h,0,3,this.A),mi(t=this.h,0,1,s=new Cd)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Ml(this.h,2,FR(t.displayNamesLocale)):"displayNamesLocale"in t&&Ml(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){vNs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,Aze(this),by(this,t,n),Eze(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Aze(this),tv(this,t,a,s),Eze(this)}Da(){return this.u}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect");const s=new zf;J0(s,ylt,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),r.o(s),Xx(t,r),Ame(this,t),this.outputConfidenceMasks&&(ol(t,"confidence_masks"),Fo(r,"CONFIDENCE_MASKS:confidence_masks"),WA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>ZA(this,o,!0,!this.j)),pa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],pa(this,n)})),this.outputCategoryMask&&(ol(t,"category_mask"),Fo(r,"CATEGORY_MASK:category_mask"),WA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=ZA(this,n,!1,!this.j),pa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,pa(this,n)})),ol(t,"quality_scores"),Fo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,pa(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};_m.prototype.getLabels=_m.prototype.Da,_m.prototype.segmentForVideo=_m.prototype.La,_m.prototype.segment=_m.prototype.segment,_m.prototype.setOptions=_m.prototype.o,_m.createFromModelPath=function(t,s){return Go(_m,t,{baseOptions:{modelAssetPath:s}})},_m.createFromModelBuffer=function(t,s){return Go(_m,t,{baseOptions:{modelAssetBuffer:s}})},_m.createFromOptions=function(t,s){return Go(_m,t,s)};var bwe=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()}};bwe.prototype.close=bwe.prototype.close;var Hy=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new m3e,this.u=new xlt,mi(this.h,0,3,this.u),mi(t=this.h,0,1,s=new Cd)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(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 vlt,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new Bye;c_(o,3,jO(!0),!1),c_(o,1,QI(s.keypoint.x),0),c_(o,2,QI(s.keypoint.y),0),F8(n,1,pwe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new cNs;for(o of s.scribble)c_(s=new Bye,3,jO(!0),!1),c_(s,1,QI(o.x),0),c_(s,2,QI(o.y),0),HSe(i,1,Bye,s);F8(n,2,pwe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),by(this,t,a);e:{try{const i=new bwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{Eme(this)}l=void 0}return l}m(){var t=new Bf;ad(t,"image_in"),ad(t,"roi_in"),ad(t,"norm_rect_in");const s=new zf;J0(s,ylt,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Hc(r,"IMAGE:image_in"),Hc(r,"ROI:roi_in"),Hc(r,"NORM_RECT:norm_rect_in"),r.o(s),Xx(t,r),Ame(this,t),this.outputConfidenceMasks&&(ol(t,"confidence_masks"),Fo(r,"CONFIDENCE_MASKS:confidence_masks"),WA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>ZA(this,o,!0,!this.j)),pa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],pa(this,n)})),this.outputCategoryMask&&(ol(t,"category_mask"),Fo(r,"CATEGORY_MASK:category_mask"),WA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=ZA(this,n,!1,!this.j),pa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,pa(this,n)})),ol(t,"quality_scores"),Fo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,pa(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Hy.prototype.segment=Hy.prototype.segment,Hy.prototype.setOptions=Hy.prototype.o,Hy.createFromModelPath=function(t,s){return Go(Hy,t,{baseOptions:{modelAssetPath:s}})},Hy.createFromModelBuffer=function(t,s){return Go(Hy,t,{baseOptions:{modelAssetBuffer:s}})},Hy.createFromOptions=function(t,s){return Go(Hy,t,s)};var lx=class extends If{constructor(t,s){super(new vy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},mi(t=this.h=new blt,0,1,s=new Cd)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Ml(this.h,2,FR(t.displayNamesLocale)):"displayNamesLocale"in t&&Ml(this.h,2),t.maxResults!==void 0?V1(this.h,3,t.maxResults):"maxResults"in t&&Ml(this.h,3),t.scoreThreshold!==void 0?Ya(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Ml(this.h,4),t.categoryAllowlist!==void 0?cde(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Ml(this.h,5),t.categoryDenylist!==void 0?cde(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Ml(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},by(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},tv(this,t,r,s),this.j}m(){var t=new Bf;ad(t,"input_frame_gpu"),ad(t,"norm_rect"),ol(t,"detections");const s=new zf;J0(s,dNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Hc(r,"IMAGE:input_frame_gpu"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"DETECTIONS:detections"),r.o(s),Xx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Qot(o),this.j.detections.push(jlt(n));pa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{pa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};lx.prototype.detectForVideo=lx.prototype.G,lx.prototype.detect=lx.prototype.F,lx.prototype.setOptions=lx.prototype.o,lx.createFromModelPath=async function(t,s){return Go(lx,t,{baseOptions:{modelAssetPath:s}})},lx.createFromModelBuffer=function(t,s){return Go(lx,t,{baseOptions:{modelAssetBuffer:s}})},lx.createFromOptions=function(t,s){return Go(lx,t,s)};var _we=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 Pze(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function Ize(t){try{const s=new _we(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{Eme(t)}}_we.prototype.close=_we.prototype.close;var Qp=class extends If{constructor(t,s){super(new vy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,mi(t=this.h=new _lt,0,1,s=new Cd),this.A=new hlt,mi(this.h,0,3,this.A),this.j=new ult,mi(this.h,0,2,this.j),V1(this.j,4,1),Ya(this.j,2,.5),Ya(this.A,2,.5),Ya(this.h,4,.5)}get baseOptions(){return Jo(this.h,Cd,1)}set baseOptions(t){mi(this.h,0,1,t)}o(t){return"numPoses"in t&&V1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Ya(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Ya(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Ya(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,Pze(this),by(this,t,n),Ize(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,Pze(this),tv(this,t,a,s),Ize(this)}m(){var t=new Bf;ad(t,"image_in"),ad(t,"norm_rect"),ol(t,"normalized_landmarks"),ol(t,"world_landmarks"),ol(t,"segmentation_masks");const s=new zf;J0(s,uNs,this.h);const r=new Op;Pf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Fo(r,"NORM_LANDMARKS:normalized_landmarks"),Fo(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Xx(t,r),Ame(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=$R(o),this.landmarks.push(Tme(n));pa(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],pa(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=ST(o),this.worldLandmarks.push(B8(n));pa(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],pa(this,n)}),this.outputSegmentationMasks&&(Fo(r,"SEGMENTATION_MASK:segmentation_masks"),WA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>ZA(this,o,!0,!this.u)),pa(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],pa(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Qp.prototype.detectForVideo=Qp.prototype.G,Qp.prototype.detect=Qp.prototype.F,Qp.prototype.setOptions=Qp.prototype.o,Qp.createFromModelPath=function(t,s){return Go(Qp,t,{baseOptions:{modelAssetPath:s}})},Qp.createFromModelBuffer=function(t,s){return Go(Qp,t,{baseOptions:{modelAssetBuffer:s}})},Qp.createFromOptions=function(t,s){return Go(Qp,t,s)},Qp.POSE_CONNECTIONS=Flt;let F4=null,XI=null;async function bNs(){return F4||XI||(XI=(async()=>{const t=await iM.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return F4=await _m.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}),F4})(),XI)}function _Ns(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[c+m]);const g=Math.min(f,r-1)-Math.max(m+1,0)+1;o[c+u]=i/g}}for(let l=0;l=0&&(i-=o[u*r+l]);const f=Math.min(m,n-1)-Math.max(u+1,0)+1;s[c*r+l]=i/f}}}function wNs(){F4&&(F4.close(),F4=null,XI=null)}function jNs(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),[m,f]=k.useState(!1),[g,y]=k.useState(null),_=s.type!=="none"&&t!==null;return k.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const w=new Image;w.crossOrigin="anonymous",w.src=s.imageUrl,w.onload=()=>{o.current=w}}else o.current=null},[s.type,s.imageUrl]),k.useEffect(()=>{if(!_||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const w=document.createElement("video");return w.srcObject=t,w.muted=!0,w.playsInline=!0,w.autoplay=!0,w.play().catch(()=>{}),a.current=w,()=>{w.srcObject=null,a.current=null}},[_,t]),k.useEffect(()=>{if(!_){u(null),y(null);return}let w=!1;return(async()=>{f(!0),y(null);try{const N=await bNs();if(w)return;f(!1);const S=a.current;if(!S||(await new Promise(ge=>{if(S.videoWidth>0)return ge();S.onloadedmetadata=()=>ge(),setTimeout(ge,2e3)}),w))return;const M=S.videoWidth||640,I=S.videoHeight||480,P=r.current;if(!P)return;P.width=M,P.height=I;const O=P.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const q=n.current;q.width=M,q.height=I;const $=q.getContext("2d",{willReadFrequently:!0}),z=document.createElement("canvas");z.width=M,z.height=I;const V=z.getContext("2d"),X=P.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(ge=>X.addTrack(ge)),w||u(X);const J=s.blurRadius??15,Q=s.mirror??!1,ce=new Float32Array(M*I),ne=new Float32Array(M*I),re=new Float32Array(M*I);let oe=!1;const he=4,xe=.6,ue=()=>{if(w||!a.current)return;const ge=performance.now();if(ge-i.current<30){l.current=requestAnimationFrame(ue);return}i.current=ge;const _e=a.current;if(_e.readyState<2){l.current=requestAnimationFrame(ue);return}try{const Se=N.segmentForVideo(_e,ge).confidenceMasks;if(Se&&Se.length>0){ne.fill(0);for(let Me=1;MeOe?(dt=Me.height*Oe,qe=(Me.width-dt)/2):(pe=Me.width/Oe,ve=(Me.height-pe)/2),O.drawImage(Me,qe,ve,dt,pe,0,0,M,I)}$.clearRect(0,0,M,I),$.drawImage(_e,0,0,M,I);const Ee=$.getImageData(0,0,M,I),Ae=Ee.data;for(let Me=0;Me{w=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[_,s.type,s.blurRadius,s.imageUrl,t]),k.useEffect(()=>()=>{wNs()},[]),{canvasRef:r,compositedStream:c,isLoading:m,isActive:_,error:g}}function Pme({maxDurationSeconds:t=300,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=k.useRef(null),i=k.useRef(null),c=k.useRef(null),[u,m]=k.useState(null),f=k.useRef([]),g=k.useRef(null),y=k.useRef(null),_=k.useRef(null),w=k.useRef(null),j=UE(),[N,S]=k.useState("camera"),M=k.useRef(null),I=k.useRef(null),P=k.useRef(null),O=k.useRef(null),q=k.useRef(null),[$,z]=k.useState(!0),[V,X]=k.useState(!0),[Y,J]=k.useState(null),[Q,ce]=k.useState(!1),[ne,re]=k.useState(!1),[oe,he]=k.useState(null),[xe,ue]=k.useState(null),[ge,_e]=k.useState(0),[Be,Se]=k.useState("user"),[Ee,Ae]=k.useState(0),[Me,ke]=k.useState(!1),[Oe,qe]=k.useState(!0),[ve,dt]=k.useState(null),[pe,Ue]=k.useState(!1),[Xe,et]=k.useState(null),Ce=k.useRef(null),[Je,Ge]=k.useState(()=>{try{const tr=localStorage.getItem("video-bg-config");if(tr)return JSON.parse(tr)}catch{}return{type:"none"}});k.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(Je))}catch{}},[Je]);const{canvasRef:lt,compositedStream:He,isLoading:We,isActive:tt}=jNs(u,Je),Ke=k.useRef(r);Ke.current=r;const rt=k.useCallback(tr=>{z(tr)},[]),it=k.useRef($),It=k.useCallback(()=>{P.current&&(cancelAnimationFrame(P.current),P.current=null),M.current&&(M.current.getTracks().forEach(tr=>tr.stop()),M.current=null),O.current&&(O.current.getTracks().forEach(tr=>tr.stop()),O.current=null),q.current&&(q.current.srcObject=null,q.current=null)},[]),Vt=k.useCallback(async()=>{var tr;try{const dr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});M.current=dr;let Sr=null;try{Sr=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(!Sr)try{dn=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Yr=dr.getVideoTracks()[0],ui=Yr.getSettings(),ns=ui.width||1920,Wt=ui.height||1080,Hr=document.createElement("canvas");Hr.width=ns,Hr.height=Wt,I.current=Hr;const Mr=Hr.getContext("2d");let xr=null;Sr&&(xr=document.createElement("video"),xr.srcObject=Sr,xr.muted=!0,xr.playsInline=!0,xr.autoplay=!0,await xr.play(),q.current=xr);const Wn=document.createElement("video");Wn.srcObject=dr,Wn.muted=!0,Wn.playsInline=!0,Wn.autoplay=!0,await Wn.play();const ai=()=>{if(Mr.drawImage(Wn,0,0,ns,Wt),xr&&xr.readyState>=2){const $e=Math.round(ns*.2),st=Math.round($e*(xr.videoHeight/xr.videoWidth||.75)),vt=ns-$e-20,xt=Wt-st-20,Ot=12;Mr.save(),Mr.beginPath(),Mr.moveTo(vt+Ot,xt),Mr.lineTo(vt+$e-Ot,xt),Mr.quadraticCurveTo(vt+$e,xt,vt+$e,xt+Ot),Mr.lineTo(vt+$e,xt+st-Ot),Mr.quadraticCurveTo(vt+$e,xt+st,vt+$e-Ot,xt+st),Mr.lineTo(vt+Ot,xt+st),Mr.quadraticCurveTo(vt,xt+st,vt,xt+st-Ot),Mr.lineTo(vt,xt+Ot),Mr.quadraticCurveTo(vt,xt,vt+Ot,xt),Mr.closePath(),Mr.clip(),Mr.translate(vt+$e,xt),Mr.scale(-1,1),Mr.drawImage(xr,0,0,$e,st),Mr.restore(),Mr.strokeStyle="rgba(255,255,255,0.6)",Mr.lineWidth=2,Mr.beginPath(),Mr.moveTo(vt+Ot,xt),Mr.lineTo(vt+$e-Ot,xt),Mr.quadraticCurveTo(vt+$e,xt,vt+$e,xt+Ot),Mr.lineTo(vt+$e,xt+st-Ot),Mr.quadraticCurveTo(vt+$e,xt+st,vt+$e-Ot,xt+st),Mr.lineTo(vt+Ot,xt+st),Mr.quadraticCurveTo(vt,xt+st,vt,xt+st-Ot),Mr.lineTo(vt,xt+Ot),Mr.quadraticCurveTo(vt,xt,vt+Ot,xt),Mr.closePath(),Mr.stroke()}P.current=requestAnimationFrame(ai)};ai();const Aa=Hr.captureStream(30),no=[],$t=dr.getAudioTracks();if($t.length&&no.push(...$t),Sr){const $e=Sr.getAudioTracks();$e.length&&no.push(...$e)}else dn&&no.push(...dn.getAudioTracks());const je=new MediaStream([...Aa.getVideoTracks(),...no]);return O.current=je,Yr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),It()},je}catch(dr){return console.error("[VideoRecorder] Screen capture error:",dr),dr.name!=="NotAllowedError"&&((tr=Ke.current)==null||tr.call(Ke,"Failed to start screen capture: "+(dr.message||"Unknown error"))),null}},[It]),hs=k.useCallback(async()=>{var dr,Sr;X(!0),dt(null);const tr=j&&$;console.log("[VideoRecorder] initCamera start",{isMobile:j,usePortraitMode:$,shouldBePortrait:tr,facingMode:Be});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(Wt=>Wt.stop()));const dn=j&&tr?{facingMode:{ideal:Be},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Be},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,m(Yr),J(!0);const ns=Yr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ns.width,"x",ns.height),l.current){const Wt=l.current;Wt.srcObject=Yr,Wt.muted=!0,Wt.playsInline=!0,Wt.autoplay=!0,Wt.setAttribute("muted",""),Wt.setAttribute("playsinline",""),Wt.setAttribute("autoplay","");try{(dr=Wt.load)==null||dr.call(Wt)}catch(Mr){console.warn("[VideoRecorder] videoEl.load failed",Mr)}const Hr=async()=>{try{return await Wt.play(),console.log("[VideoRecorder] preview play ok"),Ue(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:Wt.readyState,videoWidth:Wt.videoWidth,videoHeight:Wt.videoHeight})},300),!0}catch(Mr){return console.warn("[VideoRecorder] preview play blocked",Mr),Ue(!0),!1}};await new Promise(Mr=>{let xr=!1;const Wn=()=>{xr||(xr=!0,Mr())},ai=()=>{Hr().finally(Wn)};Wt.onloadedmetadata=ai,Wt.onloadeddata=ai,setTimeout(Wn,1500)})}try{y.current=new AudioContext;const Wt=y.current.createMediaStreamSource(Yr);_.current=y.current.createAnalyser(),_.current.fftSize=256,Wt.connect(_.current);const Hr=()=>{if(_.current){const Mr=new Uint8Array(_.current.frequencyBinCount);_.current.getByteFrequencyData(Mr);const xr=Mr.reduce((Wn,ai)=>Wn+ai)/Mr.length;Ae(Math.min(100,xr/128*100))}w.current=requestAnimationFrame(Hr)};Hr()}catch(Wt){console.warn("Audio context not available:",Wt)}}catch(dn){console.error("Camera initialization error:",dn),J(!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),dt(Yr),(Sr=Ke.current)==null||Sr.call(Ke,Yr)}finally{X(!1)}},[Be,j,$]);k.useEffect(()=>{it.current!==$&&Y&&!Q&&!xe&&(it.current=$,hs())},[$,Y,Q,xe,hs]),k.useEffect(()=>(hs(),()=>{c.current&&c.current.getTracks().forEach(tr=>tr.stop()),g.current&&clearInterval(g.current),w.current&&cancelAnimationFrame(w.current),y.current&&y.current.close(),Ce.current&&clearInterval(Ce.current),xe&&URL.revokeObjectURL(xe),It()}),[hs,xe]),k.useEffect(()=>{if(V||Y!==!0||xe)return;const tr=c.current,dr=l.current;!tr||!dr||tt||(dr.srcObject!==tr&&(dr.srcObject=tr,dr.muted=!0,dr.playsInline=!0,dr.autoplay=!0,dr.setAttribute("muted",""),dr.setAttribute("playsinline",""),dr.setAttribute("autoplay","")),dr.play().then(()=>Ue(!1)).catch(Sr=>{Ue(!0),console.warn("Live preview play blocked on mount:",Sr)}))},[Y,V,xe,tt]),k.useEffect(()=>{n==null||n(Q)},[Q,n]);const Es=k.useCallback(async()=>{if(xe)return;const tr=l.current;if(tr)try{await tr.play(),Ue(!1)}catch(dr){Ue(!0),console.warn("Live preview still blocked (needs user gesture):",dr)}},[xe]),Ts=k.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),g.current&&(clearInterval(g.current),g.current=null),It(),ce(!1),re(!1)},[It]),cr=k.useCallback(async()=>{let tr=null;if(N==="screen"){if(tr=await Vt(),!tr)return}else tr=tt&&He?He:c.current;if(!tr)return;Es(),f.current=[],_e(0);const Sr=["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(tr,Sr?{mimeType:Sr,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 Wt;const Yr=dn.mimeType||Sr||((Wt=f.current[0])==null?void 0:Wt.type)||"video/webm",ui=new Blob(f.current,{type:Yr});he(ui);const ns=URL.createObjectURL(ui);ue(ns)},i.current=dn,dn.start(100),ce(!0),g.current=setInterval(()=>{_e(Yr=>Yr>=t-1?(Ts(),t):Yr+1)},1e3)},[Es,t,Ts,tt,He,N,Vt]),zr=k.useCallback(()=>{Ce.current&&(clearInterval(Ce.current),Ce.current=null),et(3);let tr=3;Ce.current=setInterval(()=>{tr-=1,tr<=0?(Ce.current&&clearInterval(Ce.current),Ce.current=null,et(null),cr()):et(tr)},1e3)},[cr]),Ft=k.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),re(!0),g.current&&clearInterval(g.current))},[]),Ps=k.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),re(!1),g.current=setInterval(()=>{_e(tr=>tr>=t-1?(Ts(),t):tr+1)},1e3))},[t,Ts]),yr=k.useCallback(()=>{xe&&URL.revokeObjectURL(xe),he(null),ue(null),_e(0),ke(!1),qe(!0),l.current&&c.current&&!tt&&(l.current.srcObject=c.current,l.current.muted=!0,Es())},[Es,xe,tt]),Is=k.useCallback(()=>{Se(tr=>tr==="user"?"environment":"user")},[]),Ar=k.useCallback(()=>{oe&&s(oe,ge)},[oe,ge,s]),tn=k.useCallback(()=>{l.current&&xe&&(Me?l.current.pause():(qe(!1),l.current.muted=!1,l.current.play()),ke(!Me))},[xe,Me]);k.useEffect(()=>{if(!xe)return;const tr=l.current;if(!tr)return;qe(!1),tr.pause(),tr.removeAttribute("src"),tr.srcObject=null,tr.load(),tr.src=xe,tr.currentTime=0,tr.playsInline=!0,tr.muted=!1,tr.onended=()=>ke(!1);const dr=()=>{var Yr;const Sr=tr.error,dn=Sr?`Recorded video failed to play (code ${Sr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Sr),(Yr=Ke.current)==null||Yr.call(Ke,dn)};return tr.addEventListener("error",dr),tr.load(),()=>{tr.removeEventListener("error",dr)}},[xe]);const na=tr=>{const dr=Math.floor(tr/60),Sr=tr%60;return`${dr}:${Sr.toString().padStart(2,"0")}`},Ln=N==="screen"?"aspect-video":j&&$?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Ln,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ys,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Y===!1?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Ln,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(ul,{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:ve||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(G,{onClick:()=>hs(),variant:"secondary",className:"w-full",children:[e.jsx(zo,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:Pt("flex flex-col gap-2",a),children:[!Q&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(G,{variant:N==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("camera"),children:[e.jsx(gf,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(G,{variant:N==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("screen"),children:[e.jsx(yS,{className:"h-4 w-4"}),"Screen"]})]}),N==="camera"&&!Q&&!xe&&e.jsx(O2s,{value:Je,onChange:Ge,isLoading:We,disabled:Q}),N==="camera"&&j&&!Q&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(vS,{className:Pt("h-4 w-4",$?"text-muted-foreground":"text-primary")}),e.jsx(ye,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(qr,{id:"orientation-toggle",checked:$,onCheckedChange:rt}),e.jsx(ye,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(N0,{className:Pt("h-4 w-4",$?"text-primary":"text-muted-foreground")})]}),N==="screen"&&!Q&&!xe&&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(yS,{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:Pt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{Es()},children:[e.jsx("video",{ref:l,src:xe??void 0,className:Pt("w-full bg-black",$&&!xe?"object-contain":"object-cover",Ln,!xe&&Be==="user"!==(Je.mirror??!1)&&"scale-x-[-1]",tt&&!xe&&"hidden"),playsInline:!0,controls:!!xe,muted:xe?Oe:!0,autoPlay:!xe},xe??"live"),tt&&!xe&&e.jsx("canvas",{ref:lt,className:Pt("w-full bg-black",$?"object-contain":"object-cover",Ln,Be==="user"!==(Je.mirror??!1)&&"scale-x-[-1]")}),tt&&We&&!xe&&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(ys,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!xe&&pe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(G,{type:"button",variant:"secondary",onClick:()=>void Es(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!xe&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Xe!==null&&!xe&&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:Xe},Xe),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),Q&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:Pt("w-3 h-3 rounded-full",ne?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[na(ge)," / ",na(t)]})]}),Q&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(qi,{value:ge/t*100,className:"h-1 rounded-none"})}),!xe&&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(LL,{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:`${Ee}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:xe?e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:yr,children:[e.jsx(zo,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(G,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:tn,children:Me?e.jsx(Ih,{className:"h-5 w-5"}):e.jsx(sl,{className:"h-5 w-5"})}),e.jsxs(G,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Ar,children:[e.jsx(ua,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[N==="camera"?e.jsx(G,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Is,disabled:Q||Xe!==null,children:e.jsx(w0,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!Q&&Xe===null?e.jsx(G,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:N==="screen"?cr:zr,children:N==="screen"?e.jsx(yS,{className:"h-6 w-6"}):e.jsx(An,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(G,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ne?Ps:Ft,children:ne?e.jsx(sl,{className:"h-5 w-5"}):e.jsx(Ih,{className:"h-5 w-5"})}),e.jsx(G,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Ts,children:e.jsx(k0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const zlt="teleprompter_settings",qye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function NNs(){try{const t=localStorage.getItem(zlt);return t?{...qye,...JSON.parse(t)}:qye}catch{return qye}}function kNs(t){try{localStorage.setItem(zlt,JSON.stringify(t))}catch{}}function Blt({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),m=k.useRef(0),[f,g]=k.useState(NNs),{scrollSpeed:y,fontSize:_,lineHeight:w,opacity:j,position:N,isMirrored:S}=f,M=k.useCallback((Y,J)=>{g(Q=>{const ce={...Q,[Y]:J};return kNs(ce),ce})},[]),[I,P]=k.useState(!1),[O,q]=k.useState(null),$=k.useCallback(Y=>{if(!i.current)return;u.current===0&&(u.current=Y);const J=Y-u.current;u.current=Y,m.current+=y*J/1e3;const Q=Math.floor(m.current);Q>0&&(i.current.scrollTop+=Q,m.current-=Q);const{scrollTop:ce,scrollHeight:ne,clientHeight:re}=i.current;if(ce+re>=ne){P(!1);return}c.current=requestAnimationFrame($)},[y]);k.useEffect(()=>(I?(u.current=0,m.current=0,c.current=requestAnimationFrame($)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[I,$]),k.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){q(3);let Y=3;const J=setInterval(()=>{Y-=1,Y<=0?(clearInterval(J),q(null),o==null||o(),P(!0)):q(Y)},1e3);return()=>clearInterval(J)}else setTimeout(()=>P(!0),100);else n||(P(!1),q(null))},[n,s,a,o]);const z=k.useCallback(()=>{i.current&&(i.current.scrollTop=0),P(!1)},[]),V=k.useCallback(()=>{P(Y=>!Y)},[]);if(!s)return e.jsx("div",{className:Pt("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(G,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const X={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Pt("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:Pt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",X[N],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:j},children:e.jsxs("div",{ref:i,className:Pt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${_}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsx(G,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(el,{className:"h-4 w-4"})})}),e.jsx($o,{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(ye,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:y})]}),e.jsx(Qg,{value:[y],onValueChange:([Y])=>M("scrollSpeed",Y),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(ye,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_,"px"]})]}),e.jsx(Qg,{value:[_],onValueChange:([Y])=>M("fontSize",Y),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(ye,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(Qg,{value:[w*10],onValueChange:([Y])=>M("lineHeight",Y/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(ye,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(j*100),"%"]})]}),e.jsx(Qg,{value:[j*100],onValueChange:([Y])=>M("opacity",Y/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>M("position","top"),children:e.jsx(Sp,{className:"h-4 w-4"})}),e.jsx(G,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>M("position","center"),children:e.jsx(v0,{className:"h-4 w-4"})}),e.jsx(G,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>M("position","bottom"),children:e.jsx(Ji,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-xs",children:"Mirror Mode"}),e.jsx(qr,{checked:S,onCheckedChange:Y=>M("isMirrored",Y)})]})]})})]}),e.jsx(G,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(Ih,{className:"h-4 w-4"}):e.jsx(sl,{className:"h-4 w-4"})}),e.jsx(G,{variant:"secondary",size:"icon",onClick:z,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(w0,{className:"h-4 w-4"})}),e.jsxs(G,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Cp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function SNs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ra(),[o,l]=k.useState(""),[i,c]=k.useState(null),[u,m]=k.useState("levelup"),{data:f,isLoading:g}=J_s(),{data:y,isLoading:_}=ews(),{data:w,isLoading:j}=tws(),N=sws(),S=k.useMemo(()=>y?y.filter(q=>{const $=!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())||q.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),z=!i||q.category_id===i;return $&&z}):[],[y,o,i]),M=k.useMemo(()=>w?w.filter(q=>!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),I=q=>{t({title:q.title,text:q.script_text})},P=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||_||j;return e.jsxs("div",{className:Pt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search scripts...",value:o,onChange:q=>l(q.target.value),className:"pl-9"})]})}),e.jsxs(ga,{value:u,onValueChange:q=>m(q),className:"flex-1 flex flex-col",children:[e.jsxs(fa,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ss,{value:"levelup",children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ss,{value:"my-scripts",children:[e.jsx(Ax,{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(Ye,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map(q=>e.jsx(Ye,{variant:i===q.id?"default":"outline",className:"cursor-pointer",onClick:()=>c(q.id),children:q.name},q.id))]}),e.jsx(Li,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ys,{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(wn,{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(Pe,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>I(q),children:[e.jsx(Et,{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(Lt,{className:"text-sm font-medium truncate",children:q.title}),q.category&&e.jsx(Ye,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:$=>{$.stopPropagation(),P(q)},children:e.jsx(Ax,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(De,{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(G,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Li,{className:"flex-1 max-h-[50vh]",children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ys,{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(Ax,{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(Pe,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>I(q),children:[e.jsx(Et,{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(Lt,{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(Ye,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(De,{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 CNs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=k.useState(()=>{const i=pT(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(ye,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(ys,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:bLt.map(i=>{const c=_Lt(i.id),u=a.has(i.id),m=c.some(f=>f.id===t);return e.jsxs(bf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(_f,{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,")"]}),m&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Ji,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(wf,{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:Pt("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(ua,{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: "',pT(t).headerText(r),'"']})]})}function $lt({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,m]=k.useState(!1),[f,g]=k.useState(r.page_template||"default"),[y,_]=k.useState([]),[w,j]=k.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,S]=k.useState(!1),[M,I]=k.useState(!1),P=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";k.useEffect(()=>{t&&y.length===0&&O()},[t]);const O=async()=>{I(!0);try{const{data:ce,error:ne}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ne)throw ne;const re=(ce||[]).map(oe=>({id:oe.id,name:[oe.first_name,oe.last_name].filter(Boolean).join(" ")||"Unnamed",email:oe.email||null}));_(re)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},q=async ce=>{j(ce),S(!1),c(!0);try{const{error:ne}=await H.from("agent_videos").update({contact_id:(ce==null?void 0:ce.id)||null,recipient_name:(ce==null?void 0:ce.name)||null}).eq("id",r.id);if(ne)throw ne;me.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ne){console.error("Failed to update contact:",ne),me.error("Failed to update contact")}finally{c(!1)}},$=async ce=>{l(ce),c(!0);try{const{error:ne}=await H.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ne)throw ne;g(ce),me.success("Template saved!"),a==null||a()}catch(ne){console.error("Failed to save template:",ne),me.error("Failed to save template"),l(f)}finally{c(!1)}},z=(w==null?void 0:w.name)||null,V=()=>{const ce=r.title||"Video Message",ne=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},X=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ce=V(),ne=`Watch: ${r.title||"Video Message"} ${P}`;try{const re=new Blob([ce],{type:"text/html"}),oe=new Blob([ne],{type:"text/plain"}),he=new ClipboardItem({"text/html":re,"text/plain":oe});await navigator.clipboard.write([he]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ne+` `+ce),me.success("Copied! Paste into your email.")}},Y=async()=>{await navigator.clipboard.writeText(P),m(!0),me.success("Share link copied!"),setTimeout(()=>m(!1),2e3)},J=()=>{const ne=pT(o).headerText(z),re=o==="default"?`Check out this video: ${P}`:`${ne} Check out this special video: ${P}`;window.open(`sms:?body=${encodeURIComponent(re)}`,"_self")},Q=()=>{const ce=pT(o),ne=ce.headerText(z),re=o==="default"?r.title||"Video Message":ne,oe=`${ce.subText} Watch the video: ${P}`,he=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${he}?subject=${encodeURIComponent(re)}&body=${encodeURIComponent(oe)}`,"_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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Uo,{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(ye,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Vo,{open:N,onOpenChange:S,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Zi,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search contacts..."}),e.jsxs(qx,{children:[e.jsx(Ux,{children:M?"Loading...":"No contacts found."}),e.jsx(Vx,{children:y.map(ce=>e.jsxs(_p,{value:ce.name,onSelect:()=>q(ce),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",(w==null?void 0:w.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),w&&e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>q(null),disabled:i,className:"shrink-0",children:e.jsx(Er,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',pT(o).headerText(w.name),'"']})]}),e.jsx(CNs,{selectedTemplate:o,onSelect:$,contactName:z,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:P,readOnly:!0,className:"font-mono text-sm"}),e.jsx(G,{onClick:Y,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Share for Email"}),e.jsxs(G,{variant:"outline",className:"w-full gap-2",onClick:X,children:[e.jsx(bl,{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(ye,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{variant:"outline",className:"flex-1 gap-2",onClick:J,children:[e.jsx(Ki,{className:"h-4 w-4"}),"Text"]}),e.jsxs(G,{variant:"outline",className:"flex-1 gap-2",onClick:Q,children:[e.jsx(rr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(Rn,{children:e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function MNs(){var et;const t=ar(),[s]=Ul(),{toast:r}=Ra(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=wit(),{data:u}=nm(),m=B3(),f=ows(),[g,y]=k.useState("record"),[_,w]=k.useState(""),[j,N]=k.useState(!1),[S,M]=k.useState(!1),[I,P]=k.useState(!1),[O,q]=k.useState(null),[$,z]=k.useState(0),[V,X]=k.useState(0),[Y,J]=k.useState(null),[Q,ce]=k.useState(null),[ne,re]=k.useState(n||""),[oe,he]=k.useState(""),[xe,ue]=k.useState(""),[ge,_e]=k.useState(null),[Be,Se]=k.useState(null),[Ee,Ae]=k.useState(null),[Me,ke]=k.useState(!1),Oe=k.useCallback(async(Ce,Je)=>{q(Ce),y("uploading");try{const{videoId:Ge,uploadUrl:lt}=await ER(oe||"Quick Video Touch");J(Ge);const{apiKey:He}=await PR(Ge),We=new XMLHttpRequest;We.upload.onprogress=it=>{it.lengthComputable&&z(it.loaded/it.total*100)},await new Promise((it,It)=>{We.onload=()=>{We.status>=200&&We.status<300?it():It(new Error(`Upload failed: ${We.status}`))},We.onerror=()=>It(new Error("Upload failed")),We.open("PUT",lt),We.setRequestHeader("AccessKey",He),We.send(Ce)}),y("processing");let tt=0;const Ke=Date.now(),rt=90*1e3;for(;tt<4;){if(await new Promise(It=>setTimeout(It,3e3)),Date.now()-Ke>rt){const It=Ce.size/1048576,Vt=`https://iframe.mediadelivery.net/play/${Ge}/${Ge}`;await m.mutateAsync({bunny_video_id:Ge,playback_url:Vt,file_size_mb:It,title:oe||"Quick Video Touch",notes:xe||void 0,contact_id:ne&&ne!=="none"?ne: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 FA(Ge);if(tt=it.status,X(it.encodeProgress||0),tt===4)ce({playbackUrl:it.directPlayUrl,thumbnailUrl:it.thumbnailUrl,previewUrl:it.previewUrl||null,duration:it.length||Je,fileSizeMb:(it.storageSize||Ce.size)/(1024*1024)});else if(tt===5||tt===6)throw new Error("Video processing failed")}y("details")}catch(Ge){console.error("Upload error:",Ge),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),y("record")}},[oe,r]),qe=async()=>{if(!(!Y||!Q))try{const Ce=ne&&ne!=="none"?ne:null,Je=await m.mutateAsync({bunny_video_id:Y,contact_id:Ce,playback_url:Q.playbackUrl,thumbnail_url:Q.thumbnailUrl,preview_url:Q.previewUrl,duration_seconds:Q.duration,file_size_mb:Q.fileSizeMb,title:oe||"Quick Video Touch",notes:xe,task_id:a||null,status:"ready"});_e(Je.id),Se(Je.share_token||null),Ce&&await f.mutateAsync({contactId:Ce,videoId:Je.id,notes:xe}),r({title:"Video saved successfully!"}),y("share")}catch(Ce){console.error("Save video error:",Ce),r({title:"Failed to save video",description:(Ce==null?void 0:Ce.message)||"Please try again.",variant:"destructive"})}},ve=(Ce,Je)=>{navigator.clipboard.writeText(Je),Ae(Ce),setTimeout(()=>Ae(null),2e3),r({title:"Copied to clipboard!"})},dt=()=>Be?`https://video.relevelup.com/${Be}`:(Q==null?void 0:Q.playbackUrl)||"",pe=()=>{const Ce=u==null?void 0:u.find(We=>We.id===ne),Je=Ce?`${Ce.first_name}`:"",Ge=(Ce==null?void 0:Ce.phone)||"",lt=(Ce==null?void 0:Ce.email)||"",He=dt();return{text:`Hey${Je?` ${Je}`:""}! I recorded a quick video for you: ${He}`,link:He,contactPhone:Ge,contactEmail:lt}},Ue=()=>{const{text:Ce,contactPhone:Je}=pe(),Ge=Je?`sms:${Je}?body=${encodeURIComponent(Ce)}`:`sms:?body=${encodeURIComponent(Ce)}`;window.open(Ge,"_self")},Xe=()=>{const{link:Ce,contactEmail:Je}=pe(),Ge="Check out this video",lt=`I recorded a quick video for you: ${Ce}`,He=Je?`mailto:${Je}?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(lt)}`:`mailto:?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(lt)}`;window.open(He,"_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(G,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Ga,{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(G,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(wn,{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(Pme,{maxDurationSeconds:300,onRecordingComplete:Oe,onRecordingStateChange:P,className:"w-full",teleprompterContent:j&&_&&e.jsx(Blt,{text:_,isVisible:j,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!1})}),!j&&_&&e.jsxs(G,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(Tr,{placeholder:"Type or paste your script here...",value:_,onChange:Ce=>w(Ce.target.value),rows:6}),e.jsxs(xE,{open:S,onOpenChange:M,children:[e.jsx(yNe,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:"w-full",children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(P3,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(gE,{className:"p-4 border-b",children:e.jsx(yE,{children:"Select a Script"})}),e.jsx(SNs,{onSelectScript:Ce=>{w(Ce.text),M(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),_&&e.jsx(G,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),g==="uploading"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(De,{className:"pt-6 text-center",children:[e.jsx(ci,{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(qi,{value:$,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[$.toFixed(0),"%"]})]})}),g==="processing"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(De,{className:"pt-6 text-center space-y-4",children:[e.jsx(ys,{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(qi,{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(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Video Details"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(Le,{value:oe,onChange:Ce=>he(Ce.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Attach to Contact (Optional)"}),e.jsxs(Rs,{value:ne,onValueChange:re,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"No contact - use anywhere"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Uo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Ce=>e.jsx(ft,{value:Ce.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zi,{className:"h-4 w-4"}),Ce.first_name," ",Ce.last_name]})},Ce.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Tr,{value:xe,onChange:Ce=>ue(Ce.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(G,{className:"w-full",onClick:qe,disabled:m.isPending,children:[m.isPending&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),g==="share"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(De,{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(G,{variant:"outline",className:"justify-start",onClick:Ue,children:[e.jsx(Ki,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(G,{variant:"outline",className:"justify-start",onClick:Xe,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(G,{variant:"outline",className:"justify-start",onClick:()=>ve("link",pe().link),children:[e.jsx(Uo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ee==="link"&&e.jsx(ua,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(G,{variant:"outline",className:"justify-start",onClick:()=>ke(!0),children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(G,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(G,{onClick:()=>{y("record"),q(null),J(null),ce(null)},children:"Record Another"})]})]})]}),ge&&Be&&e.jsx($lt,{open:Me,onOpenChange:ke,video:{id:ge,share_token:Be,title:oe||null,contact_id:ne||null,thumbnail_url:(Q==null?void 0:Q.thumbnailUrl)||null},contactName:((et=u==null?void 0:u.find(Ce=>Ce.id===ne))==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(vd,{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(G,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function TNs({open:t,onOpenChange:s}){const{data:r}=nm(),{data:n}=ime(),a=B3(),o=k.useRef(null),[l,i]=k.useState(null),[c,u]=k.useState(""),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState(!1),[j,N]=k.useState(0),[S,M]=k.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-I,q=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;if(!Y.type.startsWith("video/")){me.error("Please select a video file");return}const J=Y.size/(1024*1024);if(J>500){me.error("Video file must be less than 500MB");return}if(J>O){me.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(Y),c||u(Y.name.replace(/\.[^/.]+$/,""))},$=async()=>{if(!l){me.error("Please select a video file");return}w(!0),N(0),M("creating");try{const{data:X,error:Y}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(Y)throw new Error(Y.message);const{videoId:J,libraryId:Q}=X;M("uploading");const{data:ce,error:ne}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:J,isAgentVideo:!0}});if(ne)throw new Error(ne.message);await new Promise((he,xe)=>{const ue=new XMLHttpRequest;ue.upload.addEventListener("progress",ge=>{if(ge.lengthComputable){const _e=Math.round(ge.loaded/ge.total*100);N(_e)}}),ue.addEventListener("load",()=>{ue.status>=200&&ue.status<300?he():xe(new Error(`Upload failed with status ${ue.status}`))}),ue.addEventListener("error",()=>xe(new Error("Upload failed"))),ue.open("PUT",ce.uploadUrl),ue.setRequestHeader("AccessKey",ce.apiKey),ue.send(l)}),M("processing");const re=l.size/(1024*1024),oe=`https://iframe.mediadelivery.net/embed/${Q}/${J}`;await a.mutateAsync({bunny_video_id:J,playback_url:oe,file_size_mb:re,title:c||l.name,notes:m||void 0,contact_id:g||void 0,status:"processing",touch_type:"video_upload"}),me.success("Video uploaded successfully! Processing may take a few minutes."),z()}catch(X){console.error("Upload error:",X),me.error(X instanceof Error?X.message:"Failed to upload video")}finally{w(!1),M("idle")}},z=()=>{_||(i(null),u(""),f(""),y(""),N(0),M("idle"),s(!1))},V=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${j}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(fs,{open:t,onOpenChange:z,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{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(ye,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:X=>{X.stopPropagation(),i(null)},children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var X;return(X=o.current)==null?void 0:X.click()},children:[e.jsx(ci,{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(ye,{htmlFor:"title",children:"Title"}),e.jsx(Le,{id:"title",value:c,onChange:X=>u(X.target.value),placeholder:"Enter video title",disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Associate with Contact (optional)"}),e.jsxs(Rs,{value:g||"__none__",onValueChange:X=>y(X==="__none__"?"":X),disabled:_,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a contact"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(X=>e.jsxs(ft,{value:X.id,children:[X.first_name," ",X.last_name||""]},X.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Tr,{id:"notes",value:m,onChange:X=>f(X.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(ys,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(qi,{value:S==="uploading"?j:S==="processing"?100:10})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:z,disabled:_,children:"Cancel"}),e.jsx(G,{onClick:$,disabled:!l||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function ANs(t){return pt({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 ENs(){const{user:t}=Fs();return pt({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 PNs(){const{user:t}=Fs();return pt({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 INs(){const{user:t}=Fs(),s=Qt();return Tt({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 LNs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function DNs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function ONs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=k.useState([]),[c,u]=k.useState(null),[m,f]=k.useState(!1),[g,y]=k.useState(!1),[_,w]=k.useState(""),[j,N]=k.useState(""),[S,M]=k.useState(""),[I,P]=k.useState(!1),O=INs(),q=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",$=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",z=r.title||"Video Message";k.useEffect(()=>{t&&l.length===0&&V()},[t]),k.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${z}`),M("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),w(""),r.contact_id)){const ne=l.find(re=>re.id===r.contact_id);ne&&(u(ne),w(ne.email||""))}},[t,r.contact_id,l]);const V=async()=>{y(!0);try{const{data:ne,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;i(ne||[])}catch{console.error("Failed to fetch contacts")}finally{y(!1)}},X=ne=>{u(ne),f(!1),w(ne.email||""),M(`Hey ${ne.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${z}`)},Y=()=>{u(null),w(""),M("Hey! I recorded a quick video just for you. Click below to watch it:")},J=ne=>`${ne.first_name} ${ne.last_name||""}`.trim(),Q=ne=>{const re=S.split(/\n\n+/).map(xe=>`

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

`).join(""),oe=ne?DNs(ne):q,he=ne?``:"";return`
${re}

▶ Watch Video

${he}
`},ce=async()=>{if(!_){me.error("Please enter a recipient email");return}if(!q){me.error("Video does not have a share link");return}P(!0);try{let ne;try{const xe=c?J(c):_.split("@")[0];ne=(await O.mutateAsync({video_id:r.id,recipient_email:_,recipient_name:xe,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(xe){console.warn("Failed to create tracking record, sending without tracking:",xe)}const re=Q(ne),{data:oe,error:he}=await H.functions.invoke("gmail-send",{body:{to:_,subject:j,body:re,contactId:(c==null?void 0:c.id)||null}});if(he)throw he;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");me.success("Video email sent!"),s(!1),o==null||o()}catch(ne){console.error("Gmail send error:",ne),me.error("Failed to send: "+(ne instanceof Error?ne.message:"Unknown error"))}finally{P(!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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rr,{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(ye,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Vo,{open:m,onOpenChange:f,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[c?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Zi,{className:"h-4 w-4 text-muted-foreground"}),J(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(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search contacts..."}),e.jsxs(qx,{children:[e.jsx(Ux,{children:g?"Loading...":"No contacts found."}),e.jsx(Vx,{children:l.filter(ne=>ne.email).map(ne=>e.jsxs(_p,{value:`${ne.first_name} ${ne.last_name||""} ${ne.email||""}`,onSelect:()=>X(ne),children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",(c==null?void 0:c.id)===ne.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:J(ne)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne.email})]})]},ne.id))})]})]})})]}),c&&e.jsx(G,{variant:"ghost",size:"icon",onClick:Y,className:"shrink-0",children:e.jsx(Er,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Le,{id:"video-to",value:_,onChange:ne=>w(ne.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(Qo,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Le,{id:"video-subject",value:j,onChange:ne=>N(ne.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Tr,{id:"video-message",value:S,onChange:ne=>M(ne.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(ye,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[$?e.jsx("img",{src:$,alt:z,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(sl,{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(sl,{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(G,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(G,{onClick:ce,disabled:I||!_||!j,className:"gap-2",children:[I?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const RNs=()=>{const{user:t}=Fs();return pt({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 FNs({recipient:t}){return t.watched_at?e.jsxs(Ye,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(sl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(Ye,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(kh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(Ye,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:[e.jsx(Fn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function zNs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=ANs(r);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(co,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(ws,{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(Li,{className:"h-[400px]",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Recipient"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Sent"}),e.jsx(jt,{children:"Last Activity"})]})}),e.jsx(qn,{children:a.map(l=>e.jsxs(ks,{children:[e.jsx(ut,{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(ut,{children:e.jsx(FNs,{recipient:l})}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:ds(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:l.last_activity_at?ql(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function BNs(){const{data:t,isLoading:s}=ENs(),{data:r=[],isLoading:n}=PNs(),[a,o]=k.useState(null),l=s||n,i=r.reduce((c,u)=>{const m=u.agent_videos,f=(m==null?void 0:m.id)||u.video_id;return c[f]||(c[f]={videoId:f,title:(m==null?void 0:m.title)||"Untitled",thumbnailUrl:m==null?void 0:m.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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(ws,{className:"h-4 w-20"})}),e.jsx(De,{children:e.jsx(ws,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Fn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(De,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(Tn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(kh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(De,{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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(vr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(De,{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,m=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(Fn,{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(Tn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(kh,{className:"h-3 w-3"})," ",m]})]})]}),e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(zNs,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function $Ns({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 qNs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:c,onEmbedToCrm:u,onShareWithTemplate:m,onSendViaGmail:f,isGmailConnected:g,getContactName:y,getShareUrl:_,copyToClipboard:w,formatDuration:j}){const[N,S]=k.useState(!1);return e.jsxs(Pe,{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($Ns,{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(sl,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:j(t.duration_seconds)}),t.status!=="ready"&&e.jsx(Ye,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(De,{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(Zi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:y(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(mn,{className:"h-3 w-3"}),e.jsx("span",{children:ds(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(Tn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),g&&t.share_token&&e.jsxs(G,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(rr,{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(Zi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:y(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(mn,{className:"h-3 w-3"}),e.jsx("span",{children:ds(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(Tn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M=>M.stopPropagation(),children:e.jsx(vx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",className:"bg-popover",children:[e.jsxs(La,{onClick:M=>{M.stopPropagation(),n()},children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(yw,{}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),m()},children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),w(_(t),"Share link")},children:[e.jsx(Uo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),i()},children:[e.jsx(nS,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),c()},children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),u()},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),g&&t.share_token&&e.jsxs(La,{onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),o()},children:[e.jsx(Pa,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(yw,{}),t.contact_id&&e.jsxs(La,{onClick:M=>{M.stopPropagation(),l()},children:[e.jsx(Zi,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(La,{onClick:M=>{M.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function UNs(){var it,It;const t=ar(),{data:s,isLoading:r,refetch:n}=rws(),{data:a}=ime(),{data:o}=nm(),l=iws(),i=aws(),{isGmailConnected:c,gmailEmail:u}=Ff(),{data:m}=Gx(),{data:f=[],isLoading:g}=RNs(),[y,_]=k.useState("my"),[w,j]=k.useState(""),[N,S]=k.useState(null),[M,I]=k.useState(!1),[P,O]=k.useState(!1),[q,$]=k.useState(!1),[z,V]=k.useState(!1),[X,Y]=k.useState(!1),[J,Q]=k.useState(""),[ce,ne]=k.useState(!1),[re,oe]=k.useState(!1),[he,xe]=k.useState(!1),[ue,ge]=k.useState(!1),[_e,Be]=k.useState(""),[Se,Ee]=k.useState({}),Ae=Vt=>{if(!Vt)return"Unassigned";const hs=o==null?void 0:o.find(Es=>Es.id===Vt);return hs?`${hs.first_name} ${hs.last_name||""}`.trim():"Unknown"},Me=Vt=>{if(!Vt)return"0:00";const hs=Math.floor(Vt/60),Es=Vt%60;return`${hs}:${Es.toString().padStart(2,"0")}`},ke=s==null?void 0:s.filter(Vt=>{if(!w)return!0;const hs=Ae(Vt.contact_id).toLowerCase(),Es=(Vt.title||"").toLowerCase(),Ts=(Vt.notes||"").toLowerCase();return hs.includes(w.toLowerCase())||Es.includes(w.toLowerCase())||Ts.includes(w.toLowerCase())}),[Oe,qe]=k.useState(!1);k.useEffect(()=>{if(Oe)return;(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Ts=>Ts.status==="processing"&&Ts.bunny_video_id);if(!hs.length)return;let Es=!1;for(const Ts of hs)try{const{data:cr,error:zr}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:Ts.bunny_video_id,isAgentVideo:!0}});if(zr||!cr)continue;cr.status===4&&(await H.from("agent_videos").update({status:"ready",playback_url:cr.directPlayUrl,thumbnail_url:cr.thumbnailUrl,preview_url:cr.previewUrl,duration_seconds:cr.length||Ts.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Ts.id),Es=!0)}catch(cr){console.warn("Reconcile check failed for video",Ts.id,cr)}qe(!0),Es&&n()})()},[s,Oe,n]),k.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Ft=>(Ft==null?void 0:Ft.bunny_video_id)&&!Se[Ft.id]);if(!hs.length)return;const Es=hs.map(Ft=>Ft.bunny_video_id),{data:Ts,error:cr}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Es,isAgentVideo:!0}});if(cr)throw cr;const zr=(Ts==null?void 0:Ts.assets)||{};Ee(Ft=>{const Ps={...Ft};for(const yr of hs)zr[yr.bunny_video_id]&&(Ps[yr.id]={previewUrl:zr[yr.bunny_video_id].previewUrl,thumbnailUrl:zr[yr.bunny_video_id].thumbnailUrl});return Ps})})().catch(hs=>console.warn("Failed to load signed Bunny asset URLs",hs))},[s,Se]);const ve=(a==null?void 0:a.total_storage_mb)||0,dt=(a==null?void 0:a.max_storage_mb)||1024,pe=ve/dt*100,Ue=pe>=80,Xe=pe>=100,et=async(Vt,hs)=>{await navigator.clipboard.writeText(Vt),me.success(`${hs} copied to clipboard`)},Ce=Vt=>Vt.share_token?`https://video.relevelup.com/${Vt.share_token}`:Vt.playback_url||"",Je=Vt=>{const hs=Ce(Vt),Es=o==null?void 0:o.find(yr=>yr.id===Vt.contact_id),Ts=Ae(Vt.contact_id),cr=Ts!=="Unassigned"?Ts.split(" ")[0]:"",zr=(Es==null?void 0:Es.phone)||"",Ft=`Hey${cr?` ${cr}`:""}! I recorded a quick video message for you. Check it out: ${hs}`,Ps=zr?`sms:${zr}?body=${encodeURIComponent(Ft)}`:`sms:?body=${encodeURIComponent(Ft)}`;window.open(Ps,"_self")},Ge=Vt=>{const hs=o==null?void 0:o.find(Ps=>Ps.id===Vt.contact_id),Es=(hs==null?void 0:hs.email)||"",Ts=Ce(Vt),cr="Check out this video",zr=`I recorded a quick video for you: ${Ts}`,Ft=Es?`mailto:${Es}?subject=${encodeURIComponent(cr)}&body=${encodeURIComponent(zr)}`:`mailto:?subject=${encodeURIComponent(cr)}&body=${encodeURIComponent(zr)}`;window.open(Ft,"_self")},lt=Vt=>{var cr;const hs=Ce(Vt),Es=Vt.title||"Video Message",Ts=Vt.share_token?`https://video.relevelup.com/thumb/${Vt.share_token}`:((cr=Se[Vt.id])==null?void 0:cr.thumbnailUrl)||Vt.thumbnail_url||"";return``},He=async Vt=>{if(!Vt.thumbnail_url&&!Vt.share_token){me.error("Video thumbnail not available yet");return}const hs=lt(Vt),Es=Ce(Vt),Ts=`Watch: ${Vt.title||"Video Message"} ${Es}`;try{const cr=new Blob([hs],{type:"text/html"}),zr=new Blob([Ts],{type:"text/plain"}),Ft=new ClipboardItem({"text/html":cr,"text/plain":zr});await navigator.clipboard.write([Ft]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Ts+` `+hs),me.success("Copied! Paste into your email.")}},We=async Vt=>{try{me.loading("Preparing download...",{id:"download"});const{data:hs,error:Es}=await H.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Vt.bunny_video_id,isAgentVideo:!0}});if(Es||!(hs!=null&&hs.downloadUrl))throw new Error((Es==null?void 0:Es.message)||"Failed to get download URL");const cr=`${((Vt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,zr=await fetch(hs.downloadUrl);if(!zr.ok)throw new Error("Failed to fetch video file");const Ft=await zr.blob(),Ps=URL.createObjectURL(Ft),yr=document.createElement("a");yr.href=Ps,yr.download=cr,yr.rel="noreferrer",document.body.appendChild(yr),yr.click(),yr.remove(),URL.revokeObjectURL(Ps),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"})}},tt=async Vt=>{S(Vt),ne(!0),Q(""),Y(!0);try{const{data:hs,error:Es}=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(Es||!(hs!=null&&hs.html))throw new Error("Failed to generate CRM embed code");Q(hs.html)}catch(hs){console.error("CRM embed error:",hs),me.error("Failed to generate CRM embed code"),Y(!1)}finally{ne(!1)}},Ke=Vt=>{S(Vt),I(!0)},rt=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 ${y==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),m&&((it=m.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 ${y==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ur,{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 ${y==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(co,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),y==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{variant:"outline",onClick:()=>$(!0),children:[e.jsx(ci,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(G,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),y==="team"?e.jsx(VNs,{videos:f,isLoading:g,searchTerm:w,setSearchTerm:j}):y==="analytics"?e.jsx(BNs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:Ue?"border-amber-500":Xe?"border-destructive":"",children:e.jsxs(De,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(CL,{className:`h-5 w-5 ${Xe?"text-destructive":Ue?"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:[ve.toFixed(1)," MB / ",dt>=1024?`${(dt/1024).toFixed(0)} GB`:`${dt} MB`]})]}),e.jsx(qi,{value:Math.min(pe,100),className:`h-2 ${Xe?"[&>div]:bg-destructive":Ue?"[&>div]:bg-amber-500":""}`})]}),Ue&&!Xe&&e.jsxs(Ye,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),Xe&&e.jsxs(Ye,{variant:"destructive",children:[e.jsx(ul,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),Xe&&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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:Vt=>j(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"})}):(ke==null?void 0:ke.length)===0?e.jsx(Pe,{children:e.jsxs(De,{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(G,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(qs,{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:ke==null?void 0:ke.map(Vt=>{var hs,Es;return e.jsx(qNs,{video:Vt,previewSrc:(hs=Se[Vt.id])==null?void 0:hs.previewUrl,thumbnailSrc:(Es=Se[Vt.id])==null?void 0:Es.thumbnailUrl,onOpen:()=>Ke(Vt),onDelete:()=>{S(Vt),O(!0)},onRename:()=>{S(Vt),Be(Vt.title||""),ge(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Vt.contact_id}`),onGetEmbedCode:()=>{S(Vt),V(!0)},onCopyEmailHtml:()=>He(Vt),onEmbedToCrm:()=>tt(Vt),onShareWithTemplate:()=>{S(Vt),oe(!0)},onSendViaGmail:()=>{S(Vt),xe(!0)},isGmailConnected:c,getContactName:Ae,getShareUrl:Ce,copyToClipboard:et,formatDuration:Me},Vt.id)})}),e.jsx(fs,{open:M,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(js,{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(Zi,{className:"h-3 w-3"}),Ae(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(ys,{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(G,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(zo,{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(G,{variant:"outline",onClick:()=>Je(N),children:[e.jsx(Ki,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(G,{variant:"outline",onClick:()=>Ge(N),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(G,{variant:"outline",onClick:()=>et(Ce(N),"Share link"),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(G,{variant:"outline",onClick:()=>He(N),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(G,{variant:"outline",onClick:()=>We(N),children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(G,{variant:"outline",onClick:()=>{I(!1),tt(N)},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(G,{variant:"outline",onClick:()=>{I(!1),oe(!0)},children:[e.jsx($l,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(N==null?void 0:N.share_token)&&e.jsxs(G,{variant:"outline",onClick:()=>{I(!1),xe(!0)},children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(G,{variant:"destructive",onClick:()=>{I(!1),O(!0)},children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:P,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsxs(js,{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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(G,{variant:"destructive",onClick:rt,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(TNs,{open:q,onOpenChange:$}),e.jsx(fs,{open:z,onOpenChange:V,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(js,{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(ye,{children:"Embed Code"}),e.jsx(Tr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(G,{className:"flex-1",onClick:()=>{const Vt=``;et(Vt,"Embed code")},children:[e.jsx(yi,{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($lt,{open:re,onOpenChange:oe,video:N,contactName:Ae(N.contact_id)}),N&&e.jsx(ONs,{open:he,onOpenChange:xe,video:N,gmailEmail:u,signedThumbnailUrl:(It=Se[N.id])==null?void 0:It.thumbnailUrl}),e.jsx(fs,{open:ue,onOpenChange:ge,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Rename Video"}),e.jsx(Gr,{children:"Enter a new title for this video."})]}),e.jsx(Le,{value:_e,onChange:Vt=>Be(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"),ge(!1)}})}}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>ge(!1),children:"Cancel"}),e.jsx(G,{disabled:!_e.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:_e.trim()},{onSuccess:()=>{me.success("Video renamed"),ge(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:X,onOpenChange:Y,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(rn,{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."})]}),ce?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ys,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):J?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"CRM Email HTML"}),e.jsx(Tr,{readOnly:!0,rows:12,value:J,className:"font-mono text-xs"})]}),e.jsxs(G,{className:"w-full",onClick:()=>{et(J,"CRM embed code")},children:[e.jsx(yi,{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 VNs({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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(Pe,{children:e.jsxs(De,{className:"py-12 text-center",children:[e.jsx(ur,{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(Cn,{className:"h-7 w-7",children:[e.jsx(Wa,{src:c.avatar||""}),e.jsx(Mn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(Ye,{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(Pe,{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:m=>{m.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(De,{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(Zi,{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(Tn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),ds(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const HNs=()=>{const{user:t}=Fs();return pt({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})},Lze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function GNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=HNs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=k.useMemo(()=>{if(!r)return new Map;const _=new Map;let w=0;return r.forEach(j=>{_.has(j.owner_user_id)||(_.set(j.owner_user_id,{name:j.owner_name||"Unknown",avatar:j.owner_avatar_url,color:Lze[w%Lze.length]}),w++)}),_},[r]),u=k.useMemo(()=>Array.from(c.entries()).map(([_,w])=>({id:_,...w})),[c]),m=k.useMemo(()=>{if(!r)return[];let _=r;if(l!=="all"&&(_=_.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();_=_.filter(j=>{var N,S,M,I;return j.deal_name.toLowerCase().includes(w)||((N=j.contact_name)==null?void 0:N.toLowerCase().includes(w))||((S=j.property_address)==null?void 0:S.toLowerCase().includes(w))||((M=j.city)==null?void 0:M.toLowerCase().includes(w))||((I=j.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return _},[r,a,l]),f=k.useMemo(()=>{const _=new Map;return m.forEach(w=>{const j=w.stage_name||"Unknown";_.has(j)||_.set(j,{name:j,color:w.stage_color,icon:w.stage_icon,deals:[],totalValue:0});const N=_.get(j);N.deals.push(w),N.totalValue+=w.sale_price||0}),Array.from(_.values())},[m]),g=_=>_>=1e6?`$${(_/1e6).toFixed(1)}M`:_>=1e3?`$${(_/1e3).toFixed(0)}K`:`$${_.toFixed(0)}`,y=_=>_?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(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ur,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search deals...",value:a,onChange:_=>o(_.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:l,onValueChange:i,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"All Members"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Members"}),u.map(_=>e.jsx(ft,{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(ws,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(ws,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(ws,{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(ur,{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 w=_.icon&&E2e[_.icon]||jd;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(w,{className:"h-3.5 w-3.5",style:{color:_.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:_.name})]}),e.jsx(Ye,{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(Li,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:_.deals.map(j=>{const N=c.get(j.owner_user_id);return e.jsx(WNs,{deal:j,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:y},j.id)})})})]},_.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[m.length," deal",m.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function WNs({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(Cn,{className:"h-4 w-4",children:[e.jsx(Wa,{src:n||""}),e.jsx(Mn,{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(Ye,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(xn,{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(ml,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function KNs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Pt("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(ur,{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(tl,{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(Li,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:Pt("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Cn,{className:"h-7 w-7",children:[e.jsx(Wa,{src:l.avatar_url||""}),e.jsx(Mn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:Pt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(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(Cn,{className:Pt("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(Wa,{src:l.avatar_url||""}),e.jsx(Mn,{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 Dze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function ZNs(){const t=Fa(),{data:s}=Gx(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=pt({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(m=>m.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((m,f)=>({id:m.id,name:m.name||"Unknown",avatar_url:m.avatar_url,color:Dze[f%Dze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function YNs(t){return pt({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 QNs(){const t=Fa();return pt({queryKey:["all-deal-tags-map",t],queryFn:async()=>{if(!t)return{tags:[],byDeal:{},unique:[]};const{data:s,error:r}=await H.from("deal_tags").select("id, deal_id, tag").eq("owner_user_id",t);if(r)throw r;const n=s||[],a={},o=new Set;n.forEach(i=>{a[i.deal_id]||(a[i.deal_id]=[]),a[i.deal_id].push(i.tag),o.add(i.tag)});const l=Array.from(o).sort((i,c)=>i.localeCompare(c));return{tags:n,byDeal:a,unique:l}},enabled:!!t})}function qlt({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(du,{open:a,onOpenChange:o,children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{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(Ud,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&E2e[c.icon]||jd,m=c.id===s;return e.jsxs(La,{onClick:()=>i(c),className:Pt("flex items-center gap-2 cursor-pointer",m&&"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}),m&&e.jsx(ua,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const XNs={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"}},JNs={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 Ult({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,M;const c=UE(),u=XNs[t.deal_type],m=JNs[t.priority],f=k.useMemo(()=>t.target_close_date?dy(Fl(t.target_close_date),new Date):null,[t.target_close_date]),g=f!==null&&f<0,y=f!==null&&f<=7&&f>=0,_=k.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!I)return null;const P=t.contract_date?Fl(t.contract_date):new Date;return dy(P,Fl(I))},[t]),w=l&&!t.scorecard_transaction_id,j=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Pe,{className:Pt("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",g&&"border-red-200 bg-red-50/30",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(De,{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(Cn,{className:"h-4 w-4",children:[e.jsx(Wa,{src:i.avatar_url||""}),e.jsx(Mn,{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(Ye,{variant:"outline",className:Pt("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Cn,{className:"h-5 w-5",children:e.jsxs(Mn,{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(pl,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(_o,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),j&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(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($M,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Pt("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(xn,{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(ml,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:N(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",N(t.expected_commission)," GCI"]}),(()=>{const I=Nx(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(I)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:Pt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",m.color),children:[e.jsx("div",{className:Pt("w-1.5 h-1.5 rounded-full",m.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(qlt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,P)=>a(t.id,I,P)}):t.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-[10px]",g&&"text-red-600",y&&!g&&"text-amber-600",!g&&!y&&"text-muted-foreground"),children:[g?e.jsx(ul,{className:"h-3 w-3"}):e.jsx(fn,{className:"h-3 w-3"}),e.jsx("span",{children:g?`${Math.abs(f)}d overdue`:y?`${f}d left`:ds(Fl(t.target_close_date),"MMM d")})]}):null]})]})})}function eks({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const m=k.useRef(null),f=s.reduce((j,N)=>j+(N.expected_price||0),0),g=s.reduce((j,N)=>j+(N.expected_commission||0),0),y=s.reduce((j,N)=>j+(Nx(N)||0),0),_=j=>j>=1e6?`$${(j/1e6).toFixed(1)}M`:j>=1e3?`$${(j/1e3).toFixed(0)}K`:`$${j.toFixed(0)}`,w=t.icon&&E2e[t.icon]||jd;return e.jsxs("div",{ref:m,className:Pt("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:j=>o(j,t.id),onDrop:j=>l(j,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(w,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(Ye,{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"]}),y>0&&y!==g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[_(y)," Net"]})]})]})]}),e.jsx(Li,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(j=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(j.id,t.id)},children:e.jsx(Ult,{deal:j,onClick:()=>r(j),isWonStage:c,ownerInfo:(u==null?void 0:u(j))||null})},j.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function tks({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:Xh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:VL,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:t8,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:gL,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:Bo,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(Pe,{className:"animate-pulse",children:e.jsx(De,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(W1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Pe,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Pt("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value}),"subtitle"in a&&a.subtitle&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.subtitle})]})]})})},a.label);return"tooltip"in a&&a.tooltip?e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:o}),e.jsx(sc,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function sks({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Fs(),[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(nn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(bf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(_f,{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(nn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(Ye,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Ji,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(wf,{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(ye,{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(ye,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(INe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(ile,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(zd,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:Pt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(ile,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Nd,{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(Mo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(ye,{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(Mo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(ye,{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(ye,{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(ye,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(Le,{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(ye,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Le,{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(ye,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Le,{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(ye,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Rs,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"email",children:"Email"}),e.jsxs(ft,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const rks=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],nks=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function aks({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=ome(),{data:o}=nm(),{data:l}=qQe(),i=Oue(),c=Dit(),u=Oit(),m=kSe(),[f,g]=k.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[y,_]=k.useState(""),[w,j]=k.useState(!1),[N,S]=k.useState(!1),[M,I]=k.useState({first_name:"",last_name:"",email:"",phone:""}),P=(l==null?void 0:l.filter(J=>((r==null?void 0:r.listing_id)===J.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 J,Q,ce,ne,re,oe,he,xe;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:((J=r.expected_price)==null?void 0:J.toString())||"",commission_percentage:((Q=r.commission_percentage)==null?void 0:Q.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((ne=r.team_split_pct)==null?void 0:ne.toString())||"",referral_fee_pct:((re=r.referral_fee_pct)==null?void 0:re.toString())||"",franchise_fee_pct:((oe=r.franchise_fee_pct)==null?void 0:oe.toString())||"",transaction_fee:((he=r.transaction_fee)==null?void 0:he.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Fl(r.target_close_date):void 0,contract_date:r.contract_date?Fl(r.contract_date):void 0,listing_date:r.listing_date?Fl(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||((xe=a==null?void 0:a[0])==null?void 0:xe.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 $=o==null?void 0:o.filter(J=>{var ce,ne,re;const Q=y.toLowerCase();return((ce=J.first_name)==null?void 0:ce.toLowerCase().includes(Q))||((ne=J.last_name)==null?void 0:ne.toLowerCase().includes(Q))||((re=J.email)==null?void 0:re.toLowerCase().includes(Q))}).slice(0,5),z=()=>{const J=parseFloat(O.expected_price)||0,Q=parseFloat(O.commission_percentage)||0;return J*(Q/100)},V=()=>{const J=z();if(!J)return null;const Q=parseFloat(O.brokerage_split_pct)||0,ce=parseFloat(O.team_split_pct)||0,ne=parseFloat(O.referral_fee_pct)||0,re=parseFloat(O.franchise_fee_pct)||0,oe=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let xe=J;ne&&(xe-=J*ne/100);let ue=xe;return Q&&(ue-=xe*Q/100),ce&&(ue-=J*ce/100),re&&(ue-=J*re/100),oe&&(ue-=oe),Math.max(0,ue)}let he=J;return Q&&(he=he*((100-Q)/100)),ce&&(he=he*((100-ce)/100)),ne&&(he=he-J*ne/100),re&&(he=he-J*re/100),oe&&(he=he-oe),Math.max(0,he)},X=async J=>{var Q,ce,ne;if(J.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const re={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:z()||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:((Q=O.target_close_date)==null?void 0:Q.toISOString().split("T")[0])||null,contract_date:((ce=O.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ne=O.listing_date)==null?void 0:ne.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,...re}),me.success("Deal updated successfully");else{const oe=await c.mutateAsync(re);if(me.success("Deal created successfully"),f.portal_enabled&&(oe!=null&&oe.id))try{await m.mutateAsync({deal_id:oe.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")}},Y=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(js,{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:X,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(ye,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Le,{id:"deal_name",value:O.deal_name,onChange:J=>q(Q=>({...Q,deal_name:J.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Deal Type"}),e.jsxs(Rs,{value:O.deal_type,onValueChange:J=>q(Q=>({...Q,deal_type:J})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:rks.map(J=>e.jsx(ft,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Stage"}),e.jsxs(Rs,{value:O.stage_id||"none",onValueChange:J=>q(Q=>({...Q,stage_id:J==="none"?"":J})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select stage"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No Stage"}),a==null?void 0:a.map(J=>e.jsx(ft,{value:J.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:J.color}}),J.name]})},J.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:y,onChange:J=>{_(J.target.value),j(!0),S(!1),J.target.value||q(Q=>({...Q,contact_id:""}))},onFocus:()=>j(!0),placeholder:"Search contacts...",className:"pl-9"}),w&&y&&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:[$&&$.length>0?$.map(J=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{q(Q=>({...Q,contact_id:J.id})),_(`${J.first_name} ${J.last_name}`),j(!1)},children:[e.jsx(Zi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[J.first_name," ",J.last_name]}),J.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:J.email})]},J.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 J=y.trim().split(/\s+/);I({first_name:J[0]||"",last_name:J.slice(1).join(" ")||"",email:"",phone:""}),S(!0),j(!1)},children:[e.jsx(El,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',y.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(El,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(G,{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(Le,{placeholder:"First name *",value:M.first_name,onChange:J=>I(Q=>({...Q,first_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Last name",value:M.last_name,onChange:J=>I(Q=>({...Q,last_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Email",type:"email",value:M.email,onChange:J=>I(Q=>({...Q,email:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Phone",type:"tel",value:M.phone,onChange:J=>I(Q=>({...Q,phone:J.target.value})),className:"h-8 text-sm"})]}),e.jsx(G,{type:"button",size:"sm",className:"w-full h-8",disabled:!M.first_name.trim()||i.isPending,onClick:async()=>{try{const J=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});J&&(q(Q=>({...Q,contact_id:J.id})),_(`${J.first_name} ${J.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(El,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),P.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(pl,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(Rs,{value:O.listing_id||"none",onValueChange:J=>{const Q=J==="none"?"":J,ce=P.find(ne=>ne.id===Q);q(ce?ne=>{var re;return{...ne,listing_id:Q,deal_type:"seller",property_address:ce.property_address||ne.property_address,city:ce.city||ne.city,state:ce.state||ne.state,expected_price:((re=ce.price)==null?void 0:re.toString())||ne.expected_price}}:ne=>({...ne,listing_id:Q}))},children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"None"}),P.map(J=>e.jsx(ft,{value:J.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:J.property_address||`${J.city}, ${J.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(J.price/1e3).toFixed(0),"K"]})]})},J.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(ye,{htmlFor:"property_address",children:"Address"}),e.jsx(Le,{id:"property_address",value:O.property_address,onChange:J=>q(Q=>({...Q,property_address:J.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"city",children:"City"}),e.jsx(Le,{id:"city",value:O.city,onChange:J=>q(Q=>({...Q,city:J.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(Le,{id:"state",value:O.state,onChange:J=>q(Q=>({...Q,state:J.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Le,{id:"zip_code",value:O.zip_code,onChange:J=>q(Q=>({...Q,zip_code:J.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(ye,{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(Le,{id:"expected_price",type:"number",value:O.expected_price,onChange:J=>q(Q=>({...Q,expected_price:J.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:J=>q(Q=>({...Q,commission_percentage:J.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(ye,{children:"Expected GCI"}),e.jsx(Le,{value:z()?`$${z().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(ye,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Rs,{value:O.commission_calc_method,onValueChange:J=>q(Q=>({...Q,commission_calc_method:J})),children:[e.jsx(Ls,{className:"h-7 text-xs",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(ft,{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(ye,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:J=>q(Q=>({...Q,brokerage_split_pct:J.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(ye,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:J=>q(Q=>({...Q,team_split_pct:J.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(ye,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:J=>q(Q=>({...Q,referral_fee_pct:J.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(ye,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:J=>q(Q=>({...Q,franchise_fee_pct:J.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(ye,{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(Le,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:J=>q(Q=>({...Q,transaction_fee:J.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(ye,{className:"text-xs",children:"Net to Agent"}),e.jsx(Le,{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(ye,{children:"Target Close Date"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),O.target_close_date?ds(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:O.target_close_date,onSelect:J=>q(Q=>({...Q,target_close_date:J})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Contract Date"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),O.contract_date?ds(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:O.contract_date,onSelect:J=>q(Q=>({...Q,contract_date:J})),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(ye,{children:"Listing Date (for Days on Market)"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),O.listing_date?ds(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:O.listing_date,onSelect:J=>q(Q=>({...Q,listing_date:J})),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(ye,{children:"Priority"}),e.jsxs(Rs,{value:O.priority,onValueChange:J=>q(Q=>({...Q,priority:J})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:nks.map(J=>e.jsx(ft,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{type:"number",min:"0",max:"100",value:O.probability,onChange:J=>q(Q=>({...Q,probability:J.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(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:O.notes,onChange:J=>q(Q=>({...Q,notes:J.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(sks,{formData:f,onChange:g}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{type:"submit",disabled:Y,children:[Y&&e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function iks({dealId:t}){const s=Fa(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState(!1),{data:i=[]}=pt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:_,error:w}=await H.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(w)throw w;return _},enabled:!!t}),{data:c=[]}=pt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:_,error:w}=await H.from("deal_tags").select("tag").eq("owner_user_id",s);if(w)throw w;return[...new Set(_.map(N=>N.tag))].sort()},enabled:!!s}),u=Tt({mutationFn:async _=>{if(!s)throw new Error("Not authenticated");const{error:w}=await H.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:_.trim()});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),m=Tt({mutationFn:async _=>{const{error:w}=await H.from("deal_tags").delete().eq("id",_);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const _=n.trim();_&&(i.some(w=>w.tag.toLowerCase()===_.toLowerCase())||u.mutate(_))},g=i.map(_=>_.tag.toLowerCase()),y=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(Ye,{variant:"secondary",className:"gap-1 text-xs",children:[_.tag,e.jsx("button",{type:"button",onClick:()=>m.mutate(_.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Er,{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(qs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(Le,{value:n,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),f()),_.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag name...",className:"h-8 text-xs flex-1",autoFocus:!0}),e.jsx("button",{type:"button",onClick:f,disabled:!n.trim()||u.isPending,className:"h-8 px-3 rounded-md bg-primary text-primary-foreground text-xs font-medium disabled:opacity-50 shrink-0",children:"Add"}),e.jsx("button",{type:"button",onClick:()=>{l(!1),a("")},className:"h-8 px-2 rounded-md bg-muted text-muted-foreground text-xs shrink-0",children:"Cancel"})]}),n&&y.length>0&&e.jsx("div",{className:"absolute z-20 w-full mt-1 bg-background border rounded shadow-lg max-h-32 overflow-y-auto",children:y.map(_=>e.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs hover:bg-muted active:bg-muted",onClick:w=>{w.preventDefault(),u.mutate(_)},children:_},_))})]})]})}function oks(t){return pt({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 lks(){const t=Fa(),s=Qt();return Tt({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 cks(){const t=Qt();return Tt({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 dks(){const t=Qt();return Tt({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 uks(t){const{data:s,error:r}=await H.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const Oze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function hks({open:t,onOpenChange:s}){const{data:r,isLoading:n}=mws(),a=pws(),o=fws(),l=xws(),[i,c]=k.useState(!1),[u,m]=k.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,g]=k.useState(""),y=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}),m({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")}},w=async(S,M)=>{try{await o.mutateAsync({id:S,is_required:M})}catch{me.error("Failed to update question")}},j=()=>{f.trim()&&(m(S=>({...S,options:[...S.options,f.trim()]})),g(""))},N=S=>{m(M=>({...M,options:M.options.filter((I,P)=>P!==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(js,{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(Li,{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(ys,{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(Eu,{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(Ye,{variant:"secondary",className:"text-xs",children:Oze[S.field_type]||S.field_type}),S.is_required&&e.jsx(Ye,{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:I=>w(S.id,I),className:"scale-75"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>_(S.id),children:e.jsx(kr,{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(ye,{className:"text-sm font-medium",children:"Question"}),e.jsx(Le,{value:u.question_text,onChange:S=>m(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(ye,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(Oze).map(([S,M])=>e.jsx("button",{type:"button",onClick:()=>m(I=>({...I,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:M},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ye,{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(Er,{className:"h-3.5 w-3.5"})})]},M)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),j()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(G,{variant:"outline",size:"sm",onClick:j,disabled:!f.trim(),className:"h-8",children:e.jsx(qs,{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=>m(M=>({...M,is_required:S}))}),e.jsx(ye,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:()=>c(!1),className:"flex-1",children:"Cancel"}),e.jsxs(G,{size:"sm",onClick:y,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(ys,{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(G,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function mks({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=k.useState(""),[i,c]=k.useState(!1),{data:u,isLoading:m}=pt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:_,error:w}=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(w)throw w;return _},enabled:i||!!n}),f=k.useMemo(()=>!n||!u?null:u.find(_=>_.id===n),[n,u]),g=k.useMemo(()=>!u||!r?[]:u.filter(_=>{var w;return((w=_.client_email)==null?void 0:w.toLowerCase())===r.toLowerCase()&&_.id!==t}),[u,r,t]),y=k.useMemo(()=>{if(!u||!o.trim())return[];const _=o.toLowerCase();return u.filter(w=>{var N,S,M,I;const j=w.deal_pipeline;return((N=w.client_name)==null?void 0:N.toLowerCase().includes(_))||((S=w.client_email)==null?void 0:S.toLowerCase().includes(_))||((M=j==null?void 0:j.deal_name)==null?void 0:M.toLowerCase().includes(_))||((I=j==null?void 0:j.property_address)==null?void 0:I.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(ye,{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(pl,{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(G,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(TS,{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(ye,{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(G,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>c(!i),children:[e.jsx(pl,{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 w=_.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(Ye,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w==null?void 0:w.property_address})]}),e.jsx(pl,{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(sn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:o,onChange:_=>l(_.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),m&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ys,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),y.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:y.map(_=>{const w=_.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(Ye,{variant:"outline",className:"text-[10px] shrink-0",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:_.client_email})]})]},_.id)})}),o&&y.length===0&&!m&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function N3e({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([]),[m,f]=k.useState(!1),[g,y]=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:w})=>{u(w||[]),f(!1)}))},[l,t]);const _=c.filter(w=>!g||(w.title||w.recipient_name||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(_u,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ps,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(js,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value:g,onChange:w=>y(w.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-16 w-full"}),e.jsx(ws,{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(w=>e.jsxs("button",{onClick:()=>{s(w.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:j=>{const N=j.currentTarget.parentElement;if(N){j.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:w.title||w.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.duration_seconds?`${Math.round(w.duration_seconds)}s`:"",w.created_at?` · ${new Date(w.created_at).toLocaleDateString()}`:""]})]})]},w.id))})]})]})}function k3e({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),m=B3(),f=()=>{o("record"),i(0),u(0)},g=_=>{!_&&(a==="uploading"||a==="processing")||(n(_),_||f())},y=k.useCallback(async(_,w)=>{o("uploading");try{const j="Card Video",{videoId:N,libraryId:S}=await ER(j),{uploadUrl:M,apiKey:I}=await PR(N),P=new XMLHttpRequest;P.upload.onprogress=Y=>{Y.lengthComputable&&i(Y.loaded/Y.total*100)},await new Promise((Y,J)=>{P.onload=()=>P.status>=200&&P.status<300?Y():J(new Error("Upload failed")),P.onerror=()=>J(new Error("Upload failed")),P.open("PUT",M),P.setRequestHeader("AccessKey",I),P.send(_)}),o("processing");let O=0;const q=Date.now(),$=9e4,z=`https://iframe.mediadelivery.net/embed/${S}/${N}`;for(;O<4;){if(await new Promise(J=>setTimeout(J,3e3)),Date.now()-q>$){const J=_.size/1048576;await m.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${S}/${N}`,file_size_mb:J,title:j,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(z),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const Y=await FA(N);if(O=Y.status,u(Y.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const V=await FA(N),X=(V.storageSize||_.size)/(1024*1024);await m.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||z,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||w,file_size_mb:X,title:j,status:"ready",touch_type:"video"}),s(z),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(j){console.error("Recording upload error:",j),me.error("Failed to process video. Please try again."),o("record")}},[t,s,m]);return e.jsxs(fs,{open:r,onOpenChange:g,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{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(js,{children:e.jsx(vs,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(Pme,{maxDurationSeconds:300,onRecordingComplete:y,onError:_=>me.error(_)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ys,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(qi,{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(ys,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(qi,{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(wi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const pks=t=>`portal-settings-draft:${t}`;function Vlt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=IR(),[o,l]=k.useState(!1),i=k.useMemo(()=>pks(r.id),[r.id]),[c,u]=k.useState(!1),[m,f]=k.useState(r.next_step_text||""),[g,y]=k.useState(r.next_step_video_url||""),[_,w]=k.useState(r.inspection_date||""),[j,N]=k.useState(r.appraisal_date||""),[S,M]=k.useState(r.welcome_message||""),[I,P]=k.useState(r.review_url||""),[O,q]=k.useState(r.show_post_close_tips),[$,z]=k.useState(r.notify_client),[V,X]=k.useState(r.require_onboarding),[Y,J]=k.useState(r.allow_spouse),[Q,ce]=k.useState(r.visibility),[ne,re]=k.useState(r.stage_mapping||[]),[oe,he]=k.useState(null),[xe,ue]=k.useState(r.linked_portal_id||null),ge=()=>{f(r.next_step_text||""),y(r.next_step_video_url||""),w(r.inspection_date||""),N(r.appraisal_date||""),M(r.welcome_message||""),P(r.review_url||""),q(r.show_post_close_tips),z(r.notify_client),X(r.require_onboarding),J(r.allow_spouse),ce(r.visibility),re(r.stage_mapping||[]),ue(r.linked_portal_id||null)};k.useEffect(()=>{u(!1);const ke=localStorage.getItem(i);if(ke)try{const Oe=JSON.parse(ke);f(Oe.nextStepText||""),y(Oe.nextStepVideo||""),w(Oe.inspectionDate||""),N(Oe.appraisalDate||""),M(Oe.welcomeMessage||""),P(Oe.reviewUrl||""),q(!!Oe.showPostClose),z(!!Oe.notifyClient),X(!!Oe.requireOnboarding),J(!!Oe.allowSpouse),ce(Oe.visibility||r.visibility),re(Oe.stageMapping||[]),ue(Oe.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}ge(),u(!0)},[i,r]),k.useEffect(()=>{if(!c)return;const ke={nextStepText:m,nextStepVideo:g,inspectionDate:_,appraisalDate:j,welcomeMessage:S,reviewUrl:I,showPostClose:O,notifyClient:$,requireOnboarding:V,allowSpouse:Y,visibility:Q,stageMapping:ne,linkedPortalId:xe};m!==(r.next_step_text||"")||g!==(r.next_step_video_url||"")||_!==(r.inspection_date||"")||j!==(r.appraisal_date||"")||S!==(r.welcome_message||"")||I!==(r.review_url||"")||O!==r.show_post_close_tips||$!==r.notify_client||V!==r.require_onboarding||Y!==r.allow_spouse||Q!==r.visibility||JSON.stringify(ne)!==JSON.stringify(r.stage_mapping||[])||xe!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(ke)):localStorage.removeItem(i)},[m,g,_,j,S,I,O,$,V,Y,Q,ne,xe,i,c,r]);const _e=()=>{localStorage.removeItem(i),ge()},Be=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:m||null,next_step_video_url:g||null,inspection_date:_||null,appraisal_date:j||null,welcome_message:S||null,review_url:I||null,show_post_close_tips:O,notify_client:$,require_onboarding:V,allow_spouse:Y,visibility:Q,stage_mapping:ne.length>0?ne:null,linked_portal_id:xe});const ke=r.linked_portal_id;xe&&xe!==ke&&await H.from("client_portals").update({linked_portal_id:r.id}).eq("id",xe),!xe&&ke&&await H.from("client_portals").update({linked_portal_id:null}).eq("id",ke),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Se=()=>{re([...ne,{label:""}])},Ee=ke=>{re(ne.filter((Oe,qe)=>qe!==ke)),oe===ke&&he(null)},Ae=(ke,Oe,qe)=>{const ve=[...ne];ve[ke]={...ve[ke],[Oe]:qe},re(ve)},Me=()=>{const Oe=gNe(null).map(qe=>({label:qe.label,description:qe.description,stageId:void 0}));re(Oe)};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(js,{children:e.jsx(vs,{children:"Portal Settings"})}),e.jsxs(ga,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ss,{value:"general",children:"General"}),e.jsx(ss,{value:"timeline",children:"Timeline"}),e.jsx(ss,{value:"content",children:"Content"})]}),e.jsxs(Li,{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(ye,{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(ke=>e.jsx("button",{onClick:()=>ce(ke),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Q===ke?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:ke.charAt(0).toUpperCase()+ke.slice(1)},ke))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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:X})]}),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(ye,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(G,{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(ye,{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:Y,onCheckedChange:J})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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:$,onCheckedChange:z})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(mks,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:xe,onLink:ue})}),e.jsx("div",{children:e.jsx(Le,{type:"date",value:_,onChange:ke=>w(ke.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Le,{type:"date",value:j,onChange:ke=>N(ke.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(ye,{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(G,{variant:"outline",size:"sm",onClick:Me,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.'}),ne.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(G,{variant:"outline",size:"sm",onClick:Me,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ne.map((ke,Oe)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Eu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Le,{value:ke.label,onChange:qe=>Ae(Oe,"label",qe.target.value),placeholder:`Stage ${Oe+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>he(oe===Oe?null:Oe),children:oe===Oe?"Less":"More"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Ee(Oe),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]}),oe===Oe&&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(ye,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:ke.description||"",onChange:qe=>Ae(Oe,"description",qe.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(ye,{className:"text-xs text-muted-foreground",children:"Video"}),ke.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:ke.video_url.length>40?ke.video_url.slice(0,40)+"...":ke.video_url}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>Ae(Oe,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(k3e,{onVideoReady:qe=>Ae(Oe,"video_url",qe)}),e.jsx(N3e,{userId:n,onSelect:qe=>Ae(Oe,"video_url",qe),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const qe=prompt("Paste a YouTube or Loom URL:");qe&&Ae(Oe,"video_url",qe)},children:[e.jsx(Uo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Oe))}),ne.length>0&&e.jsxs(G,{variant:"outline",size:"sm",onClick:Se,className:"mt-2 text-xs w-full",children:[e.jsx(qs,{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(ye,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:S,onChange:ke=>M(ke.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(ye,{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:m,onChange:ke=>f(ke.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(ye,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Le,{value:g,onChange:ke=>y(ke.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(ye,{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(Le,{value:I,onChange:ke=>P(ke.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(G,{variant:"ghost",onClick:_e,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(G,{onClick:Be,disabled:a.isPending,children:[a.isPending?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(hks,{open:o,onOpenChange:l})]})}const fks=t=>`portal-update-draft:${t}`;function Hlt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=k.useMemo(()=>fks(r),[r]),[l,i]=k.useState(""),[c,u]=k.useState(""),[m,f]=k.useState(""),[g,y]=k.useState(!1),[_,w]=k.useState(a??!1),[j,N]=k.useState(!1),S=jit();k.useEffect(()=>{N(!1);const P=localStorage.getItem(o);if(P)try{const O=JSON.parse(P);i(O.title||""),u(O.content||""),f(O.videoUrl||""),y(!!O.isStageChange),w(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),N(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),y(!1),w(a??!1),N(!0)},[o,a]),k.useEffect(()=>{if(!j)return;const P={title:l,content:c,videoUrl:m,isStageChange:g,sendNotification:_};l.trim()||c.trim()||m.trim()||g||_!==(a??!1)?localStorage.setItem(o,JSON.stringify(P)):localStorage.removeItem(o)},[l,c,m,g,_,j,o,a]);const M=()=>{localStorage.removeItem(o),i(""),u(""),f(""),y(!1),w(a??!1)},I=async()=>{if(l.trim())try{if(await S.mutateAsync({portal_id:r,title:l.trim(),content:c.trim()||void 0,video_url:m.trim()||void 0,is_stage_change:g}),_&&n)try{const P=S1(n);await H.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:c.trim()||null,portal_url:P}}),me.success("Update posted & client notified")}catch(P){console.error("Notification failed:",P),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(js,{children:e.jsx(vs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Le,{value:l,onChange:P=>i(P.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:c,onChange:P=>u(P.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(ye,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Le,{value:m,onChange:P=>f(P.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:()=>y(!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:()=>w(!_),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(Fm,{className:"h-3 w-3"}):e.jsx(c1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(G,{variant:"ghost",onClick:M,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(G,{onClick:I,disabled:!l.trim()||S.isPending,children:[S.isPending?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function Glt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=IR(),{isGmailConnected:o,gmailEmail:l}=Ff(),[i,c]=k.useState(r.client_name||""),[u,m]=k.useState(r.client_email||""),[f,g]=k.useState(!1),[y,_]=k.useState(!1),w=S1(r.slug),j=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,S=`Hi ${j}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,M=()=>{navigator.clipboard.writeText(w),_(!0),setTimeout(()=>_(!1),2e3),me.success("Portal link copied!")},I=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)}},P=()=>{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(js,{children:e.jsx(vs,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Le,{value:i,onChange:O=>c(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Le,{type:"email",value:u,onChange:O=>m(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(G,{variant:"outline",size:"icon",onClick:M,className:"shrink-0",children:y?e.jsx(ua,{className:"h-4 w-4 text-emerald-600"}):e.jsx(yi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(G,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(G,{onClick:P,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(G,{variant:"ghost",onClick:M,className:"w-full text-muted-foreground",children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function xks({deal:t}){const{isAdmin:s,user:r}=Fs(),{data:n,isLoading:a}=cws(t.id),o=kSe(),l=IR(),[i,c]=k.useState(!1),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState(!1),w=`portal-management-ui:${t.id}`;if(k.useEffect(()=>{const O=sessionStorage.getItem(w);if(O)try{const q=JSON.parse(O);m(!!q.settingsOpen),g(!!q.composerOpen),_(!!q.inviteOpen)}catch{sessionStorage.removeItem(w)}},[w]),k.useEffect(()=>{u||f||y?sessionStorage.setItem(w,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:y})):sessionStorage.removeItem(w)},[u,f,y,w]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ys,{className:"h-3 w-3 animate-spin ml-auto"})]})});const j=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=S1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},M=()=>{if(!n)return;const O=S1(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(nn,{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(G,{onClick:j,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(nn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const I=S1(n.slug),P=(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(nn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ye,{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(Ye,{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:I})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(yi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:M,className:"text-xs flex-1 min-w-0",children:[e.jsx(rn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Fn,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(eT,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>m(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(el,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(Vlt,{open:u,onOpenChange:m,portal:n,dealOwnerId:P}),e.jsx(Hlt,{open:f,onOpenChange:g,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(Glt,{open:y,onOpenChange:_,portal:n,dealName:t.deal_name})]})}const gks=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function yks(t){return pt({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 vks(){const t=Qt();return Tt({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 bks(){const t=Qt();return Tt({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 _ks({dealId:t,primaryContactId:s}){const r=ar(),{data:n,isLoading:a}=yks(t),{data:o}=nm(),l=vks(),i=bks(),[c,u]=k.useState(!1),[m,f]=k.useState(""),[g,y]=k.useState("Client"),_=new Set((n==null?void 0:n.map(M=>M.contact_id))||[]);s&&_.add(s);const w=o==null?void 0:o.filter(M=>{var P,O,q;if(_.has(M.id))return!1;if(!m.trim())return!0;const I=m.toLowerCase();return((P=M.first_name)==null?void 0:P.toLowerCase().includes(I))||((O=M.last_name)==null?void 0:O.toLowerCase().includes(I))||((q=M.email)==null?void 0:q.toLowerCase().includes(I))}).slice(0,8),j=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(ur,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(Vo,{open:c,onOpenChange:u,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx($o,{className:"w-80 p-3",align:"start",children:e.jsx(Rze,{search:m,setSearch:f,selectedRole:g,setSelectedRole:y,filteredContacts:w,onAdd:j})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(Vo,{open:c,onOpenChange:u,children:[e.jsx(Ho,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})}),e.jsx($o,{className:"w-80 p-3",align:"end",children:e.jsx(Rze,{search:m,setSearch:f,selectedRole:g,setSelectedRole:y,filteredContacts:w,onAdd:j})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(M=>{var I,P,O,q,$,z,V,X;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(Cn,{className:"h-7 w-7",children:e.jsxs(Mn,{className:"text-[10px] bg-primary/10 text-primary",children:[(P=(I=M.contact)==null?void 0:I.first_name)==null?void 0:P[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:[($=M.contact)==null?void 0:$.first_name," ",(z=M.contact)==null?void 0:z.last_name]})}),e.jsx(Ye,{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(G,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${M.contact.phone}`,children:e.jsx(Nn,{className:"h-3 w-3"})})}),((X=M.contact)==null?void 0:X.email)&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${M.contact.email}`,children:e.jsx(rr,{className:"h-3 w-3"})})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(M.id),children:e.jsx(kr,{className:"h-3 w-3"})})]})]},M.id)})})]})}function Rze({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Rs,{value:r,onValueChange:n,children:[e.jsx(Ls,{className:"h-8 text-sm",children:e.jsx($s,{placeholder:"Role"})}),e.jsx(Ds,{children:gks.map(l=>e.jsx(ft,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Li,{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 wks={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"}},jks={note:Ki,call:Nn,email:rr,meeting:fn,stage_change:rn,task_completed:sa,document:xn,system:mn};function Nks({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Ae,Me;const{data:l,isLoading:i}=m2s((t==null?void 0:t.id)||""),{data:c,isLoading:u}=f2s((t==null?void 0:t.id)||""),m=p2s(),f=g2s(),g=x2s(),y=h2s(),{data:_,isLoading:w}=oks((t==null?void 0:t.id)||""),j=lks(),N=cks(),S=dks(),M=k.useRef(null),[I,P]=k.useState(""),[O,q]=k.useState(""),[$,z]=k.useState(!1),[V,X]=k.useState(!1);if(!t)return null;const Y=wks[t.deal_type],J=(()=>{var qe;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const ke=((qe=t.listing)==null?void 0:qe.created_at)||t.listing_date;if(!ke)return null;const Oe=t.contract_date?Fl(t.contract_date):new Date;return dy(Oe,Fl(ke))})(),Q=ke=>ke?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ke):"-",ce=async()=>{if(I.trim())try{await m.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),P(""),me.success("Note added")}catch{me.error("Failed to add note")}},ne=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")}},re=async(ke,Oe)=>{try{await g.mutateAsync({id:ke,is_completed:Oe,deal_id:t.id})}catch{me.error("Failed to update task")}},oe=async()=>{try{await y.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},he=(c==null?void 0:c.filter(ke=>ke.is_completed).length)||0,xe=(c==null?void 0:c.length)||0,ue=(_==null?void 0:_.length)||0,ge=ke=>ke<1024?`${ke} B`:ke<1024*1024?`${(ke/1024).toFixed(1)} KB`:`${(ke/(1024*1024)).toFixed(1)} MB`,_e=ke=>ke?ke.startsWith("image/")?bl:ke.includes("pdf")?wn:HM:HM,Be=async ke=>{const Oe=ke.target.files;if(!(!Oe||!t)){X(!0);try{for(const qe of Array.from(Oe)){if(qe.size>20*1024*1024){me.error(`${qe.name} exceeds 20MB limit`);continue}await j.mutateAsync({dealId:t.id,file:qe})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{X(!1),M.current&&(M.current.value="")}}},Se=async(ke,Oe)=>{if(t)try{await N.mutateAsync({fileId:ke,storagePath:Oe,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Ee=async(ke,Oe)=>{try{const qe=await uks(ke),ve=document.createElement("a");ve.href=qe,ve.download=Oe,ve.target="_blank",document.body.appendChild(ve),ve.click(),document.body.removeChild(ve)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(xE,{open:s,onOpenChange:r,children:e.jsxs(P3,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(gE,{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(Ye,{variant:"outline",className:Pt("text-xs",Y.color),children:Y.label}),e.jsxs(Ye,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(yE,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(iks,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>z(!0),children:e.jsx(kr,{className:"h-4 w-4"})})]})]})}),e.jsx(Li,{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(Cn,{className:"h-10 w-10",children:e.jsxs(Mn,{className:"bg-primary/10 text-primary",children:[(Ae=t.contact.first_name)==null?void 0:Ae[0],(Me=t.contact.last_name)==null?void 0:Me[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(G,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Nn,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(G,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(rr,{className:"h-4 w-4"})})})]})]}),e.jsx(_ks,{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(xn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:Q(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:Q(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${Q(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:Q(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:Q(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(G,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(_o,{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"})]}),J!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:Pt("text-lg font-bold",J>90?"text-red-600":J>60?"text-amber-600":"text-foreground"),children:[J," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ds(Fl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ml,{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(xks,{deal:t}),e.jsxs(ga,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(fa,{className:"w-full grid grid-cols-3",children:[e.jsxs(ss,{value:"tasks",className:"gap-1",children:[e.jsx(sa,{className:"h-4 w-4"}),"Tasks ",xe>0&&`(${he}/${xe})`]}),e.jsxs(ss,{value:"files",className:"gap-1",children:[e.jsx(bS,{className:"h-4 w-4"}),"Files ",ue>0&&`(${ue})`]}),e.jsxs(ss,{value:"activity",className:"gap-1",children:[e.jsx(mn,{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(Le,{placeholder:"Add a new task...",value:O,onChange:ke=>q(ke.target.value),onKeyDown:ke=>ke.key==="Enter"&&ne()}),e.jsx(G,{onClick:ne,disabled:!O.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(ke=>e.jsxs("div",{className:Pt("flex items-center gap-3 p-3 rounded-lg border transition-colors",ke.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Mo,{checked:ke.is_completed,onCheckedChange:Oe=>re(ke.id,!!Oe)}),e.jsx("span",{className:Pt("flex-1 text-sm",ke.is_completed&&"line-through text-muted-foreground"),children:ke.title}),ke.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ds(new Date(ke.due_date),"MMM d")})]},ke.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:Be,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(G,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var ke;return(ke=M.current)==null?void 0:ke.click()},disabled:V,children:[V?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ci,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[_==null?void 0:_.map(ke=>{const Oe=_e(ke.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(Oe,{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:ke.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ge(ke.file_size)," · ",ds(new Date(ke.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W1,{children:e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${ke.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:ke.id,visible:!ke.visible_on_portal,dealId:t.id}),children:ke.visible_on_portal?e.jsx(Tn,{className:"h-4 w-4"}):e.jsx(Cp,{className:"h-4 w-4"})})}),e.jsx(sc,{side:"top",children:ke.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ee(ke.storage_path,ke.file_name),children:e.jsx(vi,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Se(ke.id,ke.storage_path),children:e.jsx(Er,{className:"h-4 w-4"})})]})]},ke.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(Tr,{placeholder:"Add a note...",value:I,onChange:ke=>P(ke.target.value),rows:2}),e.jsxs(G,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(ke=>{const Oe=jks[ke.activity_type]||mn;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(Oe,{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:ke.title}),ke.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:ke.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ql(new Date(ke.created_at),{addSuffix:!0})})]})]},ke.id)}),(l==null?void 0:l.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),e.jsx(Tc,{open:$,onOpenChange:z,children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Deal?"}),e.jsxs(lc,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function kks({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=Rue(),o=Oit(),{data:l}=_E(),{data:i}=Rf(),[c,u]=k.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ds(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",y=r.expected_price||0,_=r.commission_percentage||3,w=r.expected_commission||y*_/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||ds(new Date,"yyyy-MM-dd"),sale_price:y,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const m=async g=>{if(g.preventDefault(),!!r)try{const y=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:y.id,actual_close_date:c.close_date}),me.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(y){console.error("Error syncing to scorecard:",y),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(js,{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(_o,{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:m,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Le,{id:"property_address",value:c.property_address,onChange:g=>u(y=>({...y,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(ye,{htmlFor:"city",children:"City"}),e.jsx(Le,{id:"city",value:c.city,onChange:g=>u(y=>({...y,city:g.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(Le,{id:"state",value:c.state,onChange:g=>u(y=>({...y,state:g.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zip",children:"Zip"}),e.jsx(Le,{id:"zip",value:c.zip,onChange:g=>u(y=>({...y,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(ye,{children:"Transaction Type *"}),e.jsxs(Rs,{value:c.transaction_type,onValueChange:g=>u(y=>({...y,transaction_type:g})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"buyer",children:"Buyer"}),e.jsx(ft,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Le,{id:"close_date",type:"date",value:c.close_date,onChange:g=>u(y=>({...y,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(ye,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(ml,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Le,{id:"sale_price",type:"number",value:c.sale_price||"",onChange:g=>u(y=>({...y,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(ye,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(_S,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Le,{id:"commission_amount",type:"number",value:c.commission_amount||"",onChange:g=>u(y=>({...y,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(ye,{children:"Lead Source"}),e.jsxs(Rs,{value:c.lead_source_id,onValueChange:g=>u(y=>({...y,lead_source_id:g})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select source"})}),e.jsx(Ds,{children:l==null?void 0:l.map(g=>e.jsx(ft,{value:g.id,children:g.name},g.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Client Type"}),e.jsxs(Rs,{value:c.client_type_id,onValueChange:g=>u(y=>({...y,client_type_id:g})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select type"})}),e.jsx(Ds,{children:i==null?void 0:i.map(g=>e.jsx(ft,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Tr,{id:"notes",value:c.notes,onChange:g=>u(y=>({...y,notes:g.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(Rn,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(G,{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(ba,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const Sks={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"}},Fze={urgent:0,high:1,medium:2,low:3};function Cks({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=k.useState("target_close_date"),[l,i]=k.useState("asc"),c=y=>{a===y?i(_=>_==="asc"?"desc":"asc"):(o(y),i("asc"))},u=k.useMemo(()=>[...t].sort((y,_)=>{var j,N;let w=0;switch(a){case"deal_name":w=y.deal_name.localeCompare(_.deal_name);break;case"stage":{const S=((j=s.find(I=>I.id===y.stage_id))==null?void 0:j.sort_order)||0,M=((N=s.find(I=>I.id===_.stage_id))==null?void 0:N.sort_order)||0;w=S-M;break}case"expected_price":w=(y.expected_price||0)-(_.expected_price||0);break;case"expected_commission":w=(y.expected_commission||0)-(_.expected_commission||0);break;case"target_close_date":{const S=y.target_close_date?Fl(y.target_close_date).getTime():1/0,M=_.target_close_date?Fl(_.target_close_date).getTime():1/0;w=S-M;break}case"priority":w=Fze[y.priority]-Fze[_.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),m=y=>y?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(y):"—",f=y=>y?s.find(_=>_.id===y):null,g=({field:y,children:_})=>e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(y),children:[_,a===y?l==="asc"?e.jsx(Tu,{className:"ml-2 h-4 w-4"}):e.jsx(Yh,{className:"ml-2 h-4 w-4"}):e.jsx(wd,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(jt,{className:"w-[250px]",children:e.jsx(g,{field:"deal_name",children:"Deal Name"})}),e.jsx(jt,{className:"w-[150px]",children:e.jsx(g,{field:"stage",children:"Stage"})}),e.jsx(jt,{className:"w-[100px]",children:"Type"}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(g,{field:"expected_price",children:"Price"})}),e.jsx(jt,{className:"w-[120px]",children:e.jsx(g,{field:"expected_commission",children:"GCI"})}),e.jsx(jt,{className:"w-[130px]",children:e.jsx(g,{field:"target_close_date",children:"Close Date"})}),e.jsx(jt,{className:"w-[100px]",children:e.jsx(g,{field:"priority",children:"Priority"})})]})}),e.jsx(qn,{children:u.map(y=>{f(y.stage_id);const _=Sks[y.deal_type],w=y.target_close_date?dy(Fl(y.target_close_date),new Date):null,j=w!==null&&w<0,N=w!==null&&w<=7&&w>=0;return e.jsxs(ks,{className:Pt("cursor-pointer hover:bg-muted/50 transition-colors",j&&"bg-red-50/50"),onClick:()=>r(y),children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:y.deal_name}),y.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[y.contact.first_name," ",y.contact.last_name]})]})}),e.jsx(ut,{onClick:S=>S.stopPropagation(),children:e.jsx(qlt,{stages:s,currentStageId:y.stage_id||"",onStageSelect:(S,M)=>n(y.id,S,M)})}),e.jsx(ut,{children:e.jsx(Ye,{variant:"outline",className:Pt("text-xs",_.color),children:_.label})}),e.jsx(ut,{children:e.jsx("span",{className:"font-medium",children:m(y.expected_price)})}),e.jsx(ut,{children:e.jsx("span",{className:"text-emerald-600",children:m(y.expected_commission)})}),e.jsx(ut,{children:y.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-sm",j&&"text-red-600",N&&!j&&"text-amber-600"),children:[j&&e.jsx(ul,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ds(Fl(y.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx(Ye,{variant:"outline",className:Pt("text-xs capitalize",y.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",y.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",y.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",y.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:y.priority})})]},y.id)})})]})})}function Mks(){const t=Fa();return pt({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 Tks(t){const s=Fa();return pt({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 Aks(){const t=Fa(),s=Qt();return Tt({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 Eks(){const t=Qt();return Tt({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 Pks(){const t=Qt();return Tt({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 S3e(){const t=Qt();return Tt({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 Iks(){const t=Qt();return Tt({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 Lks(t){const s=Fa();return pt({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 Dks(){const t=Fa(),s=Qt();return Tt({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 Oks(){const t=Qt();return Tt({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 Rks(){const t=Fa(),s=Qt();return Tt({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:m}=await H.from("deal_tasks").insert(c).select();if(m)throw m;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const Fks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function zks({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=Tks(t?r:void 0),m=Iks(),f=Rks(),[g,y]=k.useState(new Set),[_,w]=k.useState(!1),j=(c||[]).filter(I=>I.status!=="done");k.useEffect(()=>{j.length>0&&y(new Set(j.map(I=>I.id)))},[c]);const N=I=>{y(P=>{const O=new Set(P);return O.has(I)?O.delete(I):O.add(I),O})},S=async()=>{w(!0);try{const I=Array.from(g);I.length>0&&await m.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),me.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}},M=async()=>{w(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),me.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsxs(js,{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(Ye,{variant:"outline",className:"text-sm",children:a}),e.jsx(ba,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ye,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ys,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:j.length})," incomplete task",j.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Li,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:j.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Mo,{checked:g.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[Fks[I.priority]," ",I.title]}),I.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:I.stage.color+"20",color:I.stage.color},children:I.stage.name})]},I.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{g.size===j.length?y(new Set):y(new Set(j.map(I=>I.id)))},children:g.size===j.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"sm",onClick:M,disabled:_,children:"Skip"}),e.jsxs(G,{size:"sm",onClick:S,disabled:_,children:[_&&e.jsx(ys,{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(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(G,{onClick:S,disabled:_,children:[_&&e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function Bks(){const t=Fa();return pt({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 $ks({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=kSe(),u=IR(),m=dws(),f=uws(),[g,y]=k.useState(!1),_=!!(n!=null&&n.archived_at),w=async()=>{y(!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{y(!1)}},j=async P=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:P}),me.success(P?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(S1(n.slug)),me.success("Link copied!"))},S=()=>{n&&window.open(S1(n.slug),"_blank")},M=async()=>{if(n)try{await m.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},I=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(Ye,{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(G,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(uL,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(kr,{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(Ye,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,title:"Copy link",children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(rn,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(Fn,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(eT,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(el,{className:"h-3.5 w-3.5"})}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(bx,{className:"h-3.5 w-3.5"})})}),e.jsx(Ud,{align:"end",children:e.jsxs(La,{onClick:M,children:[e.jsx(zM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:j,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(G,{size:"sm",onClick:w,disabled:g,className:"shrink-0 ml-4",children:[g?e.jsx(ys,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(nn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function qks(){const{data:t,isLoading:s}=lme(),{data:r,isLoading:n}=Bks(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=hws(),[u,m]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(null),N=Fa(),S=s||n,M=new Map;r==null||r.forEach(V=>M.set(V.deal_id,V));const P=[...(t||[]).filter(V=>{var ce,ne,re,oe,he;const X=M.get(V.id),Y=a.toLowerCase(),J=!Y||V.deal_name.toLowerCase().includes(Y)||((ne=(ce=V.contact)==null?void 0:ce.first_name)==null?void 0:ne.toLowerCase().includes(Y))||((oe=(re=V.contact)==null?void 0:re.last_name)==null?void 0:oe.toLowerCase().includes(Y))||((he=X==null?void 0:X.client_name)==null?void 0:he.toLowerCase().includes(Y));let Q=!0;return l==="active"?Q=!!(X!=null&&X.is_enabled)&&!(X!=null&&X.archived_at):l==="disabled"?Q=!!X&&!X.is_enabled&&!X.archived_at:l==="archived"?Q=!!(X!=null&&X.archived_at):l==="none"?Q=!X:l==="all"&&(Q=!(X!=null&&X.archived_at)||!X),J&&Q})].sort((V,X)=>{const Y=M.get(V.id),J=M.get(X.id);if(Y!=null&&Y.archived_at&&!(J!=null&&J.archived_at))return 1;if(!(Y!=null&&Y.archived_at)&&(J!=null&&J.archived_at)||Y&&!J)return-1;if(!Y&&J)return 1;if(Y&&J){if(Y.is_enabled&&!J.is_enabled)return-1;if(!Y.is_enabled&&J.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,$=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,z=async()=>{if(w)try{await c.mutateAsync({id:w.id,dealId:w.deal_id}),me.success("Portal permanently deleted"),j(null)}catch{me.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ys,{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(nn,{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",$>0&&` · ${$} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(Er,{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(G,{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(Li,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[P.map(V=>{const X=M.get(V.id)||null,Y=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx($ks,{dealId:V.id,dealName:V.deal_name,contactName:Y,portal:X,onSettingsOpen:m,onComposerOpen:J=>g(J),onInviteOpen:(J,Q)=>_({portal:J,dealName:Q}),onDeleteConfirm:j},V.id)}),P.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(nn,{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(Vlt,{open:!!u,onOpenChange:V=>!V&&m(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}),y&&e.jsx(Glt,{open:!!y,onOpenChange:V=>!V&&_(null),portal:y.portal,dealName:y.dealName}),e.jsx(Tc,{open:!!w,onOpenChange:V=>!V&&j(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Permanently delete this portal?"}),e.jsx(lc,{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(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class Uks 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 TI="deal-pipeline-detail-sheet";function Vks(){var yr;const t=UE(),{data:s,isLoading:r}=ome(),{data:n,isLoading:a,refetch:o}=lme(),{data:l,isLoading:i}=y2s(),c=Lit(),u=u2s(),[m,f]=k.useState("board"),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(null),[S,M]=k.useState(null),[I,P]=k.useState(null),[O,q]=k.useState(null),[$,z]=k.useState(!1),[V,X]=k.useState(null),[Y,J]=k.useState(""),[Q,ce]=k.useState("all"),[ne,re]=k.useState("all"),{data:oe}=QNs(),[he,xe]=k.useState(!1),[ue,ge]=k.useState(!1),[_e,Be]=k.useState(new Set),Se=k.useRef(!1),[Ee,Ae]=k.useState(null),{data:Me}=Gx(),{isTeamLeader:ke,teamMembers:Oe}=ZNs(),qe=k.useMemo(()=>Array.from(_e),[_e]),{data:ve}=YNs(qe),dt=k.useMemo(()=>{const Is=new Map;return Oe.forEach(Ar=>Is.set(Ar.id,{name:Ar.name,avatar_url:Ar.avatar_url,color:Ar.color})),Is},[Oe]),pe=k.useCallback(Is=>Is.owner_user_id&&dt.get(Is.owner_user_id)||null,[dt]),Ue=k.useCallback(Is=>{Be(Ar=>{const tn=new Set(Ar);return tn.has(Is)?tn.delete(Is):tn.add(Is),tn})},[]);k.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[Xe,et]=Ul(),Ce=k.useRef(!1);k.useEffect(()=>{const Is=Xe.get("deal");if(Is&&n&&n.length>0&&!Ce.current){const Ar=n.find(tn=>tn.id===Is);Ar&&(Ce.current=!0,N(Ar),w(!0),Xe.delete("deal"),et(Xe,{replace:!0}))}},[n,Xe]);const Je=k.useMemo(()=>{if(!ve||!s)return[];const Is=new Map(s.map(Ar=>[Ar.name,Ar.id]));return ve.map(Ar=>{const tn=Ar._stage_name&&Is.get(Ar._stage_name)||null;return{...Ar,stage_id:tn||Ar.stage_id}})},[ve,s]),Ge=k.useMemo(()=>[...n||[],...Je],[n,Je]);k.useEffect(()=>{if(Se.current||Ge.length===0)return;Se.current=!0;const Is=sessionStorage.getItem(TI);if(Is)try{const Ar=JSON.parse(Is);if(!Ar.open||!Ar.dealId)return;const tn=Ge.find(na=>na.id===Ar.dealId);tn&&(N(tn),w(!0))}catch{sessionStorage.removeItem(TI)}},[Ge]),k.useEffect(()=>{_&&(j!=null&&j.id)?sessionStorage.setItem(TI,JSON.stringify({dealId:j.id,open:!0})):sessionStorage.removeItem(TI)},[_,j==null?void 0:j.id]);const lt=(oe==null?void 0:oe.byDeal)||{},He=(oe==null?void 0:oe.unique)||[],We=Ge.filter(Is=>{var dr,Sr,dn,Yr,ui,ns;const Ar=Y.toLowerCase(),tn=lt[Is.id]||[],na=!Ar||Is.deal_name.toLowerCase().includes(Ar)||((Sr=(dr=Is.contact)==null?void 0:dr.first_name)==null?void 0:Sr.toLowerCase().includes(Ar))||((Yr=(dn=Is.contact)==null?void 0:dn.last_name)==null?void 0:Yr.toLowerCase().includes(Ar))||((ui=Is.property_address)==null?void 0:ui.toLowerCase().includes(Ar))||((ns=Is.city)==null?void 0:ns.toLowerCase().includes(Ar))||tn.some(Wt=>Wt.toLowerCase().includes(Ar)),Ln=Q==="all"||Is.deal_type===Q,tr=ne==="all"||tn.includes(ne);return na&&Ln&&tr}),tt=k.useMemo(()=>{if(!s)return l||null;const Is=new Set(s.filter(dr=>dr.is_won_stage).map(dr=>dr.id)),Ar=new Set(s.filter(dr=>dr.is_lost_stage).map(dr=>dr.id)),tn=Ge.filter(dr=>dr.stage_id&&!Is.has(dr.stage_id)&&!Ar.has(dr.stage_id)),na=Ge.filter(dr=>dr.stage_id&&Is.has(dr.stage_id)),Ln=new Date().getFullYear(),tr=na.filter(dr=>dr.actual_close_date?new Date(dr.actual_close_date).getFullYear()===Ln:!0);return{totalDeals:Ge.length,activeDeals:tn.length,wonDeals:na.length,pipelineValue:tn.reduce((dr,Sr)=>dr+(Sr.expected_price||0),0),expectedCommission:tn.reduce((dr,Sr)=>dr+(Sr.expected_commission||0),0),expectedNetToAgent:tn.reduce((dr,Sr)=>dr+(Nx(Sr)||0),0),wonValue:na.reduce((dr,Sr)=>dr+(Sr.expected_price||0),0),weightedGCI:tn.reduce((dr,Sr)=>dr+(Sr.expected_commission||0)*((Sr.probability??50)/100),0),weightedNet:tn.reduce((dr,Sr)=>dr+(Nx(Sr)||0)*((Sr.probability??50)/100),0),ytdWonDeals:tr.length,ytdWonGCI:tr.reduce((dr,Sr)=>dr+(Sr.expected_commission||0),0),ytdWonNet:tr.reduce((dr,Sr)=>dr+(Nx(Sr)||0),0),projectedAnnualNet:tr.reduce((dr,Sr)=>dr+(Nx(Sr)||0),0)+tn.reduce((dr,Sr)=>dr+(Nx(Sr)||0)*((Sr.probability??50)/100),0)}},[Ge,s,l]),Ke=Is=>{N(Is),w(!0)},rt=Is=>{M(Is||null),N(null),y(!0)},it=Is=>{N(Is),w(!1),y(!0)},It=Is=>{w(Is),Is||sessionStorage.removeItem(TI)},Vt=(Is,Ar)=>{P(Is)},hs=(Is,Ar)=>{Is.preventDefault(),Is.dataTransfer.dropEffect="move",q(Ar)},Es=async(Is,Ar)=>{if(Is.preventDefault(),q(null),!I)return;const tn=n==null?void 0:n.find(tr=>tr.id===I),na=s==null?void 0:s.find(tr=>tr.id===Ar),Ln=s==null?void 0:s.find(tr=>tr.id===(tn==null?void 0:tn.stage_id));if(!tn||!na||tn.stage_id===Ar){P(null);return}Ae({dealId:I,dealName:tn.deal_name,fromStageName:(Ln==null?void 0:Ln.name)||"Unknown",toStageName:na.name,toStageId:Ar,isWonStage:na.is_won_stage,deal:tn}),P(null)},Ts=async()=>{if(!Ee)return;const{dealId:Is,toStageId:Ar,toStageName:tn,isWonStage:na,deal:Ln}=Ee;if(await u.mutateAsync({dealId:Is,stageId:Ar,stageName:tn}),me.success(`Moved to ${tn}`),na&&!Ln.scorecard_transaction_id){const tr={...Ln,stage_id:Ar};X(tr),z(!0)}},cr=k.useCallback(async(Is,Ar,tn)=>{const na=n==null?void 0:n.find(dr=>dr.id===Is),Ln=s==null?void 0:s.find(dr=>dr.id===Ar),tr=s==null?void 0:s.find(dr=>dr.id===(na==null?void 0:na.stage_id));!na||!Ln||na.stage_id===Ar||Ae({dealId:Is,dealName:na.deal_name,fromStageName:(tr==null?void 0:tr.name)||"Unknown",toStageName:tn,toStageId:Ar,isWonStage:Ln.is_won_stage,deal:na})},[n,s]),zr=Is=>We.filter(Ar=>Ar.stage_id===Is),Ft=r||a,Ps=t?"list":m;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(G,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(zo,{className:"h-4 w-4"})}),!t&&e.jsx(W1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:m==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(Tp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(sc,{children:"Kanban board view"})]}),e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:m==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(nh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(sc,{children:"Grouped list view"})]}),e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:m==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(rT,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(sc,{children:"Sortable table view"})]}),e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(G,{variant:m==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(nn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(sc,{children:"Client portal management"})]})]})}),Me&&!ke&&e.jsxs(G,{variant:"outline",onClick:()=>xe(!0),children:[e.jsx(ur,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(G,{onClick:()=>rt(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Ps!=="portals"&&e.jsx(tks,{stats:tt,isLoading:i}),Ps!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search deals, contacts, addresses, tags...",value:Y,onChange:Is=>J(Is.target.value),className:"pl-9 pr-8"}),Y&&e.jsx("button",{onClick:()=>J(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Er,{className:"h-4 w-4"})})]}),e.jsxs(Rs,{value:Q,onValueChange:ce,children:[e.jsx(Ls,{className:"w-[140px]",children:e.jsx($s,{placeholder:"All Types"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Types"}),e.jsx(ft,{value:"buyer",children:"Buyer"}),e.jsx(ft,{value:"seller",children:"Seller"}),e.jsx(ft,{value:"dual",children:"Dual"}),e.jsx(ft,{value:"referral",children:"Referral"}),e.jsx(ft,{value:"lease",children:"Lease"})]})]}),e.jsxs(Rs,{value:ne,onValueChange:re,children:[e.jsxs(Ls,{className:"w-[160px]",children:[e.jsx(Lh,{className:"h-3.5 w-3.5 mr-1.5 text-muted-foreground"}),e.jsx($s,{placeholder:"All Tags"})]}),e.jsxs(Ds,{className:"max-h-[300px]",children:[e.jsx(ft,{value:"all",children:"All Tags"}),He.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No tags yet"}),He.map(Is=>e.jsx(ft,{value:Is,children:Is},Is))]})]}),ne!=="all"&&e.jsxs(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(Lh,{className:"h-3 w-3"}),ne,e.jsx("button",{onClick:()=>re("all"),className:"ml-1 hover:text-foreground","aria-label":"Clear tag filter",children:e.jsx(Er,{className:"h-3 w-3"})})]}),(Y||Q!=="all"||ne!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[We.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[ke&&!t&&Oe.length>0&&e.jsx(KNs,{members:Oe,enabledMembers:_e,onToggleMember:Ue,isOpen:ue,onToggleOpen:()=>ge(Is=>!Is)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Ft?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Is=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(ws,{className:"h-full rounded-xl"})},Is))}):Ps==="board"?e.jsxs(Li,{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(Is=>e.jsx(eks,{stage:Is,deals:zr(Is.id),onDealClick:Ke,onAddDeal:rt,onDragStart:Vt,onDragOver:hs,onDrop:Es,isDragOver:O===Is.id,isWonStage:Is.is_won_stage,getOwnerInfo:pe},Is.id))}),e.jsx(yue,{orientation:"horizontal"})]}):Ps==="table"?e.jsx(Li,{className:"h-full",children:e.jsx(Cks,{deals:We,stages:s||[],onDealClick:Ke,onStageChange:cr})}):Ps==="portals"?e.jsx(qks,{}):e.jsx(Li,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Is=>{const Ar=zr(Is.id);return Ar.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:Is.color}}),e.jsx("h3",{className:"font-semibold",children:Is.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",Ar.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:Ar.map(tn=>e.jsx(Ult,{deal:tn,onClick:()=>Ke(tn),stages:s,onStageChange:cr,showStagePicker:!0,isWonStage:Is.is_won_stage,ownerInfo:pe(tn)},tn.id))})]},Is.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(Tp,{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(G,{onClick:()=>rt(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&We.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(sn,{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(G,{variant:"outline",onClick:()=>{J(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(aks,{open:g,onOpenChange:y,deal:j,defaultStageId:S}),e.jsx(Nks,{deal:j,open:_,onOpenChange:It,onEdit:it,isWonStage:j?(yr=s==null?void 0:s.find(Is=>Is.id===j.stage_id))==null?void 0:yr.is_won_stage:!1,onAddToScorecard:Is=>{X(Is),z(!0),w(!1)}}),e.jsx(kks,{open:$,onOpenChange:z,deal:V,onComplete:()=>{o(),X(null)}}),Ee&&e.jsx(zks,{open:!!Ee,onOpenChange:Is=>{Is||Ae(null)},dealId:Ee.dealId,dealName:Ee.dealName,fromStageName:Ee.fromStageName,toStageName:Ee.toStageName,toStageId:Ee.toStageId,onConfirm:Ts}),e.jsx(GNs,{open:he,onOpenChange:xe})]})}function Hks(){return e.jsx(Uks,{children:e.jsx(Vks,{})})}function Wlt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var J;const o=Aks(),l=Eks(),{data:i}=lme(),c=Fa(),{data:u}=pt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:Q,error:ce}=await H.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",c).order("first_name").limit(500);if(ce)throw ce;return Q},enabled:!!c&&t}),[m,f]=k.useState(""),[g,y]=k.useState(""),[_,w]=k.useState("none"),[j,N]=k.useState("none"),[S,M]=k.useState("medium"),[I,P]=k.useState("todo"),[O,q]=k.useState(),[$,z]=k.useState(!1),[V,X]=k.useState(!1);k.useEffect(()=>{r?(f(r.title),y(r.description||""),w(r.deal_id||"none"),N(r.contact_id||"none"),M(r.priority),P(r.status),q(r.due_date?Mm(r.due_date):void 0)):(f(""),y(""),w(n||"none"),N("none"),M("medium"),P("todo"),q(void 0))},[r,t,n]);const Y=async()=>{if(!m.trim()){me.error("Task title is required");return}try{const Q={title:m.trim(),description:g.trim()||null,deal_id:_==="none"?null:_,contact_id:j==="none"?null:j,stage_id:a||null,priority:S,status:I,due_date:O?ds(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Q}),me.success("Task updated")):(await o.mutateAsync(Q),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(js,{children:e.jsx(vs,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title *"}),e.jsx(Le,{value:m,onChange:Q=>f(Q.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:g,onChange:Q=>y(Q.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Priority"}),e.jsxs(Rs,{value:S,onValueChange:Q=>M(Q),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"low",children:"🟢 Low"}),e.jsx(ft,{value:"medium",children:"🟡 Medium"}),e.jsx(ft,{value:"high",children:"🟠 High"}),e.jsx(ft,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Status"}),e.jsxs(Rs,{value:I,onValueChange:Q=>P(Q),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"todo",children:"To Do"}),e.jsx(ft,{value:"in_progress",children:"In Progress"}),e.jsx(ft,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Due Date"}),e.jsxs(Vo,{children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(fn,{className:"mr-2 h-4 w-4"}),O?ds(O,"PPP"):"Pick a date"]})}),e.jsx($o,{className:"w-auto p-0",align:"start",children:e.jsx(Nf,{mode:"single",selected:O,onSelect:q,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Link to Deal"}),e.jsxs(Vo,{open:$,onOpenChange:z,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),_!=="none"?((J=i==null?void 0:i.find(Q=>Q.id===_))==null?void 0:J.deal_name)||"Select deal":"No Deal"]}),e.jsx(Ex,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search deals..."}),e.jsxs(qx,{children:[e.jsx(Ux,{children:"No deals found."}),e.jsxs(Vx,{children:[e.jsxs(_p,{value:"no-deal",onSelect:()=>{w("none"),z(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",_==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Q=>e.jsxs(_p,{value:Q.deal_name,onSelect:()=>{w(Q.id),z(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",_===Q.id?"opacity-100":"opacity-0")}),Q.deal_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Link to Contact"}),e.jsxs(Vo,{open:V,onOpenChange:X,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{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(Zi,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?(()=>{const Q=u==null?void 0:u.find(ce=>ce.id===j);return Q?`${Q.first_name} ${Q.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(Ex,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Bx,{children:[e.jsx($x,{placeholder:"Search contacts..."}),e.jsxs(qx,{children:[e.jsx(Ux,{children:"No contacts found."}),e.jsxs(Vx,{children:[e.jsxs(_p,{value:"no-contact",onSelect:()=>{N("none"),X(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Q=>e.jsxs(_p,{value:`${Q.first_name} ${Q.last_name}`,onSelect:()=>{N(Q.id),X(!1)},children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",j===Q.id?"opacity-100":"opacity-0")}),Q.first_name," ",Q.last_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(G,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{onClick:Y,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const Gks={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 Wks({tasks:t}){const s=S3e(),r=Pks(),n=ar(),[a,o]=k.useState(null),l=async m=>{const f=m.status==="done"?"todo":"done";try{await s.mutateAsync({id:m.id,status:f})}catch{me.error("Failed to update task")}},i=async m=>{try{await r.mutateAsync(m),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(m=>{if(m.deal){const f=c.get(m.deal.id)||{dealName:m.deal.deal_name,tasks:[]};f.tasks.push(m),c.set(m.deal.id,f)}else u.push(m)}),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(m=>e.jsx(zze,{task:m,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},m.id))]}),Array.from(c.entries()).map(([m,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${m}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(Ye,{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(zze,{task:g,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:y=>n(`/mission-control/pipeline?deal=${y}`)},g.id))]},m)),a&&e.jsx(Wlt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function zze({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&M0(Mm(t.due_date))&&!Nu(Mm(t.due_date)),i=!o&&t.due_date&&Nu(Mm(t.due_date)),c=Gks[t.priority];return e.jsxs("div",{className:Pt("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}):e.jsx(jd,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Zi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(Ye,{variant:"outline",className:Pt("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:Pt("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(mn,{className:"h-3 w-3"}),ds(Mm(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(md,{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(kr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Kks=[{status:"todo",label:"To Do",icon:jd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:fp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:sa,color:"border-t-emerald-500"}],Zks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Yks({tasks:t}){const s=S3e(),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:Kks.map(o=>e.jsxs("div",{className:Pt("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(Ye,{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(Qks,{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 Qks({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&M0(Mm(t.due_date))&&!Nu(Mm(t.due_date)),a=!r&&t.due_date&&Nu(Mm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Pt("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:Zks[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Ta,{className:"h-2.5 w-2.5"}),t.deal.deal_name]}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Zi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Pt("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(mn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ds(Mm(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 Bze={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Xks({tasks:t}){const[s,r]=k.useState(new Date),n=S3e(),a=Bc(s),o=px(s),l=tm(a),i=mue(o),c=iSt({start:l,end:i}),u=k.useMemo(()=>{const g=new Map;return t.forEach(y=>{if(!y.due_date)return;const _=y.due_date,w=g.get(_)||[];w.push(y),g.set(_,w)}),g},[t]),m=k.useMemo(()=>t.filter(g=>!g.due_date),[t]),f=async g=>{const y=g.status==="done"?"todo":"done";try{await n.mutateAsync({id:g.id,status:y})}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(G,{variant:"ghost",size:"icon",onClick:()=>r(N4(s,1)),children:e.jsx(tl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ds(s,"MMMM yyyy")}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>r(qm(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 y=ds(g,"yyyy-MM-dd"),_=u.get(y)||[],w=fue(g,s),j=Nu(g);return e.jsxs("div",{className:Pt("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",j&&"bg-primary/5"),children:[e.jsx("div",{className:Pt("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",j&&"text-primary font-bold"),children:ds(g,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[_.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>f(N),className:Pt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",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(jd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[Bze[N.priority]," ",N.title]})]},N.id)),_.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",_.length-3," more"]})]})]},y)})}),m.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 (",m.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.map(g=>e.jsxs("button",{onClick:()=>f(g),className:Pt("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(jd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[Bze[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 Jks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function e4s({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}=Lks(n||void 0),i=Dks(),c=Oks(),[u,m]=k.useState(""),[f,g]=k.useState("medium"),[y,_]=k.useState(""),w=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:y?parseInt(y):null,sort_order:((o==null?void 0:o.length)||0)+1}),m(""),_(""),me.success("Template added")}catch{me.error("Failed to add template")}},j=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(js,{children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(jL,{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(ye,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:Pt("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Li,{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:Jks[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>j(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(kr,{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(ye,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Task title...",value:u,onChange:S=>m(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(Rs,{value:f,onValueChange:S=>g(S),children:[e.jsx(Ls,{className:"w-[100px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"low",children:"🟢 Low"}),e.jsx(ft,{value:"medium",children:"🟡 Med"}),e.jsx(ft,{value:"high",children:"🟠 High"}),e.jsx(ft,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ye,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Le,{type:"number",placeholder:"e.g., 7",value:y,onChange:S=>_(S.target.value)})]}),e.jsxs(G,{onClick:w,disabled:!u.trim()||i.isPending,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function t4s(){const{data:t,isLoading:s}=Mks(),{data:r}=ome(),[n,a]=k.useState("list"),[o,l]=k.useState(""),[i,c]=k.useState("active"),[u,m]=k.useState("all"),[f,g]=k.useState("all"),[y,_]=k.useState(!1),[w,j]=k.useState(!1),N=k.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(P=>{P.deal&&I.set(P.deal.id,P.deal.deal_name)}),Array.from(I,([P,O])=>({id:P,name:O}))},[t]),S=k.useMemo(()=>t?t.filter(I=>{var V,X,Y,J;const P=o.toLowerCase(),O=!P||I.title.toLowerCase().includes(P)||((X=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:X.toLowerCase().includes(P))||`${((Y=I.contact)==null?void 0:Y.first_name)||""} ${((J=I.contact)==null?void 0:J.last_name)||""}`.toLowerCase().includes(P),q=i==="all"||i==="active"&&I.status!=="done"||i==="todo"&&I.status==="todo"||i==="in_progress"&&I.status==="in_progress"||i==="done"&&I.status==="done"||i==="overdue"&&I.status!=="done"&&I.due_date&&M0(Mm(I.due_date))&&!Nu(Mm(I.due_date)),$=u==="all"||I.priority===u,z=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return O&&q&&$&&z}):[],[t,o,i,u,f]),M=k.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(P=>P.status!=="done");return{total:I.length,overdue:I.filter(P=>P.due_date&&M0(Mm(P.due_date))&&!Nu(Mm(P.due_date))).length,dueToday:I.filter(P=>P.due_date&&Nu(Mm(P.due_date))).length,dueThisWeek:I.filter(P=>P.due_date&&sCt(Mm(P.due_date))).length,completed:t.filter(P=>P.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(G,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[e.jsx(ty,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(G,{size:"sm",onClick:()=>_(!0),children:[e.jsx(qs,{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(nh,{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(vd,{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(mn,{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(Fd,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:u,onValueChange:m,children:[e.jsx(Ls,{className:"w-[130px]",children:e.jsx($s,{placeholder:"Priority"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Priorities"}),e.jsx(ft,{value:"urgent",children:"🔴 Urgent"}),e.jsx(ft,{value:"high",children:"🟠 High"}),e.jsx(ft,{value:"medium",children:"🟡 Medium"}),e.jsx(ft,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(Rs,{value:f,onValueChange:g,children:[e.jsx(Ls,{className:"w-[160px]",children:e.jsx($s,{placeholder:"Deal"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Deals"}),e.jsx(ft,{value:"no_deal",children:"No Deal"}),N.map(I=>e.jsx(ft,{value:I.id,children:I.name},I.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(nh,{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(x0,{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(Fd,{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(Wks,{tasks:S}),n==="kanban"&&e.jsx(Yks,{tasks:S}),n==="calendar"&&e.jsx(Xks,{tasks:S})]}),e.jsx(Wlt,{open:y,onOpenChange:_}),e.jsx(e4s,{open:w,onOpenChange:j,stages:r||[]})]})})}const wwe=[{value:"video_intro",label:"Video Intro",icon:An,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:IL,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Lh,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:pl,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:nd,description:"Links to your social profiles"}],s4s=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],r4s={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function Klt({cardId:t}){const{data:s,isLoading:r}=Jkt(t),n=e4t(),a=t4t(),o=s4t(),[l,i]=k.useState(!1),[c,u]=k.useState(""),[m,f]=k.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ws,{className:"h-16 w-full"}),e.jsx(ws,{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:r4s[c]||{}},{onSuccess:()=>{i(!1),u("")}})},y=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},_=(S,M)=>{if(!s)return;const I=s.findIndex(q=>q.id===S.id),P=M==="up"?I-1:I+1;if(P<0||P>=s.length)return;const O=s[P];a.mutate({id:S.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},j=(S,M)=>{a.mutate({id:S.id,config:M},{onSuccess:()=>f(null)})},N=S=>wwe.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(G,{size:"sm",onClick:()=>i(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,M)=>{const I=N(S.block_type),P=(I==null?void 0:I.icon)||Lh;return e.jsx(Pe,{className:S.is_visible?"":"opacity-50",children:e.jsx(De,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Eu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(P,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n4s(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"up"),disabled:M===0,children:e.jsx(Tu,{className:"h-3 w-3"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"down"),disabled:M===s.length-1,children:e.jsx(Yh,{className:"h-3 w-3"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>y(S),children:S.is_visible?e.jsx(Tn,{className:"h-3 w-3"}):e.jsx(Cp,{className:"h-3 w-3"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(kr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(G,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:wwe.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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(G,{onClick:g,disabled:!c||n.isPending,children:"Add Block"})]})]})}),m&&e.jsx(a4s,{block:m,onSave:S=>j(m,S),onClose:()=>f(null)})]})}function n4s(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 a4s({block:t,onSave:s,onClose:r}){const[n,a]=k.useState(t.config),o=wwe.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(js,{children:e.jsxs(vs,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(i4s,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(o4s,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(l4s,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(c4s,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(d4s,{config:n,onChange:a}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(G,{onClick:()=>s(n),children:"Save"})]})]})})}function i4s({config:t,onChange:s,cardId:r}){var y,_;const[n,a]=k.useState(""),[o,l]=k.useState((y=t.video_url)!=null&&y.includes("youtube")||(_=t.video_url)!=null&&_.includes("youtu.be")?"youtube":"library"),{data:i}=pt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await H.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:c,isLoading:u}=pt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:j}=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(j)throw j;return w||[]},enabled:!!i}),m=(c==null?void 0:c.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,g=w=>{var M;const j=(M=w.playback_url)==null?void 0:M.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${j?j[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ga,{value:o,onValueChange:l,children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ss,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ss,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(Li,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ws,{className:"h-14 w-full"}),e.jsx(ws,{className:"h-14 w-full"})]}):m.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:m.map(w=>e.jsxs("button",{onClick:()=>g(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:j=>{var N;j.currentTarget.style.display="none",(N=j.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 ${w.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:w.title||"Untitled Video"}),f===w.bunny_video_id&&e.jsx(ua,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx(bs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ye,{children:"YouTube URL"}),e.jsx(Le,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function o4s({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(Pe,{children:e.jsxs(De,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(kr,{className:"h-3 w-3"})})]}),e.jsx(Le,{placeholder:"Client name",value:l.name,onChange:c=>n(i,"name",c.target.value)}),e.jsx(Le,{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(G,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function l4s({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(ye,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s4s.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(ye,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(G,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(ye,{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 c4s({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(Le,{placeholder:"Button label",value:l.label,onChange:c=>n(i,"label",c.target.value)}),e.jsx(Le,{placeholder:"https://...",value:l.url,onChange:c=>n(i,"url",c.target.value)})]}),r.length>1&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(kr,{className:"h-3 w-3"})})]},i)),e.jsxs(G,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const $ze=[{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 d4s({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 m=[...r];m[c]={...m[c],url:u},s({...t,platforms:m})},o=c=>{s({...t,platforms:r.filter((u,m)=>m!==c)})},l=$ze.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=Gve[c],m=$ze.find(f=>f.value===c);return{label:(m==null?void 0:m.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 m=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:m.color+"30",backgroundColor:m.color+"10"},children:m.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:m.color,children:e.jsx("path",{d:m.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Le,{placeholder:`Your ${m.label} profile URL`,value:c.url,onChange:f=>a(u,f.target.value)})}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(ye,{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=Gve[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 u4s=Object.defineProperty,pde=Object.getOwnPropertySymbols,Zlt=Object.prototype.hasOwnProperty,Ylt=Object.prototype.propertyIsEnumerable,qze=(t,s,r)=>s in t?u4s(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,jwe=(t,s)=>{for(var r in s||(s={}))Zlt.call(s,r)&&qze(t,r,s[r]);if(pde)for(var r of pde(s))Ylt.call(s,r)&&qze(t,r,s[r]);return t},Nwe=(t,s)=>{var r={};for(var n in t)Zlt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&pde)for(var n of pde(t))s.indexOf(n)<0&&Ylt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var j3;(t=>{const s=class yo{constructor(c,u,m,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cyo.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 _,w;for(_=m;;_++){const M=yo.getNumDataCodewords(_,u)*8,I=l.getTotalBits(c,_);if(I<=M){w=I;break}if(_>=f)throw new RangeError("Data too long")}for(const M of[yo.Ecc.MEDIUM,yo.Ecc.QUARTILE,yo.Ecc.HIGH])y&&w<=yo.getNumDataCodewords(_,M)*8&&(u=M);let j=[];for(const M of c){r(M.mode.modeBits,4,j),r(M.numChars,M.mode.numCharCountBits(_),j);for(const I of M.getData())j.push(I)}a(j.length==w);const N=yo.getNumDataCodewords(_,u)*8;a(j.length<=N),r(0,Math.min(4,N-j.length),j),r(0,(8-j.length%8)%8,j),a(j.length%8==0);for(let M=236;j.lengthS[I>>>3]|=M<<7-(I&7)),new yo(_,u,S,g)}getModule(c,u){return 0<=c&&c>>9)*1335;const f=(u<<10|m)^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 m=0;m<12;m++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;a(u>>>18==0);for(let m=0;m<18;m++){const f=n(u,m),g=this.size-11+m%3,y=Math.floor(m/3);this.setFunctionModule(g,y,f),this.setFunctionModule(y,g,f)}}drawFinderPattern(c,u){for(let m=-4;m<=4;m++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(m)),y=c+f,_=u+m;0<=y&&y{(M!=w-g||P>=_)&&S.push(I[M])});return a(S.length==y),S}drawCodewords(c){if(c.length!=Math.floor(yo.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let m=this.size-1;m>=1;m-=2){m==6&&(m=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(_,w),y||(c+=this.finderPenaltyCountPatterns(w)*yo.PENALTY_N3),y=this.modules[g][j],_=1);c+=this.finderPenaltyTerminateAndCount(y,_,w)*yo.PENALTY_N3}for(let g=0;g5&&c++):(this.finderPenaltyAddHistory(_,w),y||(c+=this.finderPenaltyCountPatterns(w)*yo.PENALTY_N3),y=this.modules[j][g],_=1);c+=this.finderPenaltyTerminateAndCount(y,_,w)*yo.PENALTY_N3}for(let g=0;gy+(_?1:0),u);const m=this.size*this.size,f=Math.ceil(Math.abs(u*20-m*10)/m)-1;return a(0<=f&&f<=9),c+=f*yo.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 m=[6];for(let f=this.size-7;m.lengthyo.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const m=Math.floor(c/7)+2;u-=(25*m-10)*m-55,c>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(yo.getNumRawDataModules(c)/8)-yo.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*yo.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^m.shift();m.push(0),u.forEach((y,_)=>m[_]^=yo.reedSolomonMultiply(y,g))}return m}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let m=0;for(let f=7;f>=0;f--)m=m<<1^(m>>>7)*285,m^=(u>>>f&1)*c;return a(m>>>8==0),m}finderPenaltyCountPatterns(c){const u=c[1];a(u<=this.size*3);const m=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(m&&c[0]>=u*4&&c[6]>=u?1:0)+(m&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,m){return c&&(this.finderPenaltyAddHistory(u,m),u=0),u+=this.size,this.finderPenaltyAddHistory(u,m),this.finderPenaltyCountPatterns(m)}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 m=c-1;m>=0;m--)u.push(i>>>m&1)}function n(i,c){return(i>>>c&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class ud{constructor(c,u,m){if(this.mode=c,this.numChars=u,this.bitData=m,u<0)throw new RangeError("Invalid argument");this.bitData=m.slice()}static makeBytes(c){let u=[];for(const m of c)r(m,8,u);return new ud(ud.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!ud.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let m=0;m=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={}))})(j3||(j3={}));(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={}))})(j3||(j3={}));var PM=j3;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var h4s={L:PM.QrCode.Ecc.LOW,M:PM.QrCode.Ecc.MEDIUM,Q:PM.QrCode.Ecc.QUARTILE,H:PM.QrCode.Ecc.HIGH},Qlt=128,Xlt="L",Jlt="#FFFFFF",ect="#000000",tct=!1,sct=1,m4s=4,p4s=0,f4s=.1;function rct(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 nct(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 x4s(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*f4s),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,m=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),w=Math.floor(m),j=Math.ceil(i+u-_),N=Math.ceil(c+m-w);g={x:_,y:w,w:j,h:N}}const y=n.crossOrigin;return{x:u,y:m,h:c,w:i,excavation:g,opacity:f,crossOrigin:y}}function g4s(t,s){return s!=null?Math.max(Math.floor(s),0):t?m4s:p4s}function act({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let c=mt.useMemo(()=>{const _=(Array.isArray(t)?t:[t]).reduce((w,j)=>(w.push(...PM.QrSegment.makeSegments(j)),w),[]);return PM.QrCode.encodeSegments(_,h4s[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:m,numCells:f,calculatedImageSettings:g}=mt.useMemo(()=>{let y=c.getModules();const _=g4s(n,a),w=y.length+_*2,j=x4s(y,l,_,o);return{cells:y,margin:_,numCells:w,calculatedImageSettings:j}},[c,l,o,n,a]);return{qrcode:c,margin:m,cells:u,numCells:f,calculatedImageSettings:g}}var y4s=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),v4s=mt.forwardRef(function(s,r){const n=s,{value:a,size:o=Qlt,level:l=Xlt,bgColor:i=Jlt,fgColor:c=ect,includeMargin:u=tct,minVersion:m=sct,boostLevel:f,marginSize:g,imageSettings:y}=n,w=Nwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=w,N=Nwe(w,["style"]),S=y==null?void 0:y.src,M=mt.useRef(null),I=mt.useRef(null),P=mt.useCallback(Q=>{M.current=Q,typeof r=="function"?r(Q):r&&(r.current=Q)},[r]),[O,q]=mt.useState(!1),{margin:$,cells:z,numCells:V,calculatedImageSettings:X}=act({value:a,level:l,minVersion:m,boostLevel:f,includeMargin:u,marginSize:g,imageSettings:y,size:o});mt.useEffect(()=>{if(M.current!=null){const Q=M.current,ce=Q.getContext("2d");if(!ce)return;let ne=z;const re=I.current,oe=X!=null&&re!==null&&re.complete&&re.naturalHeight!==0&&re.naturalWidth!==0;oe&&X.excavation!=null&&(ne=nct(z,X.excavation));const he=window.devicePixelRatio||1;Q.height=Q.width=o*he;const xe=o/V*he;ce.scale(xe,xe),ce.fillStyle=i,ce.fillRect(0,0,V,V),ce.fillStyle=c,y4s?ce.fill(new Path2D(rct(ne,$))):z.forEach(function(ue,ge){ue.forEach(function(_e,Be){_e&&ce.fillRect(Be+$,ge+$,1,1)})}),X&&(ce.globalAlpha=X.opacity),oe&&ce.drawImage(re,X.x+$,X.y+$,X.w,X.h)}}),mt.useEffect(()=>{q(!1)},[S]);const Y=jwe({height:o,width:o},j);let J=null;return S!=null&&(J=mt.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{q(!0)},ref:I,crossOrigin:X==null?void 0:X.crossOrigin})),mt.createElement(mt.Fragment,null,mt.createElement("canvas",jwe({style:Y,height:o,width:o,ref:P,role:"img"},N)),J)});v4s.displayName="QRCodeCanvas";var qR=mt.forwardRef(function(s,r){const n=s,{value:a,size:o=Qlt,level:l=Xlt,bgColor:i=Jlt,fgColor:c=ect,includeMargin:u=tct,minVersion:m=sct,boostLevel:f,title:g,marginSize:y,imageSettings:_}=n,w=Nwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:N,numCells:S,calculatedImageSettings:M}=act({value:a,level:l,minVersion:m,boostLevel:f,includeMargin:u,marginSize:y,imageSettings:_,size:o});let I=N,P=null;_!=null&&M!=null&&(M.excavation!=null&&(I=nct(N,M.excavation)),P=mt.createElement("image",{href:_.src,height:M.h,width:M.w,x:M.x+j,y:M.y+j,preserveAspectRatio:"none",opacity:M.opacity,crossOrigin:M.crossOrigin}));const O=rct(I,j);return mt.createElement("svg",jwe({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!g&&mt.createElement("title",null,g),mt.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),mt.createElement("path",{fill:c,d:O,shapeRendering:"crispEdges"}),P)});qR.displayName="QRCodeSVG";function b4s({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),m=new Image;m.onload=()=>{c.fillStyle="#ffffff",c.fillRect(0,0,i,i),c.drawImage(m,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!")},m.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(qR,{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(G,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(vi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Uye(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 _4s(){const{user:t}=Fs(),{data:s,isLoading:r}=Ykt(t==null?void 0:t.id),n=UE(),[a,o]=k.useState(null),l=k.useMemo(()=>a||(s?Uye(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(ws,{className:"h-8 w-48"}),e.jsx(ws,{className:"h-32 w-full"}),e.jsx(ws,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ms,{children:e.jsx(j4s,{userId:t==null?void 0:t.id})});const i=l||Uye(s),c=u=>{o(m=>{const f=m||Uye(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(N4s,{card:s}),e.jsx(M4s,{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(vS,{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(w4s,{card:s,form:i})})]})})]})})}function w4s({card:t,form:s}){const{data:r}=pt({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(kje,{card:n})})}function j4s({userId:t}){var c;const[s,r]=k.useState(""),n=DWe(),{data:a}=pt({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:Nd,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Jh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:ou,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:$l,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(nn,{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(Pe,{className:"shadow-lg border-2",children:[e.jsxs(Et,{className:"text-center pb-2",children:[e.jsx(Lt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(vr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(De,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ye,{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(Le,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(G,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function N4s({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(Ye,{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(Nd,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(yi,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(G,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function k4s({userId:t}){const s=Qt(),r=k.useRef(null),[n,a]=k.useState(!1),[o,l]=k.useState(""),{data:i,isLoading:c}=pt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:X}=await H.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Y=(X==null?void 0:X.avatar_url)||null;if(!Y){const{data:J}=await H.storage.from("avatars").list(`${t}`);if(J&&J.length>0){const{data:Q}=H.storage.from("avatars").getPublicUrl(`${t}/${J[0].name}`);Y=`${Q.publicUrl}?t=${Date.now()}`,await H.from("profiles").update({avatar_url:Y}).eq("id",t)}}return{...X,avatar_url:Y}}}),[u,m]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(!1),N=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",M=y??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,P=((i==null?void 0:i.name)||"A").split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),q=Tt({mutationFn:async X=>{const{error:Y}=await H.from("profiles").update(X).eq("id",t);if(Y)throw Y},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")}),$=()=>{const X={};if(u!==null&&u!==(i==null?void 0:i.name)&&(X.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(X.phone=f||null),y!==null&&y!==(i==null?void 0:i.email)&&(X.email=y),Object.keys(X).length===0){me.info("No changes to save");return}q.mutate(X)},z=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;if(!Y.type.startsWith("image/")){me.error("Please select an image file");return}const J=new FileReader;J.onloadend=()=>{l(J.result),a(!0)},J.readAsDataURL(Y),X.target.value=""},V=async X=>{j(!0);try{const{data:Y}=await H.storage.from("avatars").list(`${t}`);Y&&Y.length>0&&await H.storage.from("avatars").remove(Y.map(re=>`${t}/${re.name}`));const J=`${t}/avatar.jpg`,{error:Q}=await H.storage.from("avatars").upload(J,X,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:ce}=H.storage.from("avatars").getPublicUrl(J),ne=ce.publicUrl+"?t="+Date.now();await H.from("profiles").update({avatar_url:ne}).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{j(!1)}};return c?e.jsx(ws,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(De,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ye,{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(ul,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var X;return(X=r.current)==null?void 0:X.click()},children:[e.jsxs(Cn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Wa,{src:I||void 0,alt:N}),e.jsx(Mn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:P})]}),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(gf,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:z})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":I?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Le,{value:N,onChange:X=>m(X.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Le,{value:S,onChange:X=>g(X.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Le,{value:M,onChange:X=>_(X.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(G,{variant:"outline",size:"sm",onClick:$,disabled:q.isPending,className:"w-full",children:q.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(Fke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function S4s({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=y=>{l(y),s(y==="name"?_=>({..._,brokerage_logo_url:""}):_=>({..._,brokerage_display_name:""}))},m=y=>{c(y),s(y==="name"?_=>({..._,team_logo_url:""}):_=>({..._,team_name:""}))},f=async(y,_)=>{var j;const w=(j=y.target.files)==null?void 0:j[0];if(w){if(!w.type.startsWith("image/")){me.error("Please select an image file");return}a(_);try{const N=w.name.split(".").pop()||"png",M=`${r}/${_==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await H.storage.from("card-logos").upload(M,w,{upsert:!0});if(I)throw I;const{data:P}=H.storage.from("card-logos").getPublicUrl(M),O=P.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),y.target.value=""}}},g=y=>{s(_=>({..._,[y]:""}))};return e.jsx(Pe,{children:e.jsxs(De,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(G,{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(ye,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Le,{value:t.brokerage_display_name,onChange:y=>s(_=>({..._,brokerage_display_name:y.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(gf,{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:y=>f(y,"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(ye,{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(Qg,{value:[t.brokerage_logo_size||56],onValueChange:([y])=>s(_=>({..._,brokerage_logo_size:y})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ye,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>m("name"),children:"Use Name"}),e.jsx(G,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>m("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Le,{value:t.team_name,onChange:y=>s(_=>({..._,team_name:y.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(gf,{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:y=>f(y,"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(ye,{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(Qg,{value:[t.team_logo_size||56],onValueChange:([y])=>s(_=>({..._,team_logo_size:y})),min:24,max:120,step:4})]})]})]})]})})}function C4s({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(ye,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx($l,{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(G,{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:m=>a(i,m.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(Le,{value:n[i],onChange:m=>{const f=m.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 M4s({card:t,form:s,setForm:r}){var w;const n=OWe(),a=Qt(),{data:o}=RWe(t.id),[l,i]=k.useState(t.slug),[c,u]=k.useState(!1),[m,f]=k.useState("idle"),g=k.useRef(JSON.stringify(s)),y=k.useRef(null);k.useEffect(()=>{const j=JSON.stringify(s);if(j!==g.current)return y.current&&clearTimeout(y.current),y.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=j,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{y.current&&clearTimeout(y.current)}},[s]);const _=async()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!j){me.error("Please enter a valid URL");return}if(j===t.slug){me.info("No changes to save");return}u(!0);try{const{data:N}=await H.from("agent_cards").select("id").eq("slug",j).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:j}).eq("id",t.id);if(S)throw S;i(j),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(ga,{defaultValue:"content",children:[e.jsxs(fa,{className:"w-full h-11 p-1",children:[e.jsxs(ss,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Px,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ss,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Tn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ss,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Jh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ss,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(b0,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ss,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx($m,{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(k4s,{userId:t.user_id}),e.jsx(S4s,{form:s,setForm:r,userId:t.user_id}),e.jsx(Pe,{children:e.jsxs(De,{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(ye,{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:j=>r(N=>({...N,is_published:j}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{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(Le,{value:l,onChange:j=>i(j.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(G,{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(ye,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Le,{value:s.display_email,onChange:j=>r(N=>({...N,display_email:j.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(Rs,{value:s.theme,onValueChange:j=>r(N=>({...N,theme:j})),children:[e.jsx(Ls,{className:"h-11",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(ft,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(ft,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(ft,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(C4s,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Le,{value:s.title,onChange:j=>r(N=>({...N,title:j.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Le,{value:s.positioning_statement,onChange:j=>r(N=>({...N,positioning_statement:j.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Tr,{value:s.bio,onChange:j=>r(N=>({...N,bio:j.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Le,{value:s.review_snippet,onChange:j=>r(N=>({...N,review_snippet:j.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Le,{value:s.review_source_url,onChange:j=>r(N=>({...N,review_source_url:j.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Le,{value:s.booking_url,onChange:j=>r(N=>({...N,booking_url:j.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Le,{value:s.custom_cta_label,onChange:j=>r(N=>({...N,custom_cta_label:j.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(bs,{value:"sections",className:"mt-4",children:e.jsx(Pe,{children:e.jsx(De,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:j,label: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(ye,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(qr,{checked:s[j],onCheckedChange:M=>r(I=>({...I,[j]:M}))})]},j))})})}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(Klt,{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:Tn,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:$m,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:El,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(j=>e.jsx(Pe,{className:"overflow-hidden",children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${j.color}`,children:e.jsx(j.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:j.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:j.value})]})},j.label))}),o&&o.leads.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsx(Lt,{className:"text-base",children:"Recent Leads"})}),e.jsx(De,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(j=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:j.name}),j.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:j.phone})]}),j.intent&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:j.intent})]},j.id))})]}),(!o||o.leads.length===0)&&e.jsx(Pe,{children:e.jsxs(De,{className:"p-8 text-center",children:[e.jsx($m,{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(Pe,{children:e.jsx(De,{className:"p-6",children:e.jsx(b4s,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[m==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),m==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),m==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function T4s(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState(null),[w,j]=k.useState(null),[N,S]=k.useState(0),{data:M,isLoading:I}=pt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:J,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Q)throw Q;return J}}),P=Tt({mutationFn:async J=>{const{data:Q,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:J}});if(ce)throw ce;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:J=>{me.error(J.message||"Failed to connect BoldTrail")}}),O=Tt({mutationFn:async()=>{const{data:J,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Q)throw Q;return J},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),q=Tt({mutationFn:async J=>{const{data:Q,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:J}});if(ce)throw ce;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:J=>{me.error(J.message||"Failed to save sync direction")}}),$=Tt({mutationFn:async()=>{const{data:J,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Q)throw Q;if(J!=null&&J.error)throw new Error(J.error);return J},onSuccess:J=>{_(null),c(J),a(!0)},onError:J=>{me.error(J.message||"Failed to generate sync preview")}}),z=Tt({mutationFn:async()=>{j("Initializing sync..."),S(5);const{data:J,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:Y}});if(Q)throw Q;if(J!=null&&J.error)throw new Error(J.error);const ce=J;let ne=ce.sync_log_id,re=ce.next_phase,oe=ce.next_offset;const he=ce.push_total||0,xe=ce.pull_total||0,ue=he+xe;let ge=0,_e=0;for(;re!=="finalize";){re==="push"?(j(`Pushing contacts to BoldTrail... (${ge}/${he})`),S(ue>0?ge/ue*100:0)):re==="pull"&&(j(`Pulling contacts from BoldTrail... (${_e}/${xe})`),S(ue>0?(he+_e)/ue*100:0));const{data:Ee,error:Ae}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:re,offset:oe,sync_log_id:ne,sync_direction:Y}});if(Ae)throw Ae;if(Ee!=null&&Ee.error)throw new Error(Ee.error);const Me=Ee;ge+=Me.chunk_pushed||0,_e+=Me.chunk_pulled||0,Me.progress&&j(Me.progress),re==="pull"&&xe>0?S(Math.min(95,_e/xe*100)):re==="push"&&he>0&&S(Math.min(95,ge/he*100)),re=Me.next_phase,oe=Me.next_offset}j("Finalizing sync..."),S(95);const{data:Be,error:Se}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ne,sync_direction:Y}});if(Se)throw Se;return S(100),Be},onSuccess:J=>{j(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${J.contacts_pushed||0}, pulled ${J.contacts_pulled||0}, skipped ${J.contacts_skipped||0} duplicates.`)},onError:J=>{j(null),S(0),me.error(J.message||"Sync failed")}}),V=M==null?void 0:M.connected,X=(M==null?void 0:M.sync_direction)||"bidirectional",Y=y??X;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{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(wd,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(Ye,{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(fp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(vr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(De,{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(wi,{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(wi,{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(wi,{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(Ye,{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(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect BoldTrail?"}),e.jsx(lc,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{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(ewe,{value:X,onChange:J=>q.mutate(J)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(G,{onClick:()=>$.mutate(),disabled:$.isPending||z.isPending,variant:"outline",className:"gap-2",children:[$.isPending?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(Tn,{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(Le,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:J=>r(J.target.value),className:"flex-1"}),e.jsxs(G,{onClick:()=>P.mutate(s),disabled:!s||s.length<10||P.isPending,children:[P.isPending?e.jsx(zo,{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:J=>{z.isPending||a(J)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(wd,{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 J=Y==="pull_only"?0:i.to_push,Q=Y==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ewe,{value:Y,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 ${Y==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:J}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Tu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Y==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Yh,{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(ur,{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"]}),z.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(qi,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:w||"Sync in progress..."})]}),J>0&&e.jsxs(bf,{open:u,onOpenChange:m,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tu,{className:"h-3 w-3 text-emerald-600"}),J," contacts to push to BoldTrail"]}),e.jsx(Ji,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(wf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ce,ne)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ne)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),Q>0&&e.jsxs(bf,{open:f,onOpenChange:g,children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yh,{className:"h-3 w-3 text-blue-600"}),Q," contacts to pull from BoldTrail"]}),e.jsx(Ji,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(wf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ce,ne)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ne)),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"]})]})})]}),J===0&&Q===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(G,{variant:"outline",onClick:()=>a(!1),disabled:z.isPending,children:"Cancel"}),e.jsxs(G,{onClick:()=>z.mutate(),disabled:z.isPending||J===0&&Q===0,className:"gap-2",children:[z.isPending?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(wd,{className:"h-4 w-4"}),z.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(js,{className:"p-6 pb-0",children:e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(wd,{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 ict(){const t=ar(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState("Test from ReLevelUp"),[i,c]=k.useState(!1),{data:u,isLoading:m}=pt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:y}}=await H.auth.getSession();if(!y)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 ${y.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:y}}=await H.auth.getSession();if(!y)throw new Error("Not authenticated");const w=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

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

If you received this, SES is configured correctly! 🎉

"})})).json();w.success?me.success(`Test email sent! Message ID: ${w.messageId}`):me.error(w.error||"Failed to send test email")}catch(y){me.error(y.message||"Failed to send test email")}finally{c(!1)}},g=(u==null?void 0:u.configured)===!0;return e.jsxs(Pe,{children:[e.jsx(Et,{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(rr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(vr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(Ye,{variant:g?"default":"secondary",children:m?"Checking...":g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ul,{className:"h-3 w-3"})," Not Configured"]})})]})}),g&&e.jsxs(De,{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(ye,{className:"text-xs",children:"From Email"}),e.jsx(Le,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:y=>a(y.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs",children:"To Email"}),e.jsx(Le,{placeholder:"your@email.com",value:s,onChange:y=>r(y.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs",children:"Subject"}),e.jsx(Le,{value:o,onChange:y=>l(y.target.value),className:"text-sm"})]})]}),e.jsxs(G,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(G,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Ph,{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&&!m&&e.jsx(De,{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 A4s(){var _,w,j,N;const{user:t}=Fs(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(""),[l,i]=k.useState(""),{data:c}=pt({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}=pt({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}}),m=((_=c==null?void 0:c.reply_to_email)==null?void 0:_.trim())||((w=u==null?void 0:u.email)==null?void 0:w.trim())||"",f=((j=c==null?void 0:c.display_name)==null?void 0:j.trim())||((N=u==null?void 0:u.name)==null?void 0:N.trim())||"";k.useEffect(()=>{r||(o(m),i(f))},[r,m,f]);const g=Tt({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)}),y=!!m;return e.jsxs(Pe,{children:[e.jsx(Et,{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(Fn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["Mass Email",y?e.jsxs(Ye,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(wi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(vr,{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(De,{className:"space-y-3",children:y&&!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:m})]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>n(!0),children:[e.jsx(Pa,{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(ye,{className:"text-xs",children:"Display Name"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(Le,{type:"email",placeholder:"your@email.com",value:a,onChange:S=>o(S.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{size:"sm",onClick:()=>g.mutate(),disabled:g.isPending||!a.trim(),children:[e.jsx(Vc,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(m),i(f)},children:[e.jsx(Er,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function E4s(){const{isAdmin:t}=Fs(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:c,isLoading:u}=pt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:P}=await H.from("gmail_integrations").select("*").maybeSingle();if(P)throw P;return I}}),{data:m}=pt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await H.auth.getUser();if(!I)return[];const{data:P,error:O}=await H.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(O)throw O;return P}}),f=async()=>{n(!0);try{const{data:I,error:P}=await H.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(P)throw P;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Gmail OAuth error:",I),me.error("Failed to start Gmail connection"),n(!1)}},g=async()=>{o(!0);try{const{data:I,error:P}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(P)throw P;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. Make sure Meta App credentials are configured."),o(!1)}},y=async()=>{i(!0);try{const{data:I,error:P}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(P)throw P;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."),i(!1)}},_=Tt({mutationFn:async I=>{const{error:P}=await H.from("gmail_integrations").delete().eq("id",I);if(P)throw P},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),w=Tt({mutationFn:async I=>{const{error:P}=await H.from("social_accounts").delete().eq("id",I);if(P)throw P},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),j=!!(c!=null&&c.is_active),N=(m==null?void 0:m.filter(I=>I.platform==="facebook"))||[],S=(m==null?void 0:m.filter(I=>I.platform==="instagram"))||[],M=(m==null?void 0:m.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),e.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),e.jsxs(Pe,{children:[e.jsx(Et,{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(rr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["Gmail",j&&e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(vr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(De,{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(wi,{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(wi,{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(wi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),j?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Gmail?"}),e.jsx(lc,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>_.mutate(c.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(G,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(zo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(ba,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Et,{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(Au,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(vr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[N.length>0&&e.jsx("div",{className:"space-y-2",children:N.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:I.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Au,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Facebook?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(G,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Et,{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(Pu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(vr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:I.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Pu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",I.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Instagram?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(G,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{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(Pe,{className:t?"":"opacity-70",children:[e.jsx(Et,{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(Ap,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?M.length>0?e.jsx(Ye,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Ye,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(vr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(De,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.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(Cn,{className:"h-8 w-8",children:[e.jsx(Wa,{src:I.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Ap,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect LinkedIn?"}),e.jsx(lc,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(G,{onClick:y,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(T4s,{}),e.jsx(A4s,{}),t&&e.jsx(ict,{})]})})}function P4s(){const[t]=Ul(),s=ar(),[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"),m=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:m}});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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[r==="loading"&&e.jsx(ys,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(wi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Nc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Lt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(G,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function I4s(){const t=ar();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 L4s(){const[t]=Ul(),s=ar(),[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"),m=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:y}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:m,callbackPath:"/mission-control/integrations/meta/callback"}});if(y)throw y;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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[r==="loading"&&e.jsx(ys,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(wi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Nc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Lt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(G,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const oct=new Date().getFullYear(),D4s=Array.from({length:5},(t,s)=>oct-s);function O4s(){const[t,s]=k.useState(oct),r=ar(),{data:n,isLoading:a}=H8t();return a?e.jsx(Ms,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ws,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(ws,{className:"h-24"},o))}),e.jsx(ws,{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(Rs,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Ls,{className:"w-[120px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:D4s.map(o=>e.jsx(ft,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ur,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(co,{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(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Agents with Scorecards"}),e.jsx(vr,{children:"Click to view individual agent scorecards"})]}),e.jsx(De,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(co,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Email"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:n.map(o=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:o.name}),e.jsx(ut,{className:"text-muted-foreground",children:o.email}),e.jsx(ut,{className:"text-right",children:e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const lct=new Date().getFullYear(),R4s=Array.from({length:10},(t,s)=>lct-s);function Uze(){var _;const{userId:t}=ao(),s=ar(),n=hc().pathname.startsWith("/mission-control"),[a,o]=k.useState(lct),{data:l,isLoading:i}=pt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return w},enabled:!!t}),{data:c,isLoading:u}=UNe(a,t),{yearStats:m,lifetimeStats:f,showCommission:g}=JQe(a,t),{data:y}=XQe(a,t);return i?e.jsx(Ms,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ws,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(ws,{className:"h-24"},w))})]})}):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(G,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Ga,{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(Rs,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(Ls,{className:"w-[120px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:R4s.map(w=>e.jsx(ft,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:m.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ur,{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:[m.buyerCount,"/",m.sellerCount]})]})}),e.jsx(Pe,{children:e.jsxs(De,{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:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ec(m.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Bo,{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:ec(m.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((_=m.topLeadSource)==null?void 0:_.name)||"-"})]})})]}),y&&e.jsx(Sit,{goals:y,stats:m,year:a,showCommission:g}),e.jsxs(ga,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"transactions",children:"Transactions"}),e.jsx(ss,{value:"charts",children:"Charts"}),e.jsxs(ss,{value:"map",children:[e.jsx(aa,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(bs,{value:"transactions",children:e.jsx(SSe,{transactions:c||[],showCommission:g,isLoading:u})}),e.jsx(bs,{value:"charts",children:e.jsx(CSe,{stats:m,year:a})}),e.jsx(bs,{value:"map",children:e.jsx(MSe,{transactions:c||[],isLoading:u})})]})]})})}function F4s(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState("all");pYe();const{data:o,refetch:l}=pt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:c}=pt({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:P}=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(P)throw P;return I}}),{data:u}=pt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await H.from("listings").select("id, is_approved, status"),{data:P}=await H.from("listing_shares").select("id"),{data:O}=await H.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter(q=>!q.is_approved).length)||0,active:(I==null?void 0:I.filter(q=>q.status==="active").length)||0,totalShares:(P==null?void 0:P.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),m=async(I,P,O="submit_url")=>{try{const{data:{session:q}}=await H.auth.getSession();if(!q)return;const{data:$,error:z}=await H.functions.invoke("google-indexing",{body:{action:O,listing_id:I,listing_slug:P}});if(z)throw z;if(($==null?void 0:$.configured)===!1)return;$!=null&&$.success&&me.success("Submitted to Google for indexing")}catch(q){console.error("Google indexing submission failed:",q)}},f=Tt({mutationFn:async()=>{const{data:{session:I}}=await H.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:P,error:O}=await H.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return P},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{me.error("Failed to submit to Google"),console.error(I)}}),g=Tt({mutationFn:async({id:I,approved:P,slug:O})=>{const{error:q}=await H.from("listings").update({is_approved:P}).eq("id",I);if(q)throw q;return{id:I,approved:P,slug:O}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?m(I.id,I.slug||null,"submit_url"):m(I.id,I.slug||null,"remove_url")}}),y=Tt({mutationFn:async({id:I,featured:P})=>{const{error:O}=await H.from("listings").update({is_featured:P}).eq("id",I);if(O)throw O},onSuccess:(I,{featured:P})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(P?"Listing featured":"Listing unfeatured")}}),_=Tt({mutationFn:async I=>{const{error:P}=await H.from("listings").delete().eq("id",I);if(P)throw P},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),w=Tt({mutationFn:async I=>{const{error:P}=await H.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(P)throw P},onSuccess:()=>{l(),me.success("Feature flag updated")}}),j=o??!1,N=i==null?void 0:i.filter(I=>{var q,$,z,V;const P=((q=I.city)==null?void 0:q.toLowerCase().includes(s.toLowerCase()))||((z=($=I.agent)==null?void 0:$.name)==null?void 0:z.toLowerCase().includes(s.toLowerCase()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return P&&O}),S=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),M=I=>{const P={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 P[I]||P.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(G,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Nd,{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:j,onCheckedChange:I=>w.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bo,{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(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ur,{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(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nd,{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(Pe,{children:e.jsx(De,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by city, address, or agent...",value:s,onChange:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(ga,{value:n,onValueChange:I=>a(I),children:e.jsxs(fa,{children:[e.jsx(ss,{value:"all",children:"All"}),e.jsx(ss,{value:"pending",children:"Pending"}),e.jsx(ss,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(De,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Property"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Price"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-center",children:"Approved"}),e.jsx(jt,{className:"text-center",children:"Featured"}),e.jsx(jt,{children:"Views"}),e.jsx(jt,{children:"Shares"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{})]})}),e.jsx(qn,{children:c?e.jsx(ks,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(I=>{var P,O,q,$,z;return e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(P=I.photos)==null?void 0:P[0])!=null&&O.photo_url?e.jsx("img",{src:I.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Ta,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.property_address||`${I.city}, ${I.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(q=I.property_type)==null?void 0:q.replace("_"," ")})]})]})}),e.jsx(ut,{children:e.jsx("p",{className:"text-sm",children:(($=I.agent)==null?void 0:$.name)||"Unknown"})}),e.jsx(ut,{className:"font-medium",children:S(I.price)}),e.jsx(ut,{children:e.jsx(Ye,{variant:"outline",className:M(I.status),children:(z=I.status)==null?void 0:z.replace("_"," ")})}),e.jsx(ut,{className:"text-center",children:e.jsx(qr,{checked:I.is_approved??!1,onCheckedChange:V=>g.mutate({id:I.id,approved:V,slug:I.slug})})}),e.jsx(ut,{className:"text-center",children:e.jsx(qr,{checked:I.is_featured??!1,onCheckedChange:V=>y.mutate({id:I.id,featured:V})})}),e.jsx(ut,{children:I.view_count||0}),e.jsx(ut,{children:I.share_count||0}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ds(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",children:e.jsx(bx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",children:[e.jsxs(La,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(La,{onClick:()=>y.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(ea,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(La,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&_.mutate(I.id)},children:[e.jsx(Er,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const z4s=()=>{var f,g;const[t,s]=k.useState(""),[r,n]=k.useState(null),{data:a,isLoading:o}=pt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:y,error:_}=await H.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(_)throw _;const w=(y==null?void 0:y.map(S=>S.user_id))||[],{data:j}=await H.from("profiles").select("id, name, email").in("id",w);return y==null?void 0:y.map(S=>({...S,profiles:(j==null?void 0:j.find(M=>M.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(y=>{var w,j,N,S,M;const _=t.toLowerCase();return((j=(w=y.profiles)==null?void 0:w.name)==null?void 0:j.toLowerCase().includes(_))||((S=(N=y.profiles)==null?void 0:N.email)==null?void 0:S.toLowerCase().includes(_))||((M=y.review_text)==null?void 0:M.toLowerCase().includes(_))}),i=a!=null&&a.length?(a.reduce((y,_)=>y+_.rating,0)/a.length).toFixed(1):"0.0",c=a==null?void 0:a.reduce((y,_)=>(y[_.rating]=(y[_.rating]||0)+1,y),{}),u=(a==null?void 0:a.filter(y=>y.posted_to_google).length)||0,m=y=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(_=>e.jsx(ea,{className:Pt("h-4 w-4",y>=_?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},_))});return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{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(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Total Reviews"}),e.jsx(Lt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Average Rating"}),e.jsxs(Lt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(ea,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"5-Star Reviews"}),e.jsx(Lt,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Pe,{children:e.jsxs(Et,{className:"pb-2",children:[e.jsx(vr,{children:"Posted to Google"}),e.jsxs(Lt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(rn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or review...",value:t,onChange:y=>s(y.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Member"}),e.jsx(jt,{children:"Rating"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(jt,{children:"Google"}),e.jsx(jt,{children:"Date"})]})}),e.jsx(qn,{children:o?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(y=>{var _,w;return e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(y),children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_=y.profiles)==null?void 0:_.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=y.profiles)==null?void 0:w.email})]})}),e.jsx(ut,{children:m(y.rating)}),e.jsx(ut,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:y.review_text||"-"})}),e.jsx(ut,{children:y.posted_to_google?e.jsx(Ye,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(Ye,{variant:"outline",children:"No"})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ds(new Date(y.created_at),"MMM d, yyyy")})]},y.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(js,{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(rr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[m(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(fn,{className:"h-4 w-4"}),ds(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(Ye,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(Ye,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},B4s=[{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"}],$4s=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 q4s(){const t=Qt(),{user:s}=Fs(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:c,isLoading:u}=pt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:$,error:z}=await H.from("weekly_digest_settings").select("*").single();if(z)throw z;return $}}),{data:m,isLoading:f}=pt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:$,error:z}=await H.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(z)throw z;return $}}),{data:g}=pt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:$,error:z}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(z)throw z;return $||0}}),{data:y,refetch:_}=pt({queryKey:["digest-queue-status"],queryFn:async()=>{const $=new Date;$.setUTCHours(0,0,0,0);const[z,V,X,Y]=await Promise.all([H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",$.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",$.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",$.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",$.toISOString())]);return{pending:z.count||0,processing:V.count||0,sent:X.count||0,failed:Y.count||0,total:(z.count||0)+(V.count||0)+(X.count||0)+(Y.count||0)}},refetchInterval:5e3});k.useEffect(()=>{if(y&&(y.pending>0||y.processing>0)){const $=setInterval(()=>{_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval($)}},[y,_,t]);const{data:w=0}=pt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const $=new Date;$.setUTCHours(0,0,0,0);const{count:z,error:V}=await H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",$.toISOString());if(V)throw V;return z||0}}),j=Tt({mutationFn:async $=>{const{error:z}=await H.from("weekly_digest_settings").update($).eq("id",c==null?void 0:c.id);if(z)throw z},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:$=>{me.error("Failed to update settings: "+$.message)}}),N=async()=>{n(!0);try{const{data:$,error:z}=await H.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(z)throw z;$.queued?me.success(`${$.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):$.sent!==void 0&&me.success(`Digest sent! ${$.sent} emails delivered, ${$.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch($){me.error("Failed to send digest: "+$.message)}finally{n(!1)}},S=async()=>{var $,z,V,X,Y,J;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:Q,error:ce}=await H.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ne=Q==null?void 0:Q.resendId,re=Q==null?void 0:Q.resendDetails,oe=re==null?void 0:re.status,he=(($=re==null?void 0:re.body)==null?void 0:$.status)||((V=(z=re==null?void 0:re.body)==null?void 0:z.data)==null?void 0:V.status),xe=((Y=(X=re==null?void 0:re.body)==null?void 0:X.error)==null?void 0:Y.message)||((J=re==null?void 0:re.body)==null?void 0:J.message);me.success(ne?`Preview accepted by email provider (id: ${ne})${oe?`, status check: ${oe}`:""}${he?`, provider: ${he}`:""}${xe?` (${xe})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Q){me.error("Failed to send preview: "+Q.message)}finally{o(!1)}},M=async()=>{i(!0);try{const{data:$,error:z}=await H.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(z)throw z;$.queued===0||$.sent===0&&$.failed===0&&!$.queued?me.info("No failed emails to retry"):$.queued?me.success(`${$.queued} emails queued for retry!`):me.success(`Retry complete! ${$.sent} emails delivered, ${$.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch($){me.error("Failed to retry: "+$.message)}finally{i(!1)}},I=y!=null&&y.total?Math.round((y.sent+y.failed)/y.total*100):0,P=((y==null?void 0:y.pending)||0)>0||((y==null?void 0:y.processing)||0)>0,{data:O}=pt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var J,Q;const $=new Date;$.setUTCHours(0,0,0,0);const[z,V,X,Y]=await Promise.all([H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",$.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",$.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",$.toISOString()),H.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:z.count||0,totalFailed:V.count||0,agentOsEngaged:X.count||0,lastSent:((Q=(J=Y.data)==null?void 0:J[0])==null?void 0:Q.sent_at)||null}},refetchInterval:P?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(ga,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(el,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ss,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(co,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(bs,{value:"settings",className:"space-y-6",children:[P&&y&&e.jsx(Pe,{className:"border-primary/50 bg-primary/5",children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(ys,{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:[y.sent.toLocaleString()," sent, ",y.pending.toLocaleString()," pending",y.failed>0&&`, ${y.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(qi,{value:I,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(y.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(De,{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(ur,{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(Pe,{children:e.jsx(De,{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(Pe,{children:e.jsx(De,{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(Nc,{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(Pe,{children:e.jsx(De,{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(mn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.lastSent?ds(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(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(vr,{children:"Configure when the digest is sent"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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:$=>j.mutate({is_enabled:$})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Cron Frequency"}),e.jsxs(Rs,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:$=>j.mutate({cron_frequency:$}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(ft,{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(ye,{children:"Day of Week"}),e.jsxs(Rs,{value:String(c==null?void 0:c.send_day),onValueChange:$=>j.mutate({send_day:parseInt($)}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:B4s.map($=>e.jsx(ft,{value:$.value,children:$.label},$.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Time (UTC)"}),e.jsxs(Rs,{value:String(c==null?void 0:c.send_hour),onValueChange:$=>j.mutate({send_hour:parseInt($)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:$4s.map($=>e.jsx(ft,{value:$.value,children:$.label},$.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(G,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(G,{onClick:M,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(zo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(vr,{children:"Choose what to include in the digest"})]}),e.jsxs(De,{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(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"New Resources"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:$=>j.mutate({include_new_resources:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Community Highlights"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:$=>j.mutate({include_community_posts:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(co,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Agent OS Stats"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:$=>j.mutate({include_agent_os_stats:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Upcoming Events"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:$=>j.mutate({include_upcoming_events:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Goals Progress"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:$=>j.mutate({include_goals_progress:$})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Custom Introduction"}),e.jsx(vr,{children:"Personalize the intro message (optional)"})]}),e.jsx(De,{children:e.jsx(Tr,{placeholder:"Here's what's new this week to help you grow your business...",value:(c==null?void 0:c.custom_intro_text)||"",onChange:$=>j.mutate({custom_intro_text:$.target.value||null}),rows:3})})]})]}),e.jsx(bs,{value:"stats",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(vr,{children:"Recent digest emails sent to members"})]}),e.jsx(De,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map($=>e.jsx("div",{className:"h-12 bg-muted rounded"},$))}):m&&m.length>0?e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Email"}),e.jsx(jt,{children:"Sent At"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{children:"Resources"}),e.jsx(jt,{children:"Agent OS"})]})}),e.jsx(qn,{children:m.map($=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:$.email_sent_to}),e.jsx(ut,{children:ds(new Date($.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{children:e.jsx(Ye,{variant:$.delivery_status==="sent"?"default":"destructive",children:$.delivery_status})}),e.jsx(ut,{children:$.resources_count}),e.jsx(ut,{children:$.has_agent_os_activity?e.jsx(Ye,{variant:"secondary",children:"Active"}):e.jsx(Ye,{variant:"outline",children:"Not Started"})})]},$.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rr,{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 U4s={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 V4s(){var ge,_e,Be;const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(!0),[w,j]=k.useState(!1),[N,S]=k.useState(""),[M,I]=k.useState(null),{data:P,isLoading:O}=pt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Se,error:Ee}=await H.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ee)throw Ee;const Ae=(Se==null?void 0:Se.map(Oe=>Oe.user_id))||[],{data:Me}=await H.from("profiles").select("id, name, email").in("id",Ae),ke=new Map((Me==null?void 0:Me.map(Oe=>[Oe.id,{name:Oe.name,email:Oe.email}]))||[]);return Se==null?void 0:Se.map(Oe=>({...Oe,profile:ke.get(Oe.user_id)||null}))}}),{data:q}=pt({queryKey:["all-profiles-for-points",P],queryFn:async()=>{const Ee=[];let Ae=0;for(;;){const{data:Me,error:ke}=await H.from("profiles").select("id, name, email").order("name").range(Ae,Ae+1e3-1);if(ke)throw ke;if(Ee.push(...Me),!Me||Me.length<1e3)break;Ae+=1e3}return Ee}}),z=((q==null?void 0:q.filter(Se=>!(P!=null&&P.some(Ee=>Ee.user_id===Se.id))))||[]).filter(Se=>{var Ae,Me;if(!N)return!0;const Ee=N.toLowerCase();return((Ae=Se.name)==null?void 0:Ae.toLowerCase().includes(Ee))||((Me=Se.email)==null?void 0:Me.toLowerCase().includes(Ee))}),{data:V,isLoading:X}=pt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Se,error:Ee}=await H.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ee)throw Ee;return Se},enabled:!!(n!=null&&n.user_id)&&i}),{data:Y}=pt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Se,error:Ee}=await H.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ee)throw Ee;return Se},enabled:!!(n!=null&&n.user_id)}),J=Tt({mutationFn:async({userId:Se,points:Ee,reason:Ae})=>{const{error:Me}=await H.from("agent_points").insert({user_id:Se,points:Ee,reason:Ae});if(Me)throw Me;const{data:ke}=await H.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Se).maybeSingle(),Oe=((ke==null?void 0:ke.total_points)||0)+Ee,qe=((ke==null?void 0:ke.spendable_points)||0)+Ee,{error:ve}=await H.from("agent_attendance_stats").upsert({user_id:Se,total_points:Math.max(0,Oe),spendable_points:Math.max(0,qe),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(ve)throw ve},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),m(""),g(""),me.success(y?"Points awarded successfully!":"Points deducted successfully!")},onError:Se=>{console.error("Error modifying points:",Se),me.error("Failed to modify points")}}),Q=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const Se=parseInt(u);if(isNaN(Se)||Se<=0){me.error("Please enter a valid positive number");return}J.mutate({userId:n.user_id,points:y?Se:-Se,reason:f})},ce=()=>{if(!M||!u||!f){me.error("Please fill in all fields");return}const Se=parseInt(u);if(isNaN(Se)||Se<=0){me.error("Please enter a valid positive number");return}J.mutate({userId:M.id,points:Se,reason:f},{onSuccess:()=>{j(!1),I(null),S("")}})},ne=(Se,Ee)=>{a(Se),_(Ee),l(!0)},re=Se=>{a(Se),c(!0)},oe=P==null?void 0:P.filter(Se=>{var ke,Oe,qe,ve;const Ee=((Oe=(ke=Se.profile)==null?void 0:ke.name)==null?void 0:Oe.toLowerCase())||"",Ae=((ve=(qe=Se.profile)==null?void 0:qe.email)==null?void 0:ve.toLowerCase())||"",Me=s.toLowerCase();return Ee.includes(Me)||Ae.includes(Me)}),he=(P==null?void 0:P.reduce((Se,Ee)=>Se+Ee.total_points,0))||0,xe=(P==null?void 0:P.length)||0,ue=xe>0?Math.round(he/xe):0;return O?e.jsx(Ms,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ws,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Se=>e.jsx(ws,{className:"h-24"},Se))}),e.jsx(ws,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ur,{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:xe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_o,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:he.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Bo,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:s,onChange:Se=>r(Se.target.value),className:"pl-10"})]}),e.jsxs(G,{onClick:()=>j(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Agent Leaderboard"}),e.jsx(vr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(De,{children:!oe||oe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(_o,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-12",children:"#"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Total Points"}),e.jsx(jt,{className:"text-center",children:"Spendable"}),e.jsx(jt,{className:"text-center",children:"Events"}),e.jsx(jt,{className:"text-center",children:"Streak"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:oe.map((Se,Ee)=>{var Ae,Me,ke,Oe;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:Ee<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ee===0?"bg-yellow-100 text-yellow-700":Ee===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ee+1}):e.jsx("span",{className:"text-muted-foreground",children:Ee+1})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{children:((Me=(Ae=Se.profile)==null?void 0:Ae.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ke=Se.profile)==null?void 0:ke.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Oe=Se.profile)==null?void 0:Oe.email})]})]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),Se.total_points]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(bo,{className:"h-3 w-3 mr-1"}),Se.spendable_points||0]})}),e.jsx(ut,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(fn,{className:"h-3 w-3 text-muted-foreground"}),Se.total_events_attended]})}),e.jsx(ut,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(rh,{className:"h-3 w-3 text-orange-500"}),Se.current_streak]})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>ne(Se,!0),title:"Award points",children:e.jsx(qs,{className:"h-4 w-4 text-green-600"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>ne(Se,!1),title:"Deduct points",children:e.jsx(v0,{className:"h-4 w-4 text-red-600"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>re(Se),title:"View history",children:e.jsx(KM,{className:"h-4 w-4"})})]})})]},Se.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(js,{children:[e.jsx(vs,{children:y?"Award Points":"Deduct Points"}),e.jsxs(Gr,{children:[y?"Award":"Deduct"," points ",y?"to":"from"," ",((ge=n==null?void 0:n.profile)==null?void 0:ge.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"points",children:"Points Amount"}),e.jsx(Le,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Se=>m(Se.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"reason",children:"Reason"}),e.jsx(Tr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Se=>g(Se.target.value)})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{onClick:Q,disabled:J.isPending,className:y?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:J.isPending?"Saving...":y?"Award Points":"Deduct Points"})]})]})}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(js,{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(ga,{defaultValue:"history",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsx(ss,{value:"history",children:"Point History"}),e.jsx(ss,{value:"badges",children:"Badges"})]}),e.jsx(bs,{value:"history",className:"mt-4",children:X?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Se=>e.jsx(ws,{className:"h-12"},Se))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(KM,{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(Se=>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:Se.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ds(new Date(Se.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Ye,{variant:Se.points>=0?"default":"destructive",className:Se.points>=0?"bg-green-100 text-green-800":"",children:[Se.points>=0?"+":"",Se.points]})]},Se.id))})}),e.jsx(bs,{value:"badges",className:"mt-4",children:!Y||Y.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Y.map(Se=>e.jsxs("div",{className:`p-3 rounded-lg ${U4s[Se.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Se.badge_name})]}),Se.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Se.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ds(new Date(Se.earned_at),"MMM d, yyyy")]})]},Se.id))})})]})]})}),e.jsx(fs,{open:w,onOpenChange:Se=>{j(Se),Se||(I(null),S(""),m(""),g(""))},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(js,{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(Cn,{className:"h-10 w-10",children:e.jsx(Mn,{children:((Be=M.name)==null?void 0:Be.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(G,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Le,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Se=>m(Se.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Tr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Se=>g(Se.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:N,onChange:Se=>S(Se.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:z.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(ur,{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"})]}):z.slice(0,20).map(Se=>{var Ee;return e.jsxs("button",{onClick:()=>I(Se),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(Cn,{className:"h-8 w-8",children:e.jsx(Mn,{children:((Ee=Se.name)==null?void 0:Ee.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Se.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Se.email})]})]},Se.id)})})]})}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),M&&e.jsxs(G,{onClick:ce,disabled:J.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function H4s(){const{data:t,isLoading:s}=Zkt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState("all"),[m,f]=k.useState("newest"),[g,y]=k.useState("table"),_=k.useMemo(()=>(t==null?void 0:t.map(M=>M.user_id))||[],[t]),w=k.useMemo(()=>(t==null?void 0:t.map(M=>M.id))||[],[t]),{data:j}=pt({queryKey:["card-profiles-lookup",_],queryFn:async()=>{if(_.length===0)return{};const{data:M}=await H.from("profiles").select("id, name, email").in("id",_),I={};return M==null||M.forEach(P=>{I[P.id]={name:P.name||"",email:P.email||""}}),I},enabled:_.length>0}),{data:N}=pt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const M={};w.forEach(O=>{M[O]={views:0,leads:0}});const{data:I}=await H.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");I==null||I.forEach(O=>{M[O.card_id]&&M[O.card_id].views++});const{data:P}=await H.from("agent_card_leads").select("card_id").in("card_id",w);return P==null||P.forEach(O=>{M[O.card_id]&&M[O.card_id].leads++}),M},enabled:w.length>0}),S=k.useMemo(()=>{if(!t)return[];let M=[...t];if(c==="live"?M=M.filter(I=>I.is_published):c==="draft"&&(M=M.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();M=M.filter(P=>{var q,$;const O=j==null?void 0:j[P.user_id];return P.slug.toLowerCase().includes(I)||((q=O==null?void 0:O.name)==null?void 0:q.toLowerCase().includes(I))||(($=O==null?void 0:O.email)==null?void 0:$.toLowerCase().includes(I))})}return m==="newest"?M.sort((I,P)=>new Date(P.created_at).getTime()-new Date(I.created_at).getTime()):m==="oldest"?M.sort((I,P)=>new Date(I.created_at).getTime()-new Date(P.created_at).getTime()):m==="name"?M.sort((I,P)=>{var O,q;return(((O=j==null?void 0:j[I.user_id])==null?void 0:O.name)||"").localeCompare(((q=j==null?void 0:j[P.user_id])==null?void 0:q.name)||"")}):m==="slug"?M.sort((I,P)=>I.slug.localeCompare(P.slug)):m==="views_desc"?M.sort((I,P)=>{var O,q;return(((O=N==null?void 0:N[P.id])==null?void 0:O.views)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.views)||0)}):m==="views_asc"?M.sort((I,P)=>{var O,q;return(((O=N==null?void 0:N[I.id])==null?void 0:O.views)||0)-(((q=N==null?void 0:N[P.id])==null?void 0:q.views)||0)}):m==="leads_desc"?M.sort((I,P)=>{var O,q;return(((O=N==null?void 0:N[P.id])==null?void 0:O.leads)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.leads)||0)}):m==="leads_asc"&&M.sort((I,P)=>{var O,q;return(((O=N==null?void 0:N[I.id])==null?void 0:O.leads)||0)-(((q=N==null?void 0:N[P.id])==null?void 0:q.leads)||0)}),M},[t,c,l,m,j]);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(G,{onClick:()=>o(!0),children:[e.jsx(qs,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or slug...",value:l,onChange:M=>i(M.target.value),className:"pl-9"})]}),e.jsxs(Rs,{value:c,onValueChange:u,children:[e.jsx(Ls,{className:"w-full sm:w-36",children:e.jsx($s,{placeholder:"Status"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Status"}),e.jsx(ft,{value:"live",children:"Live"}),e.jsx(ft,{value:"draft",children:"Draft"})]})]}),e.jsxs(Rs,{value:m,onValueChange:f,children:[e.jsx(Ls,{className:"w-full sm:w-44",children:e.jsx($s,{placeholder:"Sort by"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"newest",children:"Newest First"}),e.jsx(ft,{value:"oldest",children:"Oldest First"}),e.jsx(ft,{value:"name",children:"Name A–Z"}),e.jsx(ft,{value:"slug",children:"Slug A–Z"}),e.jsx(ft,{value:"views_desc",children:"Most Views"}),e.jsx(ft,{value:"views_asc",children:"Fewest Views"}),e.jsx(ft,{value:"leads_desc",children:"Most Leads"}),e.jsx(ft,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(G,{variant:g==="table"?"default":"ghost",size:"sm",onClick:()=>y("table"),className:"rounded-r-none",children:e.jsx(rT,{className:"h-4 w-4"})}),e.jsx(G,{variant:g==="grid"?"default":"ghost",size:"sm",onClick:()=>y("grid"),className:"rounded-l-none",children:e.jsx(Tp,{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(ws,{className:"h-48"},M))}):S.length>0?g==="table"?e.jsx(G4s,{cards:S,cardProfiles:j,cardStats:N,onEdit:n,sortBy:m,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(M=>e.jsx(W4s,{card:M,onEdit:()=>n(M),stats:N==null?void 0:N[M.id]},M.id))}):t&&t.length>0?e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(sn,{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(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ur,{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(G,{onClick:()=>o(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(K4s,{open:a,onOpenChange:o}),r&&e.jsx(Z4s,{card:r,open:!!r,onOpenChange:M=>!M&&n(null)})]})}function G4s({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(Yh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(Tu,{className:"h-3 w-3"}):e.jsx(wd,{className:"h-3 w-3 opacity-40"});return e.jsx(Pe,{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(Tu,{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],m=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(Ye,{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:(m==null?void 0:m.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(m==null?void 0:m.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>n(c),className:"h-8 w-8 p-0",children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),me.success("Link copied!")},children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(G,{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(rn,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function W4s({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:m}=await H.storage.from("avatars").list(`${t.user_id}`);if(m&&m.length>0){const{data:f}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${m[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(Pe,{children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(Mn,{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(Ye,{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(Tn,{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(ur,{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(G,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Pa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(G,{variant:"outline",size:"sm",onClick:l,children:e.jsx(yi,{className:"h-3 w-3"})}),e.jsx(G,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3 w-3"})})})]})]})})}function K4s({open:t,onOpenChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(!1),m=DWe(),f=l.trim(),{data:g}=pt({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}),[y,_]=k.useState(null),w=(g==null?void 0:g.find(S=>S.id===r))||y,j=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}m.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 I;n(S),u(!1);const M=g==null?void 0:g.find(P=>P.id===S);M&&(_(M),o(((I=M.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Agent"}),e.jsxs(Vo,{open:c,onOpenChange:u,children:[e.jsx(Ho,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(Ex,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($o,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Bx,{shouldFilter:!1,children:[e.jsx($x,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(qx,{children:[e.jsx(Ux,{children:"No agents found."}),e.jsx(Vx,{children:(g||[]).map(S=>e.jsxs(_p,{value:S.id,onSelect:N,children:[e.jsx(ua,{className:Pt("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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(Le,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(G,{onClick:j,disabled:m.isPending,className:"w-full",children:m.isPending?"Creating...":"Create Card"})]})]})})}function Z4s({card:t,open:s,onOpenChange:r}){const n=OWe(),{data:a}=RWe(t.id),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[m,f]=k.useState(!1),[g,y]=k.useState(""),[_,w]=k.useState(t.slug),[j,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:X}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${X.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=z=>{var Y;const V=(Y=z.target.files)==null?void 0:Y[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 X=new FileReader;X.onloadend=()=>{y(X.result),f(!0)},X.readAsDataURL(V),z.target.value=""},P=async z=>{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(ce=>`${t.user_id}/${ce.name}`));const X=`${t.user_id}/avatar.jpg`,{error:Y}=await H.storage.from("avatars").upload(X,z,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:J}=H.storage.from("avatars").getPublicUrl(X),Q=`${J.publicUrl}?t=${Date.now()}`;i(Q),await H.from("profiles").update({avatar_url:Q}).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 z=_.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!z){me.error("Please enter a valid URL");return}if(z===t.slug){me.info("No changes to save");return}N(!0);try{const{data:V}=await H.from("agent_cards").select("id").eq("slug",z).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:X}=await H.from("agent_cards").update({slug:z}).eq("id",t.id);if(X)throw X;w(z),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{N(!1)}},q=async(z,V)=>{var Y;const X=(Y=z.target.files)==null?void 0:Y[0];if(X){if(!X.type.startsWith("image/")){me.error("Please select an image file");return}try{const J=X.name.split(".").pop()||"png",Q=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${Q}.${J}`,{error:ne}=await H.storage.from("card-logos").upload(ce,X,{upsert:!0});if(ne)throw ne;const{data:re}=H.storage.from("card-logos").getPublicUrl(ce),oe=re.publicUrl+"?t="+Date.now();M(V==="brokerage_logo_url"?he=>({...he,[V]:oe,brokerage_display_name:""}):he=>({...he,[V]:oe,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{z.target.value=""}}},$=()=>{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(js,{children:[e.jsx(vs,{children:"Edit Agent Card"}),e.jsxs(Gr,{children:["/card/",t.slug]})]}),e.jsxs(ga,{defaultValue:"content",children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ss,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ss,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ss,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ss,{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(ye,{children:"Published"}),e.jsx(qr,{checked:S.is_published,onCheckedChange:z=>M(V=>({...V,is_published:z}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(Cn,{className:"h-16 w-16",children:[e.jsx(Wa,{src:l||void 0}),e.jsx(Mn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:c}),e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:c,children:e.jsx("span",{children:c?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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(Le,{value:_,onChange:z=>w(z.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(G,{variant:"outline",size:"sm",onClick:O,disabled:j||_===t.slug,className:"shrink-0",children:j?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Theme"}),e.jsxs(Rs,{value:S.theme,onValueChange:z=>M(V=>({...V,theme:z})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(ft,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(ft,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(ft,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Title / Tagline"}),e.jsx(Le,{value:S.title,onChange:z=>M(V=>({...V,title:z.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(ye,{children:"Positioning Statement"}),e.jsx(Le,{value:S.positioning_statement,onChange:z=>M(V=>({...V,positioning_statement:z.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Bio"}),e.jsx(Tr,{value:S.bio,onChange:z=>M(V=>({...V,bio:z.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Review Snippet"}),e.jsx(Le,{value:S.review_snippet,onChange:z=>M(V=>({...V,review_snippet:z.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Review Source URL"}),e.jsx(Le,{value:S.review_source_url,onChange:z=>M(V=>({...V,review_source_url:z.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Le,{value:S.booking_url,onChange:z=>M(V=>({...V,booking_url:z.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Custom CTA Label (optional)"}),e.jsx(Le,{value:S.custom_cta_label,onChange:z=>M(V=>({...V,custom_cta_label:z.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Custom CTA URL (optional)"}),e.jsx(Le,{value:S.custom_cta_url,onChange:z=>M(V=>({...V,custom_cta_url:z.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(ye,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Le,{value:S.brokerage_display_name,onChange:z=>M(V=>({...V,brokerage_display_name:z.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(z=>({...z,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(ci,{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:z=>q(z,"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(ye,{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(Qg,{value:[S.brokerage_logo_size||56],onValueChange:([z])=>M(V=>({...V,brokerage_logo_size:z})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(ye,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Le,{value:S.team_name,onChange:z=>M(V=>({...V,team_name:z.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(z=>({...z,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(ci,{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:z=>q(z,"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(ye,{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(Qg,{value:[S.team_logo_size||56],onValueChange:([z])=>M(V=>({...V,team_logo_size:z})),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:z,label:V,hint:X})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ye,{children:V}),X&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[X," ",z==="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[z],onCheckedChange:Y=>M(J=>({...J,[z]:Y}))})]},z))}),e.jsx(bs,{value:"blocks",className:"mt-4",children:e.jsx(Klt,{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(Pe,{children:e.jsxs(De,{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(Pe,{children:e.jsxs(De,{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(Pe,{children:e.jsxs(De,{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(z=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:z.name}),z.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",z.phone]}),z.intent&&e.jsx(Ye,{variant:"secondary",className:"ml-2 text-xs",children:z.intent})]},z.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(G,{onClick:$,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(Fke,{open:m,onClose:()=>f(!1),imageSrc:g,onCropComplete:P,aspectRatio:1})]})}const CT={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"},C3e={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 M3e(t=!0){return pt({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 Y4s(){const t=Qt();return Tt({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 Q4s(){const t=Qt();return Tt({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 X4s(){const t=Qt();return Tt({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 cct(t,s=!0){return pt({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 J4s(t){return pt({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 eSs(){const t=Qt();return Tt({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 tSs(){const t=Qt();return Tt({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 sSs(){const t=Qt();return Tt({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 rSs(){const t=Qt();return Tt({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 nSs(){const t=Qt();return Tt({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 aSs(){const t=Qt();return Tt({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 iSs(){const t=Qt();return Tt({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 oSs(){const t=Qt();return Tt({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 lSs(){const t=Qt();return Tt({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 cSs(t){const{isAdmin:s}=Fs();return pt({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 dSs(){const{user:t}=Fs();return pt({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 uSs(t){return pt({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 hSs(){const t=Qt(),{user:s}=Fs();return Tt({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:m}=await H.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(m)throw m;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 mSs(){const t=Qt();return Tt({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 pSs(){const t=Qt();return Tt({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 fSs(){const t=Qt();return Tt({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 xSs(){const{data:t,isLoading:s}=M3e(!1),r=Y4s(),n=Q4s(),a=X4s(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=k.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{m({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),c(null)},g=w=>{c(w),m({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},y=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},_=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(ws,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(ws,{className:"h-12 w-full"},w))})})]}):e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:w=>{l(w),w||f()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name"}),e.jsx(Le,{id:"name",value:u.name,onChange:w=>m({...u,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",value:u.description,onChange:w=>m({...u,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Le,{id:"image_url",value:u.image_url,onChange:w=>m({...u,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Le,{id:"sort_order",type:"number",value:u.sort_order,onChange:w=>m({...u,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:u.is_active,onCheckedChange:w=>m({...u,is_active:w})}),e.jsx(ye,{htmlFor:"is_active",children:"Active"})]}),e.jsx(G,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(De,{children:t&&t.length>0?e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{children:"Sort Order"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:t.map(w=>e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium",children:w.name}),e.jsx(ut,{className:"max-w-xs truncate",children:w.description}),e.jsx(ut,{children:w.sort_order}),e.jsx(ut,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>g(w),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>_(w.id),disabled:a.isPending,children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function gSs(){var ue,ge;const{data:t,isLoading:s}=cct(void 0,!1),{data:r}=M3e(!1),n=eSs(),a=tSs(),o=sSs(),l=rSs(),i=nSs(),c=aSs(),u=iSs(),m=oSs(),f=lSs(),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState(!1),[S,M]=k.useState(null),[I,P]=k.useState(null),[O,q]=k.useState(!1),[$,z]=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,X]=k.useState({name:"",price_adjustment:0}),[Y,J]=k.useState(""),Q=()=>{z({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)},ce=_e=>{M(_e),z({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}),y(!0)},ne=async _e=>{_e.preventDefault();const Be={...$,category_id:$.category_id||null};S?await a.mutateAsync({id:S.id,...Be}):await n.mutateAsync(Be),y(!1),Q()},re=async _e=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(_e)},oe=async _e=>{if(!I||!_e.target.files||_e.target.files.length===0)return;q(!0);const Be=_e.target.files[0],Se=Be.name.split(".").pop(),Ee=`products/${I.id}/${Date.now()}.${Se}`;try{const{error:Ae}=await H.storage.from("marketplace").upload(Ee,Be);if(Ae)throw Ae;const{data:{publicUrl:Me}}=H.storage.from("marketplace").getPublicUrl(Ee);await l.mutateAsync({product_id:I.id,image_url:Me,is_primary:!I.images||I.images.length===0}),me.success("Image uploaded successfully")}catch(Ae){me.error("Failed to upload image: "+Ae.message)}finally{q(!1)}},he=async _e=>{_e.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),X({name:"",price_adjustment:0}))},xe=async()=>{!I||!Y||(await f.mutateAsync({productId:I.id,videoUrl:Y}),J(""))};return s?e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(ws,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(_e=>e.jsx(ws,{className:"h-64 w-full"},_e))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{children:"Products"}),e.jsxs(fs,{open:g,onOpenChange:_e=>{y(_e),_e||Q()},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{children:[e.jsx(qs,{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(js,{children:e.jsx(vs,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ne,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(ye,{htmlFor:"name",children:"Product Name"}),e.jsx(Le,{id:"name",value:$.name,onChange:_e=>z({...$,name:_e.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"category",children:"Category"}),e.jsxs(Rs,{value:$.category_id,onValueChange:_e=>z({...$,category_id:_e}),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select category"})}),e.jsx(Ds,{children:r==null?void 0:r.map(_e=>e.jsx(ft,{value:_e.id,children:_e.name},_e.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Tr,{id:"description",value:$.description,onChange:_e=>z({...$,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(ye,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Le,{id:"base_price",type:"number",step:"0.01",min:"0",value:$.base_price,onChange:_e=>z({...$,base_price:parseFloat(_e.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Le,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:$.shipping_fee,onChange:_e=>z({...$,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(ye,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Le,{id:"sort_order",type:"number",value:$.sort_order,onChange:_e=>z({...$,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:$.allow_artwork_upload,onCheckedChange:_e=>z({...$,allow_artwork_upload:_e})}),e.jsx(ye,{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:$.requires_proof_approval,onCheckedChange:_e=>z({...$,requires_proof_approval:_e})}),e.jsx(ye,{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:$.is_active,onCheckedChange:_e=>z({...$,is_active:_e})}),e.jsx(ye,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(G,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(De,{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 Be,Se;return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[_e.images&&_e.images.length>0?e.jsx("img",{src:((Be=_e.images.find(Ee=>Ee.is_primary))==null?void 0:Be.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(Ye,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(De,{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:((Se=_e.category)==null?void 0:Se.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(Ye,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),_e.requires_proof_approval&&e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Proof Required"}),_e.variants&&_e.variants.length>0&&e.jsxs(Ye,{variant:"outline",className:"text-xs",children:[_e.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>ce(_e),children:[e.jsx(Pa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>{P(_e),w(!0)},children:[e.jsx(p1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>{P(_e),N(!0)},children:[e.jsx(Lh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>re(_e.id),children:e.jsx(kr,{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:w,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(vs,{children:["Manage Images - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ue=I==null?void 0:I.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(Ye,{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(G,{variant:"secondary",size:"icon",onClick:async()=>{var Be;await c.mutateAsync({imageId:_e.id,productId:I.id}),P({...I,images:(Be=I.images)==null?void 0:Be.map(Se=>({...Se,is_primary:Se.id===_e.id}))})},disabled:c.isPending,title:"Set as primary",children:e.jsx(ea,{className:"h-4 w-4"})}),e.jsx(G,{variant:"destructive",size:"icon",onClick:async()=>{var Se;await i.mutateAsync({id:_e.id,productId:I.id});const Be=t==null?void 0:t.find(Ee=>Ee.id===I.id);Be&&P({...Be,images:(Se=Be.images)==null?void 0:Se.filter(Ee=>Ee.id!==_e.id)})},disabled:i.isPending,children:e.jsx(kr,{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:oe,className:"hidden",id:"image-upload",disabled:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(p1,{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(ye,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(Le,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Y,onChange:_e=>J(_e.target.value)}),e.jsxs(G,{onClick:xe,disabled:!Y,children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(I==null?void 0:I.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",I.video.video_url]})]})]})]})}),e.jsx(fs,{open:j,onOpenChange:N,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsxs(vs,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:he,className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:_e=>X({...V,name:_e.target.value}),required:!0}),e.jsx(Le,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:_e=>X({...V,price_adjustment:parseFloat(_e.target.value)||0}),className:"w-32"}),e.jsx(G,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(ge=I==null?void 0:I.variants)==null?void 0:ge.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(G,{variant:"ghost",size:"icon",onClick:()=>m.mutateAsync({id:_e.id,productId:I.id}),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]},_e.id)),(!(I!=null&&I.variants)||I.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const ySs=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function vSs(){var w,j,N;const{data:t,isLoading:s}=cSs(),r=hSs(),n=mSs(),[a,o]=k.useState(null),[l,i]=k.useState(!1),[c,u]=k.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[m,f]=k.useState(!1),g=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},y=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 I=S.target.files[0],P=I.name.split(".").pop(),O=`proofs/${a.id}/${M}/${Date.now()}.${P}`;try{const{error:q}=await H.storage.from("marketplace").upload(O,I);if(q)throw q;const{data:{publicUrl:$}}=H.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:M,proofUrl:$,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(Pe,{children:[e.jsx(Et,{children:e.jsx(ws,{className:"h-8 w-48"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(ws,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Orders"})}),e.jsx(De,{children:t&&t.length>0?e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Order #"}),e.jsx(jt,{children:"Customer"}),e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Total"}),e.jsx(jt,{children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:t.map(S=>{var M,I;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-mono",children:S.order_number}),e.jsx(ut,{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:(I=S.user)==null?void 0:I.email})]})}),e.jsx(ut,{children:ds(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(ut,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(ut,{children:e.jsx(Ye,{className:C3e[S.status],children:CT[S.status]})}),e.jsx(ut,{className:"text-right",children:e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>g(S),children:[e.jsx(Tn,{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(js,{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:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(j=a.user)==null?void 0:j.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(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(Ye,{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:m}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(G,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-4 w-4 mr-1"}),m?"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(ye,{children:"Status"}),e.jsxs(Rs,{value:c.status,onValueChange:S=>u({...c,status:S}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:ySs.map(S=>e.jsx(ft,{value:S,children:CT[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Tracking Number"}),e.jsx(Le,{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(ye,{children:"Tracking URL"}),e.jsx(Le,{value:c.trackingUrl,onChange:S=>u({...c,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Notes (optional)"}),e.jsx(Tr,{value:c.notes,onChange:S=>u({...c,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(G,{onClick:y,disabled:r.isPending,className:"w-full",children:[e.jsx(Al,{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(Ye,{variant:"outline",children:CT[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ds(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function bSs(){const[t,s]=k.useState("products"),r=ar();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(G,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ga,{value:t,onValueChange:s,children:[e.jsxs(fa,{className:"grid w-full grid-cols-3",children:[e.jsxs(ss,{value:"products",className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ss,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Bm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ss,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(bp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(bs,{value:"products",children:e.jsx(gSs,{})}),e.jsx(bs,{value:"categories",children:e.jsx(xSs,{})}),e.jsx(bs,{value:"orders",children:e.jsx(vSs,{})})]})]})})}function dct(){return pt({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 _Ss(t){return pt({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 wSs(t){return pt({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 jSs(t){return pt({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 NSs(){return pt({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 kSs(t){return pt({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 SSs(){const t=Qt();return Tt({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 CSs(){const t=Qt();return Tt({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 MSs(){const t=Qt();return Tt({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 TSs(){const t=Qt();return Tt({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 ASs(){const t=Qt();return Tt({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 ESs(){const t=Qt();return Tt({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 PSs(){const t=Qt();return Tt({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 ISs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Vye(t,s){const r=ISs(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 uct(){return pt({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 LSs(){const t=Qt();return Tt({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 DSs(){const{user:t}=Fs(),[s,r]=k.useState("items"),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(null),[w,j]=k.useState(!1),[N,S]=k.useState(null),[M,I]=k.useState(""),[P,O]=k.useState(""),[q,$]=k.useState(null),[z,V]=k.useState(""),[X,Y]=k.useState("file"),[J,Q]=k.useState(""),[ce,ne]=k.useState(""),[re,oe]=k.useState(""),[he,xe]=k.useState(!0),[ue,ge]=k.useState(null),[_e,Be]=k.useState(!1),[Se,Ee]=k.useState(!1),Ae=k.useRef(null),Me=k.useRef(null),{data:ke,isLoading:Oe}=dct(),{data:qe,isLoading:ve}=_Ss(),{data:dt,isLoading:pe}=NSs(),{data:Ue,isLoading:Xe}=uct(),et=CSs(),Ce=MSs(),Je=TSs(),Ge=ASs(),lt=ESs(),He=PSs(),We=LSs(),[tt,Ke]=k.useState({}),rt=Ft=>{Ft?(l(Ft),c(Ft.name),m(Ft.description||""),g(Ft.icon||"")):(l(null),c(""),m(""),g("")),a(!0)},it=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Ce.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:((ke==null?void 0:ke.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(Ft){console.error("Error saving category:",Ft),me.error("Failed to save category")}},It=async()=>{if(y)try{await Je.mutateAsync(y),me.success("Category deleted successfully"),_(null)}catch(Ft){console.error("Error deleting category:",Ft),me.error("Failed to delete category")}},Vt=Ft=>{var Ps;Ft?(S(Ft),I(Ft.name),O(Ft.description||""),$(Ft.category_id),V(Ft.points_cost.toString()),Y(Ft.item_type),Q(Ft.file_url||""),ne(Ft.preview_image_url||""),oe(((Ps=Ft.max_quantity)==null?void 0:Ps.toString())||""),xe(Ft.is_active)):(S(null),I(""),O(""),$(null),V(""),Y("file"),Q(""),ne(""),oe(""),xe(!0)),j(!0)},hs=async(Ft,Ps)=>{Ps==="file"?Be(!0):Ee(!0);try{const yr=Ft.name.split(".").pop(),Is=`${Date.now()}-${Math.random().toString(36).substring(7)}.${yr}`,Ar=`${Ps==="file"?"items":"previews"}/${Is}`,{error:tn}=await H.storage.from("reward-store").upload(Ar,Ft);if(tn)throw tn;const{data:{publicUrl:na}}=H.storage.from("reward-store").getPublicUrl(Ar);Ps==="file"?Q(na):ne(na),me.success("File uploaded successfully")}catch(yr){console.error("Error uploading file:",yr),me.error("Failed to upload file")}finally{Ps==="file"?Be(!1):Ee(!1)}},Es=async()=>{if(!M.trim()){me.error("Please enter an item name");return}if(!z||parseInt(z)<0){me.error("Please enter a valid points cost");return}try{const Ft={name:M,description:P||null,category_id:q,points_cost:parseInt(z),item_type:X,file_url:J||null,preview_image_url:ce||null,max_quantity:re?parseInt(re):null,current_quantity:re?parseInt(re):null,is_active:he,created_by:t==null?void 0:t.id};N?(await lt.mutateAsync({id:N.id,...Ft,current_quantity:N.max_quantity!==(re?parseInt(re):null)?re?parseInt(re):null:N.current_quantity}),me.success("Item updated successfully")):(await Ge.mutateAsync(Ft),me.success("Item created successfully")),j(!1)}catch(Ft){console.error("Error saving item:",Ft),me.error("Failed to save item")}},Ts=async()=>{if(ue)try{await He.mutateAsync(ue),me.success("Item deleted successfully"),ge(null)}catch(Ft){console.error("Error deleting item:",Ft),me.error("Failed to delete item")}},cr=async(Ft,Ps)=>{const yr=tt[Ft];if(yr===void 0||yr===Ps.toString())return;const Is=parseInt(yr);if(isNaN(Is)||Is<0){me.error("Please enter a valid positive number");return}try{await We.mutateAsync({id:Ft,points:Is}),me.success("Points updated successfully"),Ke(Ar=>{const tn={...Ar};return delete tn[Ft],tn})}catch(Ar){console.error("Error updating points:",Ar),me.error("Failed to update points")}};return Oe||ve||pe||Xe?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ws,{className:"h-8 w-64"}),e.jsx(ws,{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(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Al,{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:(qe==null?void 0:qe.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(qe==null?void 0:qe.filter(Ft=>Ft.is_active).length)||0," active"]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Bm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(ke==null?void 0:ke.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ea,{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:[qe&&qe.length>0?Math.round(qe.reduce((Ft,Ps)=>Ft+Ps.points_cost,0)/qe.length):0," pts"]})]})})]}),e.jsxs(ga,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"items",children:"Items"}),e.jsx(ss,{value:"categories",children:"Categories"}),e.jsx(ss,{value:"purchases",children:"Purchases"}),e.jsx(ss,{value:"point-settings",children:"Point Settings"})]}),e.jsx(bs,{value:"items",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Store Items"}),e.jsx(vr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(G,{onClick:()=>Vt(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(De,{children:!qe||qe.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 items yet. Add your first reward item!"})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Item"}),e.jsx(jt,{children:"Category"}),e.jsx(jt,{className:"text-center",children:"Cost"}),e.jsx(jt,{className:"text-center",children:"Type"}),e.jsx(jt,{className:"text-center",children:"Quantity"}),e.jsx(jt,{className:"text-center",children:"Status"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:qe.map(Ft=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ft.preview_image_url?e.jsx("img",{src:Ft.preview_image_url,alt:Ft.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(bo,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:Ft.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Ft.description||"No description"})]})]})}),e.jsx(ut,{children:Ft.category?e.jsx(Ye,{variant:"outline",children:Ft.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),Ft.points_cost]})}),e.jsx(ut,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Ft.item_type==="file"?e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Uo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:Ft.item_type})]})}),e.jsx(ut,{className:"text-center",children:Ft.max_quantity!==null?e.jsxs("span",{className:Ft.current_quantity===0?"text-red-500":"",children:[Ft.current_quantity,"/",Ft.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(ut,{className:"text-center",children:e.jsx(Ye,{variant:Ft.is_active?"default":"secondary",children:Ft.is_active?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Vt(Ft),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>ge(Ft.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},Ft.id))})]})})]})}),e.jsx(bs,{value:"categories",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Categories"}),e.jsx(vr,{children:"Organize your store items into categories"})]}),e.jsxs(G,{onClick:()=>rt(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(De,{children:!ke||ke.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Bm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Name"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center",children:"Items"}),e.jsx(jt,{className:"text-right",children:"Actions"})]})}),e.jsx(qn,{children:ke.map(Ft=>e.jsxs(ks,{children:[e.jsxs(ut,{className:"font-medium",children:[Ft.icon&&e.jsx("span",{className:"mr-2",children:Ft.icon}),Ft.name]}),e.jsx(ut,{className:"text-muted-foreground",children:Ft.description||"—"}),e.jsx(ut,{className:"text-center",children:(qe==null?void 0:qe.filter(Ps=>Ps.category_id===Ft.id).length)||0}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>rt(Ft),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>_(Ft.id),children:e.jsx(kr,{className:"h-4 w-4 text-destructive"})})]})})]},Ft.id))})]})})]})}),e.jsx(bs,{value:"purchases",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(bp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(vr,{children:"View all reward redemptions by agents"})]}),e.jsx(De,{children:!dt||dt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(bp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Date"}),e.jsx(jt,{children:"Agent"}),e.jsx(jt,{children:"Item"}),e.jsx(jt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(qn,{children:dt.map(Ft=>{var Ps,yr,Is,Ar;return e.jsxs(ks,{children:[e.jsx(ut,{className:"text-muted-foreground",children:ds(new Date(Ft.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(ut,{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(Zi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ps=Ft.user)==null?void 0:Ps.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((yr=Ft.user)==null?void 0:yr.email)||"—"})]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Is=Ft.item)!=null&&Is.preview_image_url?e.jsx("img",{src:Ft.item.preview_image_url,alt:Ft.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(bo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Ar=Ft.item)==null?void 0:Ar.name)||"Deleted item"})]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),Ft.points_spent]})})]},Ft.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{htmlFor:"categoryName",children:"Name"}),e.jsx(Le,{id:"categoryName",value:i,onChange:Ft=>c(Ft.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Tr,{id:"categoryDescription",value:u,onChange:Ft=>m(Ft.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Le,{id:"categoryIcon",value:f,onChange:Ft=>g(Ft.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{onClick:it,disabled:et.isPending||Ce.isPending,children:et.isPending||Ce.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:w,onOpenChange:j,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{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(ye,{htmlFor:"itemName",children:"Name *"}),e.jsx(Le,{id:"itemName",value:M,onChange:Ft=>I(Ft.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Tr,{id:"itemDescription",value:P,onChange:Ft=>O(Ft.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(ye,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Rs,{value:q||"none",onValueChange:Ft=>$(Ft==="none"?null:Ft),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select category"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No category"}),ke==null?void 0:ke.map(Ft=>e.jsxs(ft,{value:Ft.id,children:[Ft.icon&&`${Ft.icon} `,Ft.name]},Ft.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Le,{id:"itemPointsCost",type:"number",min:"0",value:z,onChange:Ft=>V(Ft.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(ye,{htmlFor:"itemType",children:"Type"}),e.jsxs(Rs,{value:X,onValueChange:Y,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"file",children:"File Download"}),e.jsx(ft,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Le,{id:"itemMaxQuantity",type:"number",min:"1",value:re,onChange:Ft=>oe(Ft.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:J,onChange:Ft=>Q(Ft.target.value),placeholder:X==="file"?"Upload a file or paste URL":"Paste external link"}),X==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(G,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ft;return(Ft=Ae.current)==null?void 0:Ft.click()},disabled:_e,children:e.jsx(ci,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ae,type:"file",className:"hidden",onChange:Ft=>{var yr;const Ps=(yr=Ft.target.files)==null?void 0:yr[0];Ps&&hs(Ps,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:ce,onChange:Ft=>ne(Ft.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(G,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ft;return(Ft=Me.current)==null?void 0:Ft.click()},disabled:Se,children:e.jsx(bl,{className:"h-4 w-4"})}),e.jsx("input",{ref:Me,type:"file",accept:"image/*",className:"hidden",onChange:Ft=>{var yr;const Ps=(yr=Ft.target.files)==null?void 0:yr[0];Ps&&hs(Ps,"preview")}})]}),ce&&e.jsx("img",{src:ce,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:he,onCheckedChange:xe}),e.jsx(ye,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(G,{onClick:Es,disabled:Ge.isPending||lt.isPending,children:Ge.isPending||lt.isPending?"Saving...":"Save"})]})]})}),e.jsx(Tc,{open:!!y,onOpenChange:()=>_(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Category"}),e.jsx(lc,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:It,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Tc,{open:!!ue,onOpenChange:()=>ge(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Item"}),e.jsx(lc,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:Ts,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Pe,{className:"mt-4",children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(el,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Lt,{children:"Point Reward Settings"}),e.jsx(vr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(De,{children:!Ue||Ue.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(el,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Action"}),e.jsx(jt,{children:"Description"}),e.jsx(jt,{className:"text-center w-32",children:"Points"}),e.jsx(jt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(qn,{children:Ue.map(Ft=>e.jsxs(ks,{children:[e.jsx(ut,{children:e.jsx("p",{className:"font-medium",children:Ft.action_name})}),e.jsx(ut,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:Ft.description})}),e.jsx(ut,{className:"text-center",children:e.jsx(Le,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:tt[Ft.id]??Ft.points.toString(),onChange:Ps=>Ke(yr=>({...yr,[Ft.id]:Ps.target.value}))})}),e.jsx(ut,{className:"text-right",children:e.jsx(G,{size:"sm",variant:"outline",disabled:tt[Ft.id]===void 0||tt[Ft.id]===Ft.points.toString()||We.isPending,onClick:()=>cr(Ft.id,Ft.points),children:e.jsx(Vc,{className:"h-4 w-4"})})})]},Ft.id))})]})})]})]})}const Vze=()=>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"})]}),Hze=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function OSs(){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:m}=pt({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}=pt({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}=pt({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}}),y=async()=>{var S;r(!0);try{const{data:M}=await H.auth.getSession(),I=(S=M==null?void 0:M.session)==null?void 0:S.access_token;if(!I)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 ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),$=await q.json();if(!q.ok||$!=null&&$.error)throw new Error(($==null?void 0:$.error)||"Failed to get authorization URL");if($!=null&&$.authUrl){localStorage.setItem("canva_code_verifier",$.codeVerifier),localStorage.setItem("canva_oauth_state",$.state);const z=window.open($.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!z){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=Y=>{var J,Q;Y.origin===window.location.origin&&(((J=Y.data)==null?void 0:J.type)==="canva-oauth-success"?(window.removeEventListener("message",V),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Q=Y.data)==null?void 0:Q.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(Y.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const X=setInterval(()=>{z.closed&&(clearInterval(X),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(M){console.error("Canva connect error:",M);const I=(M==null?void 0:M.message)||"";I.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(I||"Failed to start Canva connection"),r(!1)}},_=Tt({mutationFn:async S=>{var z;const{data:M}=await H.auth.getSession(),I=(z=M==null?void 0:M.session)==null?void 0:z.access_token;if(!I)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 ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),$=await q.json();if(!q.ok||$!=null&&$.error)throw new Error(($==null?void 0:$.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),me.success("Canva disconnected")},onError:S=>{me.error(S.message||"Failed to disconnect Canva")}}),w=Tt({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")}),j=Tt({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(Pe,{children:[e.jsx(Et,{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(Vze,{})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(Ye,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(vr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(De,{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(wi,{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(wi,{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(wi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),N?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Canva?"}),e.jsx(lc,{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(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{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(Bm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",g&&g.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:g.length})]}),n?e.jsx(Sp,{className:"h-4 w-4"}):e.jsx(Ji,{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,I;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(Ye,{variant:"outline",className:"text-xs shrink-0",children:((M=Hze.find(P=>P.value===S.folder_type))==null?void 0:M.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=S.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>j.mutate(S.id),children:e.jsx(Er,{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(G,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(G,{className:"mt-4",onClick:y,disabled:s||m,children:[s?e.jsx(zo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(Vze,{})}),"Connect Canva",e.jsx(ba,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{children:"Brokerage"}),e.jsxs(Rs,{value:i.brokerage_id,onValueChange:S=>c(M=>({...M,brokerage_id:S})),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a brokerage…"})}),e.jsx(Ds,{children:f==null?void 0:f.map(S=>e.jsx(ft,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Canva Folder ID"}),e.jsx(Le,{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(ye,{children:"Folder Display Name"}),e.jsx(Le,{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(ye,{children:"Folder Type"}),e.jsxs(Rs,{value:i.folder_type,onValueChange:S=>c(M=>({...M,folder_type:S})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:Hze.map(S=>e.jsx(ft,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Le,{placeholder:"What's in this folder?",value:i.description,onChange:S=>c(M=>({...M,description:S.target.value}))})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(G,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(zo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function RSs(){return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(dh,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(OSs,{}),e.jsx(ict,{})]})})}const FSs={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 AI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function zSs(){var X,Y,J,Q,ce;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,m]=k.useState(!1),[f,g]=k.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[y,_]=k.useState(null),[w,j]=k.useState(null),{data:N,isLoading:S}=pt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ne,error:re}=await H.from("push_notification_settings").select("*").order("setting_key");if(re)throw re;return ne}}),{data:M,isLoading:I}=pt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ne,error:re}=await H.from("push_subscriptions").select("*",{count:"exact",head:!0});if(re)throw re;return{totalSubscriptions:ne||0}}}),P=Tt({mutationFn:async({settingKey:ne,isEnabled:re})=>{const{error:oe}=await H.from("push_notification_settings").update({is_enabled:re}).eq("setting_key",ne);if(oe)throw oe},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:ne=>{me.error("Failed to update setting: "+ne.message)}}),O=k.useMemo(()=>{var ne,re;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ne=f.serviceWorker)==null?void 0:ne.activeState)??"unknown"} · sub=${(re=f.subscription)!=null&&re.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);k.useEffect(()=>{let ne=!0;const re=async()=>{var ue,ge,_e,Be,Se,Ee,Ae;const he="serviceWorker"in navigator&&"PushManager"in window,xe={isSupported:he,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ue=navigator.serviceWorker)!=null&&ue.controller)};if(!he){ne&&g(xe);return}try{const{data:Me,error:ke}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(ke)throw ke;xe.vapidPublicKey=Me==null?void 0:Me.vapidPublicKey;const qe=(await navigator.serviceWorker.getRegistrations()).find(ve=>{var pe,Ue,Xe;return(((pe=ve.active)==null?void 0:pe.scriptURL)||((Ue=ve.waiting)==null?void 0:Ue.scriptURL)||((Xe=ve.installing)==null?void 0:Xe.scriptURL)||"").includes("/sw.js")});if(qe){xe.pushWorkerScriptUrl=((ge=qe.active)==null?void 0:ge.scriptURL)||((_e=qe.waiting)==null?void 0:_e.scriptURL)||((Be=qe.installing)==null?void 0:Be.scriptURL),xe.serviceWorker={scope:qe.scope,activeState:(Se=qe.active)==null?void 0:Se.state};const ve=await qe.pushManager.getSubscription();if(ve){const dt=ve.toJSON();xe.subscription={endpoint:dt.endpoint,p256dh:(Ee=dt.keys)==null?void 0:Ee.p256dh,auth:(Ae=dt.keys)==null?void 0:Ae.auth}}}}catch(Me){xe.error=(Me==null?void 0:Me.message)||String(Me)}ne&&g(xe)};re();const oe=window.setInterval(re,4e3);return()=>{ne=!1,window.clearInterval(oe)}},[]);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(ne){me.error(`Local notification failed: ${(ne==null?void 0:ne.message)||String(ne)}`)}},$=async()=>{c(!0),_(null);try{const{data:ne,error:re}=await H.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(re)throw re;_({sent:ne==null?void 0:ne.sent,failed:ne==null?void 0:ne.failed,expiredCleaned:ne==null?void 0:ne.expiredCleaned,vapidPublicKey:ne==null?void 0:ne.vapidPublicKey}),(ne==null?void 0:ne.sent)>0?me.success(`Test notification sent to ${ne.sent} subscriber(s)`):(ne==null?void 0:ne.failed)>0?me.warning(`Notification failed for ${ne.failed} subscriber(s). ${ne.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(ne){console.error("Error sending test notification:",ne),_({error:(ne==null?void 0:ne.message)||String(ne)}),me.error("Failed to send test notification: "+(ne.message||"Unknown error"))}finally{c(!1)}},z=async()=>{m(!0),j(null);try{const{data:ne,error:re}=await H.functions.invoke("generate-vapid-keys",{body:{}});if(re)throw re;const oe=ne==null?void 0:ne.publicKey,he=ne==null?void 0:ne.privateKey;if(!oe||!he)throw new Error("generate-vapid-keys did not return keys");j({publicKey:oe,privateKey:he}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ne){console.error("Error generating VAPID keys:",ne),me.error("Failed to generate VAPID keys: "+((ne==null?void 0:ne.message)||"Unknown error"))}finally{m(!1)}},V=Tt({mutationFn:async()=>{const{error:ne}=await H.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ne)throw ne},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ne=>{me.error("Failed to clear subscriptions: "+ne.message)}});return e.jsx(Ms,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(dh,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(vr,{children:"Current active push notification subscriptions"})]}),e.jsx(De,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(M==null?void 0:M.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(el,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(vr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(De,{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(ne=>{const re=FSs[ne.setting_key]||{label:ne.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:re.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:re.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ne.description})]})]}),e.jsx(qr,{checked:ne.is_enabled,onCheckedChange:oe=>P.mutate({settingKey:ne.setting_key,isEnabled:oe}),disabled:P.isPending})]},ne.id)})})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Fm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(vr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(De,{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?AI(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: ",(X=f.serviceWorker)!=null&&X.scope?AI(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((Y=f.serviceWorker)==null?void 0:Y.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: ",(J=f.subscription)!=null&&J.endpoint?AI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Q=f.subscription)!=null&&Q.p256dh?AI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=f.subscription)!=null&&ce.auth?AI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(G,{variant:"outline",onClick:q,children:"Local notification test"}),e.jsx(G,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Le,{id:"test-title",value:s,onChange:ne=>r(ne.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Tr,{id:"test-body",value:n,onChange:ne=>a(ne.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Le,{id:"test-url",value:o,onChange:ne=>l(ne.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(G,{onClick:$,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),y&&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"}),y.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",y.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",y.sent??0," sent, ",y.failed??0," failed, ",y.expiredCleaned??0," expired cleaned"]}),y.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:y.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(kr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(vr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(De,{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(G,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(kr,{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(G,{variant:"outline",onClick:z,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function BSs(){const{toast:t}=Ra(),[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:m}=mR("presentation_count","desc"),f=m(s,{name:_=>{var w;return((w=_.name)==null?void 0:w.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:w}=await H.rpc("get_admin_presentation_stats");if(w)throw w;if(!_||_.length===0){l(!1);return}const j=_.map(P=>P.owner_user_id),{data:N,error:S}=await H.from("profiles").select("id, name, email, avatar_url").in("id",j);if(S)throw S;const M=new Map((N==null?void 0:N.map(P=>[P.id,P]))||[]),I=_.map(P=>{const O=M.get(P.owner_user_id);return{owner_user_id:P.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(P.presentation_count),total_views:Number(P.total_views),total_leads:Number(P.total_leads),total_cta_clicks:Number(P.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((P,O)=>P+O.presentation_count,0),totalViews:I.reduce((P,O)=>P+O.total_views,0),totalLeads:I.reduce((P,O)=>P+O.total_leads,0),totalCtaClicks:I.reduce((P,O)=>P+O.total_cta_clicks,0),agentsUsing:I.length})}catch(_){console.error("Error loading presentation stats:",_),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},y=[{label:"Agents Using",value:n.agentsUsing,icon:ur,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:sy,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Tn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:El,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:$m,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:y.map(_=>e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:_.label}),e.jsx(_.icon,{className:`h-4 w-4 ${_.color}`})]}),e.jsx(De,{children:o?e.jsx(ws,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:_.value.toLocaleString()})})]},_.label))}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(De,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((_,w)=>e.jsx(ws,{className:"h-12 w-full"},w))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(_l,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(_l,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(_l,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(_l,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(_l,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(_l,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(qn,{children:f.map(_=>{var j,N;const w=_.total_views>0?(_.total_leads/_.total_views*100).toFixed(1):"0.0";return e.jsxs(ks,{children:[e.jsx(ut,{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=(j=_.name)==null?void 0:j.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(ut,{className:"text-center font-medium",children:_.presentation_count}),e.jsx(ut,{className:"text-center",children:_.total_views.toLocaleString()}),e.jsx(ut,{className:"text-center",children:_.total_leads>0?e.jsx(Ye,{variant:"secondary",children:_.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:_.total_cta_clicks}),e.jsx(ut,{className:"text-center",children:e.jsxs("span",{className:Number(w)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[w,"%"]})})]},_.owner_user_id)})})]})})]})]})})}function $Ss(){const{toast:t}=Ra(),[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:m}=await H.rpc("get_admin_guest_book_stats");if(m)throw m;if(!u||u.length===0){l(!1);return}const f=u.map(j=>j.agent_id),{data:g,error:y}=await H.from("profiles").select("id, name, email, avatar_url").in("id",f);if(y)throw y;const _=new Map((g==null?void 0:g.map(j=>[j.id,j]))||[]),w=u.map(j=>{const N=_.get(j.agent_id);return{agent_id:j.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(j.open_house_count),total_visitors:Number(j.total_visitors),total_leads:Number(j.total_leads),active_count:Number(j.active_count)}});w.sort((j,N)=>N.total_visitors-j.total_visitors),r(w),a({totalOpenHouses:w.reduce((j,N)=>j+N.open_house_count,0),totalVisitors:w.reduce((j,N)=>j+N.total_visitors,0),totalLeads:w.reduce((j,N)=>j+N.total_leads,0),activeOpenHouses:w.reduce((j,N)=>j+N.active_count,0),agentsUsing:w.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},c=[{label:"Agents Using",value:n.agentsUsing,icon:ur,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:xn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:wi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Tn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:El,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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Lt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(De,{children:o?e.jsx(ws,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(De,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,m)=>e.jsx(ws,{className:"h-12 w-full"},m))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Agent"}),e.jsx(jt,{className:"text-center",children:"Open Houses"}),e.jsx(jt,{className:"text-center",children:"Active"}),e.jsx(jt,{className:"text-center",children:"Visitors"}),e.jsx(jt,{className:"text-center",children:"Leads"}),e.jsx(jt,{className:"text-center",children:"Conversion"})]})}),e.jsx(qn,{children:s.map(u=>{var f,g;const m=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(ks,{children:[e.jsx(ut,{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(ut,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(ut,{className:"text-center",children:u.active_count>0?e.jsx(Ye,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(ut,{className:"text-center",children:u.total_leads>0?e.jsx(Ye,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:e.jsxs("span",{className:Number(m)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[m,"%"]})})]},u.agent_id)})})]})})]})]})})}function qSs(){const[t]=Ul(),s=ar(),[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"),m=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:m}});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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(ys,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(wi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Nc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Lt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:e.jsx(G,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function USs(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState([]),i=k.useRef(null),{data:c,isLoading:u}=pt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:j,error:N}=await H.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return j}}),m={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(j=>j.status==="sent").length)||0,converted:(c==null?void 0:c.filter(j=>j.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(j=>j.status==="converted").length/c.length*100):0},f=Tt({mutationFn:async j=>{const{data:N,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:j}});if(S)throw S;return N},onSuccess:j=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${j.sent} email${j.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:j=>{me.error("Failed to send: "+j.message)}}),g=Tt({mutationFn:async()=>{var M,I;const{data:{user:j}}=await H.auth.getUser();if(!(j!=null&&j.email))throw new Error("Could not get your email");const{data:N,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:[{email:j.email,first_name:(I=(M=j.user_metadata)==null?void 0:M.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(S)throw S;return N},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:j=>{me.error("Failed to send test: "+j.message)}}),y=()=>{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}])},_=j=>{var M;const N=(M=j.target.files)==null?void 0:M[0];if(!N)return;const S=new FileReader;S.onload=I=>{var z,V;const O=((z=I.target)==null?void 0:z.result).split(` `).filter(X=>X.trim()),q=[],$=(V=O[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let X=$;Xce.trim().replace(/"/g,"")),J=Y[0],Q=Y[1];J&&J.includes("@")&&q.push({email:J,first_name:Q||void 0})}l(q),me.success(`${q.length} entries loaded from CSV`)},S.readAsText(N),i.current&&(i.current.value="")},w=()=>{if(o.length===0){me.error("No entries to send");return}const j=new Set((c==null?void 0:c.map(S=>S.email.toLowerCase()))||[]),N=o.filter(S=>!j.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(ys,{className:"h-3 w-3 animate-spin"}):e.jsx(rr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(De,{children:e.jsxs(ga,{defaultValue:"single",children:[e.jsxs(fa,{className:"mb-4",children:[e.jsxs(ss,{value:"single",children:[e.jsx(Fn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ss,{value:"bulk",children:[e.jsx(ci,{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(ye,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Le,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:j=>r(j.target.value),onKeyDown:j=>j.key==="Enter"&&y()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ye,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Le,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&y()})]}),e.jsxs(G,{onClick:y,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{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(G,{variant:"outline",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},className:"gap-2",children:[e.jsx(wn,{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(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(ur,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Er,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((j,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[j.email,j.first_name?` — ${j.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(G,{onClick:w,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(Fn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(vr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(De,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((j,N)=>e.jsx(ws,{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(j=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:j.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ds(new Date(j.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:j.status==="converted"?e.jsxs(Ye,{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(Ye,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.converted_at?ds(new Date(j.converted_at),"MMM d, yyyy"):"—"})]},j.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Xh,{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 Ime(t){const s=Qt(),{toast:r}=Ra(),n=pt({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=pt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const c=1e3;let u=[],m=0,f=!0;for(;f;){const{data:g,error:y}=await H.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(m,m+c-1);if(y)throw y;u=u.concat(g),f=g.length===c,m+=c}return u},enabled:!!t}),o=Tt({mutationFn:async c=>{const{data:{user:u}}=await H.auth.getUser();if(!u)throw new Error("Not authenticated");const m={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(m).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=Tt({mutationFn:async({id:c,...u})=>{const{data:m,error:f}=await H.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",c).select().single();if(f)throw f;return m},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),i=Tt({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 VSs(t){const s=Qt(),{toast:r}=Ra(),n=pt({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=Tt({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 Gze=(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 hct({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=k.useState(Gze(n,r)),c=m=>f=>i(g=>({...g,[m]:f.target.value})),u=m=>{m.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(Gze(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(js,{children:e.jsx(vs,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ga,{defaultValue:"basic",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4",children:[e.jsx(ss,{value:"basic",children:"Basic Info"}),e.jsx(ss,{value:"production",children:"Production"}),e.jsx(ss,{value:"social",children:"Social & Web"}),e.jsx(ss,{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(ye,{children:"First Name *"}),e.jsx(Le,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Last Name"}),e.jsx(Le,{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(ye,{children:"Email"}),e.jsx(Le,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(Le,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Current Brokerage"}),e.jsx(Le,{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(ye,{children:"License #"}),e.jsx(Le,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Experience (years)"}),e.jsx(Le,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Address"}),e.jsx(Le,{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(ye,{children:"City"}),e.jsx(Le,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"State"}),e.jsx(Le,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Zip"}),e.jsx(Le,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Pipeline Stage"}),e.jsxs(Rs,{value:l.stage_id,onValueChange:m=>i(f=>({...f,stage_id:m})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:r.map(m=>e.jsx(ft,{value:m.id,children:m.name},m.id))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Referred By"}),e.jsx(Le,{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(ye,{children:"Annual Production Volume"}),e.jsx(Le,{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(ye,{children:"Last Year Volume"}),e.jsx(Le,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:c("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Last Year Transactions"}),e.jsx(Le,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:c("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Avg Sale Price"}),e.jsx(Le,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:c("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Specialties / Niche"}),e.jsx(Le,{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(ye,{children:"LinkedIn URL"}),e.jsx(Le,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:c("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Website URL"}),e.jsx(Le,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Instagram Handle"}),e.jsx(Le,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Facebook URL"}),e.jsx(Le,{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(ye,{children:"Birthday"}),e.jsx(Le,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Spouse / Partner Name"}),e.jsx(Le,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Interests / Hobbies"}),e.jsx(Le,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Tr,{value:l.notes,onChange:c("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const kwe=[{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 HSs(t){return pt({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 GSs(t){return pt({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 WSs(){const t=Qt(),{toast:s}=Ra();return Tt({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 mct(){const t=Qt();return Tt({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 pct(t){return pt({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 KSs(){const t=Qt(),{toast:s}=Ra();return Tt({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 ZSs(){const t=Qt();return Tt({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 YSs({prospectId:t,prospectName:s,brokerageId:r}){var z;const{data:n=[],isLoading:a}=GSs(t),{data:o=[]}=pct(r),l=WSs(),i=B3(),c=mct(),[u,m]=k.useState("idle"),[f,g]=k.useState(0),[y,_]=k.useState(0),[w,j]=k.useState(""),[N,S]=k.useState(""),[M,I]=k.useState(!1),P=((z=o.find(V=>V.id===w))==null?void 0:z.script_text)||"",O=()=>{m("idle"),g(0),_(0),j(""),S("")},q=k.useCallback(async(V,X)=>{m("uploading");try{const Y=`Recruiting: ${s}`,{videoId:J,libraryId:Q}=await ER(Y),{uploadUrl:ce,apiKey:ne}=await PR(J),re=new XMLHttpRequest;re.upload.onprogress=Se=>{Se.lengthComputable&&g(Se.loaded/Se.total*100)},await new Promise((Se,Ee)=>{re.onload=()=>re.status>=200&&re.status<300?Se():Ee(new Error("Upload failed")),re.onerror=()=>Ee(new Error("Upload failed")),re.open("PUT",ce),re.setRequestHeader("AccessKey",ne),re.send(V)}),m("processing");let oe=0;const he=Date.now(),xe=9e4,ue=`https://iframe.mediadelivery.net/embed/${Q}/${J}`;for(;oe<4&&(await new Promise(Ee=>setTimeout(Ee,3e3)),!(Date.now()-he>xe));){const Se=await FA(J);if(oe=Se.status,_(Se.encodeProgress||0),oe===5||oe===6)throw new Error("Video processing failed")}const ge=await FA(J),_e=(ge.storageSize||V.size)/(1024*1024),Be=await i.mutateAsync({bunny_video_id:J,playback_url:ge.directPlayUrl||ue,thumbnail_url:ge.thumbnailUrl,preview_url:ge.previewUrl||null,duration_seconds:ge.length||X,file_size_mb:_e,title:Y,status:oe>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Be.id,brokerage_id:r,message:N||void 0}),m("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),O()},1500)}catch(Y){me.error(Y.message||"Failed to upload video"),m("record")}},[t,s,r,N,i,l]),$=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")||(I(V),V||O())},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>m("script"),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(js,{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(ye,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(Rs,{value:w,onValueChange:j,children:[e.jsx(Ls,{className:"mt-1",children:e.jsx($s,{placeholder:"No script — speak freely"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"none",children:"No script"}),o.map(V=>{var X;return e.jsx(ft,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(Ye,{variant:"outline",className:"text-[9px] ml-1",children:(X=kwe.find(Y=>Y.value===V.category))==null?void 0:X.label})]})},V.id)})]})]}),P&&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:P})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Tr,{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(G,{onClick:()=>m("record"),className:"w-full",children:[e.jsx(An,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(Pme,{maxDurationSeconds:300,onRecordingComplete:q,teleprompterContent:P||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(qi,{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(qi,{value:y,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(y),"%"]})]}),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(sl,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(V=>{var X,Y;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md border text-sm",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:(X=V.video)!=null&&X.thumbnail_url?e.jsx("img",{src:V.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(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:((Y=V.video)==null?void 0:Y.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(Ye,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(Ye,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Fn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(Ye,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(mn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ds(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>$(V.share_token),children:e.jsx(yi,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c.mutate({id:V.id,sent_via:"email"}),children:e.jsx(Fn,{className:"h-3 w-3"})})]})]},V.id)})})]})}function QSs(t){return pt({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).neq("status","failed").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}const Wze=[{value:"call",label:"Phone Call",icon:Nn},{value:"email",label:"Email",icon:rr},{value:"text",label:"Text Message",icon:Ki},{value:"meeting",label:"Meeting",icon:fn},{value:"note",label:"Note",icon:wn},{value:"campaign_email",label:"Campaign Email",icon:Fn}];function Xp({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 b9({label:t,url:s,icon:r}){return s?e.jsxs("a",{href:s.startsWith("http")?s:`https://${s}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(r,{className:"h-3.5 w-3.5"})," ",t," ",e.jsx(rn,{className:"h-3 w-3 opacity-50"})]}):null}function yc({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:t}),e.jsx(Le,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function fct({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=VSs((t==null?void 0:t.id)||null),{data:u=[]}=QSs((t==null?void 0:t.id)||null),[m,f]=k.useState({type:"note",title:"",description:""}),[g,y]=k.useState(!1),[_,w]=k.useState(!1),[j,N]=k.useState({});if(!t)return null;const S=()=>{var Y,J;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:((Y=t.experience_years)==null?void 0:Y.toString())||"",notes:t.notes||"",source:t.source||"",address:t.address||"",city:t.city||"",state:t.state||"",zip_code:t.zip_code||"",last_year_volume:t.last_year_volume||"",last_year_transactions:((J=t.last_year_transactions)==null?void 0:J.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||""}),w(!0)},M=()=>{const Y={id:t.id};for(const[J,Q]of Object.entries(j))J==="experience_years"||J==="last_year_transactions"?Y[J]=Q?parseInt(Q):null:Y[J]=Q||null;o(Y),w(!1)},I=()=>w(!1),P=Y=>J=>N(Q=>({...Q,[Y]:J})),O=()=>{m.title.trim()&&(c.mutate({prospect_id:t.id,activity_type:m.type,title:m.title,description:m.description||null}),f({type:"note",title:"",description:""}),y(!1))},q=s.find(Y=>Y.id===t.stage_id),$=t.address||t.city||t.state,z=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,X=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(xE,{open:n,onOpenChange:Y=>{Y||w(!1),a(Y)},children:e.jsx(P3,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Li,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(gE,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(yE,{className:"text-xl",children:[t.first_name," ",t.last_name]}),q&&e.jsx(Ye,{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(G,{variant:"ghost",size:"icon",onClick:I,children:e.jsx(Er,{className:"h-4 w-4"})}),e.jsx(G,{variant:"default",size:"icon",onClick:M,children:e.jsx(Vc,{className:"h-4 w-4"})})]}):e.jsx(G,{variant:"ghost",size:"icon",onClick:S,title:"Edit prospect",children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete prospect?"}),e.jsx(lc,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{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(rr,{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(Nn,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(aa,{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(ye,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(Rs,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(Ls,{className:"mt-1",children:e.jsx($s,{})}),e.jsx(Ds,{children:s.map(Y=>e.jsx(ft,{value:Y.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Y.color}}),Y.name]})},Y.id))})]})]}),e.jsxs(ga,{defaultValue:"details",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ss,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ss,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ss,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ss,{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(yc,{label:"First Name",value:j.first_name,onChange:P("first_name")}),e.jsx(yc,{label:"Last Name",value:j.last_name,onChange:P("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(yc,{label:"Email",value:j.email,onChange:P("email"),type:"email"}),e.jsx(yc,{label:"Phone",value:j.phone,onChange:P("phone")})]}),e.jsx(yc,{label:"Current Brokerage",value:j.current_brokerage,onChange:P("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(yc,{label:"License #",value:j.license_number,onChange:P("license_number")}),e.jsx(yc,{label:"Experience (years)",value:j.experience_years,onChange:P("experience_years"),type:"number"})]}),e.jsx(yc,{label:"Address",value:j.address,onChange:P("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(yc,{label:"City",value:j.city,onChange:P("city")}),e.jsx(yc,{label:"State",value:j.state,onChange:P("state")}),e.jsx(yc,{label:"Zip",value:j.zip_code,onChange:P("zip_code")})]}),e.jsx(yc,{label:"Source",value:j.source,onChange:P("source")}),e.jsx(yc,{label:"Referred By",value:j.referred_by,onChange:P("referred_by")}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Notes"}),e.jsx(Tr,{value:j.notes,onChange:Y=>N(J=>({...J,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(bs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(yc,{label:"Annual Production",value:j.annual_production,onChange:P("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(yc,{label:"Last Year Volume",value:j.last_year_volume,onChange:P("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(yc,{label:"Last Year Transactions",value:j.last_year_transactions,onChange:P("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(yc,{label:"Avg Sale Price",value:j.avg_sale_price,onChange:P("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(yc,{label:"Specialties / Niche",value:j.specialties,onChange:P("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(bs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(yc,{label:"LinkedIn URL",value:j.linkedin_url,onChange:P("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(yc,{label:"Website URL",value:j.website_url,onChange:P("website_url"),type:"url",placeholder:"https://..."}),e.jsx(yc,{label:"Instagram Handle",value:j.instagram_handle,onChange:P("instagram_handle"),placeholder:"@handle"}),e.jsx(yc,{label:"Facebook URL",value:j.facebook_url,onChange:P("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(bs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(yc,{label:"Birthday",value:j.birthday,onChange:P("birthday"),type:"date"}),e.jsx(yc,{label:"Spouse / Partner",value:j.spouse_name,onChange:P("spouse_name")}),e.jsx(yc,{label:"Interests / Hobbies",value:j.interests,onChange:P("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(Xp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Xp,{label:"License #",value:t.license_number}),e.jsx(Xp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Xp,{label:"Referred By",value:t.referred_by}),e.jsx(Xp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ye,{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:z?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Xp,{label:"Annual Production",value:t.annual_production}),e.jsx(Xp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Xp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Xp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Xp,{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(b9,{label:"LinkedIn",url:t.linkedin_url,icon:Ap}),e.jsx(b9,{label:"Website",url:t.website_url,icon:Nd}),t.instagram_handle&&e.jsx(b9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Pu}),e.jsx(b9,{label:"Facebook",url:t.facebook_url,icon:Au})]}):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:X?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Xp,{label:"Birthday",value:t.birthday?ds(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:bo}),e.jsx(Xp,{label:"Spouse / Partner",value:t.spouse_name,icon:Ja}),e.jsx("div",{className:"col-span-2",children:e.jsx(Xp,{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(YSs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(Qo,{}),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(G,{size:"sm",variant:"outline",onClick:()=>y(!g),children:[e.jsx(qs,{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(Rs,{value:m.type,onValueChange:Y=>f(J=>({...J,type:Y})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:Wze.map(Y=>e.jsx(ft,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(Le,{placeholder:"Subject / Title",value:m.title,onChange:Y=>f(J=>({...J,title:Y.target.value}))}),e.jsx(Tr,{placeholder:"Details (optional)",value:m.description,onChange:Y=>f(J=>({...J,description:Y.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>y(!1),children:"Cancel"}),e.jsx(G,{size:"sm",onClick:O,disabled:!m.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const Y=[...i.map(J=>({type:"manual",data:J,date:J.created_at})),...u.map(J=>({type:"campaign_email",data:J,date:J.sent_at||J.created_at}))].sort((J,Q)=>new Date(Q.date).getTime()-new Date(J.date).getTime());return Y.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):Y.map(J=>{if(J.type==="manual"){const ce=J.data,ne=Wze.find(oe=>oe.value===ce.activity_type),re=(ne==null?void 0:ne.icon)||wn;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(re,{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:ce.title}),ce.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:ce.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ds(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const Q=J.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(Fn,{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 #",Q.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Q.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[Q.status==="failed"?e.jsx(Ye,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(Fn,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),Q.opened_at?e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ds(new Date(Q.opened_at),"MMM d, h:mm a")]}):Q.status!=="failed"?e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,Q.clicked_at&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(kh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ds(new Date(Q.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ds(new Date(Q.sent_at||Q.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${Q.id}`)})})()})]})]})})})})}const XSs=["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 xct({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ra(),o=Qt(),l=k.useRef(null),[i,c]=k.useState([]),[u,m]=k.useState([]),[f,g]=k.useState({}),[y,_]=k.useState(((V=n[0])==null?void 0:V.id)||""),[w,j]=k.useState(!1),[N,S]=k.useState("upload"),[M,I]=k.useState(0),P=()=>{c([]),m([]),g({}),S("upload"),I(0)},O=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;const J=new FileReader;J.onload=ce=>{var ge;const re=((ge=ce.target)==null?void 0:ge.result).split(/\r?\n/).filter(_e=>_e.trim());if(re.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const oe=q(re[0]);m(oe);const he={},xe=new Set;oe.forEach((_e,Be)=>{const Se=_e.toLowerCase().replace(/[^a-z0-9]/g,"");let Ee=null;/^firstname$/.test(Se)||Se==="first"?Ee="first_name":/^lastname$/.test(Se)||Se==="last"?Ee="last_name":/^email$/.test(Se)||Se==="emailaddress"?Ee="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Se)?Ee="phone":/officename|currentbrokerage|brokerage|company/.test(Se)?Ee="current_brokerage":/membernumber|licensenumber|license/.test(Se)?Ee="license_number":/experienceyears|yearsexperience/.test(Se)?Ee="experience_years":/^totalvolume$|annualproduction/.test(Se)?Ee="annual_production":/^address$/.test(Se)?Ee="address":/^city$/.test(Se)?Ee="city":/^state$/.test(Se)?Ee="state":/^postalcode$|^zip$|^zipcode$/.test(Se)?Ee="zip_code":/listsidevolume|lastyearvolume/.test(Se)?Ee="last_year_volume":/^totalcount$|lastyeartransactions/.test(Se)?Ee="last_year_transactions":/avgsaleprice|averageprice/.test(Se)?Ee="avg_sale_price":/linkedin/.test(Se)?Ee="linkedin_url":/website/.test(Se)?Ee="website_url":/specialt/.test(Se)?Ee="specialties":/referr/.test(Se)?Ee="referred_by":/^notes$|^note$/.test(Se)&&(Ee="notes"),Ee&&!xe.has(Ee)&&(he[String(Be)]=Ee,xe.add(Ee))}),g(he);const ue=re.slice(1).map(_e=>{const Be=q(_e),Se={};return oe.forEach((Ee,Ae)=>{Se[String(Ae)]=Be[Ae]||""}),Se});c(ue),S("map")},J.readAsText(Y)},q=X=>{const Y=[];let J="",Q=!1;for(const ce of X)ce==='"'?Q=!Q:ce===","&&!Q?(Y.push(J.trim()),J=""):J+=ce;return Y.push(J.trim()),Y},$=async()=>{j(!0);try{const{data:{user:X}}=await H.auth.getUser();if(!X)throw new Error("Not authenticated");const Y=i.map(Q=>{const ce={brokerage_id:r,created_by:X.id,stage_id:y,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([ne,re])=>{var he;const oe=(he=Q[ne])==null?void 0:he.trim();oe&&(re==="experience_years"||re==="last_year_transactions"?ce[re]=parseInt(oe.replace(/[^0-9.-]/g,""))||null:re==="annual_production"||re==="last_year_volume"||re==="avg_sale_price"?ce[re]=oe.replace(/[^0-9.$,.-]/g,""):ce[re]=oe)}),ce});let J=0;for(let Q=0;Q{const X=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,Y=new Blob([X],{type:"text/csv"}),J=URL.createObjectURL(Y),Q=document.createElement("a");Q.href=J,Q.download="recruit-prospects-template.csv",Q.click(),URL.revokeObjectURL(J)};return e.jsx(fs,{open:t,onOpenChange:X=>{X||P(),s(X)},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(h1,{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(G,{onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},children:[e.jsx(ci,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(G,{variant:"link",className:"text-xs",onClick:z,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(Rs,{value:y,onValueChange:_,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{})}),e.jsx(Ds,{children:n.map(X=>e.jsx(ft,{value:X.id,children:X.name},X.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(jt,{className:"w-[160px]",children:"Map To"}),e.jsx(jt,{children:"Preview"})]})}),e.jsx(qn,{children:u.map((X,Y)=>{var J;return e.jsxs(ks,{children:[e.jsx(ut,{className:"font-medium text-xs",children:X}),e.jsx(ut,{children:e.jsxs(Rs,{value:f[String(Y)]||"skip",onValueChange:Q=>g(ce=>({...ce,[String(Y)]:Q==="skip"?"":Q})),children:[e.jsx(Ls,{className:"h-8 text-xs",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"skip",children:"— Skip —"}),XSs.map(Q=>e.jsx(ft,{value:Q,children:Q.replace(/_/g," ")},Q))]})]})}),e.jsx(ut,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((J=i[0])==null?void 0:J[String(Y)])||"—"})]},Y)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(ul,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>{P()},children:"Back"}),e.jsx(G,{onClick:$,disabled:w||!Object.values(f).includes("first_name"),children:w?"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(ua,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[M," prospects imported successfully!"]}),e.jsx(G,{onClick:()=>{P(),s(!1)},children:"Close"})]})]})})}function gct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ime(t),[i,c]=k.useState(!1),[u,m]=k.useState(),[f,g]=k.useState(null),[y,_]=k.useState(!1),[w,j]=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=z=>r.filter(V=>V.stage_id===z),I=(z,V)=>{S(V),z.dataTransfer.effectAllowed="move"},P=z=>{z.preventDefault(),z.dataTransfer.dropEffect="move"},O=(z,V)=>{z.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),S(null))},q=z=>{m(z),c(!0)},$=z=>{g(z),_(!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(G,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(ci,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(G,{onClick:()=>{m(void 0),c(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Li,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(z=>{const V=M(z.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:P,onDrop:X=>O(X,z.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:z.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:z.name}),e.jsx(Ye,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>q(z.id),children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:V.map(X=>e.jsx(Pe,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:z.color},draggable:!0,onDragStart:Y=>I(Y,X.id),onClick:()=>$(X),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Eu,{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(Zi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]})]}),X.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ta,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:X.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(rr,{className:"h-3 w-3 text-muted-foreground"}),X.phone&&e.jsx(Nn,{className:"h-3 w-3 text-muted-foreground"}),X.experience_years!=null&&e.jsxs(Ye,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[X.experience_years,"yr"]})]})]})]})},X.id))})]},z.id)})}),e.jsx(yue,{orientation:"horizontal"})]}),e.jsx(hct,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:z=>a.mutate(z),isSubmitting:a.isPending}),e.jsx(fct,{prospect:f,stages:s,brokerageId:t,open:y,onOpenChange:_,onUpdate:z=>{o.mutate(z),g(V=>V?{...V,...z}:null)},onDelete:z=>l.mutate(z)}),e.jsx(xct,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function fde({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ime(t),{user:i}=Fs(),c=Qt(),[u,m]=k.useState(!1),[f,g]=k.useState(null),[y,_]=k.useState(!1),[w,j]=k.useState(!1),[N,S]=k.useState(""),[M,I]=k.useState("all"),[P,O]=k.useState("all"),[q,$]=k.useState("all"),[z,V]=k.useState(null),[X,Y]=k.useState("asc"),[J,Q]=k.useState(new Set),[ce,ne]=k.useState(!1),[re,oe]=k.useState(""),he=k.useMemo(()=>{const ve=new Set;return r.forEach(dt=>{dt.current_brokerage&&ve.add(dt.current_brokerage)}),Array.from(ve).sort()},[r]),{data:xe=[]}=pt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(dt)throw dt;return ve}}),{data:ue=[]}=pt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let dt=[],pe=0;for(;;){const{data:Ue,error:Xe}=await H.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(pe,pe+1e3-1);if(Xe)throw Xe;if(dt=dt.concat(Ue??[]),!Ue||Ue.length<1e3)break;pe+=1e3}return dt}}),ge=k.useMemo(()=>{const ve=new Map;return ue.forEach(dt=>{ve.has(dt.prospect_id)||ve.set(dt.prospect_id,new Set),ve.get(dt.prospect_id).add(dt.campaign_id)}),ve},[ue]),_e=ve=>{z===ve?Y(dt=>dt==="asc"?"desc":"asc"):(V(ve),Y("asc"))},Be=({column:ve})=>z!==ve?e.jsx(wd,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):X==="asc"?e.jsx(Tu,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Yh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Se=ve=>s.find(dt=>dt.id===ve),Ee=k.useMemo(()=>{let ve=r.filter(dt=>{var Ce,Je,Ge;const pe=!N||`${dt.first_name} ${dt.last_name}`.toLowerCase().includes(N.toLowerCase())||((Ce=dt.email)==null?void 0:Ce.toLowerCase().includes(N.toLowerCase()))||((Je=dt.current_brokerage)==null?void 0:Je.toLowerCase().includes(N.toLowerCase())),Ue=M==="all"||dt.stage_id===M,Xe=P==="all"||dt.current_brokerage===P;let et=!0;return q==="in_campaign"?et=ge.has(dt.id):q==="not_in_campaign"?et=!ge.has(dt.id):q!=="all"&&(et=((Ge=ge.get(dt.id))==null?void 0:Ge.has(q))??!1),pe&&Ue&&Xe&&et});return z&&(ve=[...ve].sort((dt,pe)=>{var Ce,Je;let Ue=null,Xe=null;switch(z){case"name":Ue=`${dt.first_name} ${dt.last_name||""}`.toLowerCase(),Xe=`${pe.first_name} ${pe.last_name||""}`.toLowerCase();break;case"stage":Ue=((Ce=Se(dt.stage_id))==null?void 0:Ce.sort_order)??999,Xe=((Je=Se(pe.stage_id))==null?void 0:Je.sort_order)??999;break;case"brokerage":Ue=(dt.current_brokerage||"").toLowerCase(),Xe=(pe.current_brokerage||"").toLowerCase();break;case"experience":Ue=dt.experience_years??-1,Xe=pe.experience_years??-1;break;case"production":Ue=(dt.annual_production||"").toLowerCase(),Xe=(pe.annual_production||"").toLowerCase();break;case"source":Ue=(dt.source||"").toLowerCase(),Xe=(pe.source||"").toLowerCase();break;default:return 0}if(Ue===Xe)return 0;if(Ue==null)return 1;if(Xe==null)return-1;const et=Ue0&&Ee.every(ve=>J.has(ve.id)),Me=Ee.some(ve=>J.has(ve.id)),ke=()=>{Q(Ae?new Set:new Set(Ee.map(ve=>ve.id)))},Oe=ve=>{Q(dt=>{const pe=new Set(dt);return pe.has(ve)?pe.delete(ve):pe.add(ve),pe})},qe=Tt({mutationFn:async()=>{if(!re||!(i!=null&&i.id))throw new Error("Select a campaign");const ve=new Set(ue.filter(Ue=>Ue.campaign_id===re).map(Ue=>Ue.prospect_id)),dt=Array.from(J).filter(Ue=>!ve.has(Ue)).map(Ue=>({prospect_id:Ue,campaign_id:re,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(dt.length===0)throw new Error("All selected prospects are already in this campaign");const{error:pe}=await H.from("recruit_campaign_assignments").insert(dt);if(pe)throw pe;return dt.length},onSuccess:ve=>{me.success(`${ve} prospect(s) added to campaign`),ne(!1),Q(new Set),oe(""),c.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:ve=>me.error(ve.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(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search prospects...",value:N,onChange:ve=>S(ve.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[J.size>0&&e.jsxs(G,{variant:"secondary",onClick:()=>ne(!0),className:"gap-1.5",children:[e.jsx(Fn,{className:"h-4 w-4"})," Add ",J.size," to Campaign"]}),e.jsxs(G,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(ci,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(G,{onClick:()=>m(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(ty,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Rs,{value:M,onValueChange:I,children:[e.jsx(Ls,{className:"w-[160px] h-8 text-xs",children:e.jsx($s,{placeholder:"All stages"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All stages"}),s.map(ve=>e.jsx(ft,{value:ve.id,children:ve.name},ve.id))]})]}),e.jsxs(Rs,{value:P,onValueChange:O,children:[e.jsxs(Ls,{className:"w-[200px] h-8 text-xs",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx($s,{placeholder:"All brokerages"})]}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All brokerages"}),he.map(ve=>e.jsx(ft,{value:ve,children:ve},ve))]})]}),e.jsxs(Rs,{value:q,onValueChange:$,children:[e.jsxs(Ls,{className:"w-[200px] h-8 text-xs",children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx($s,{placeholder:"Campaign status"})]}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All contacts"}),e.jsx(ft,{value:"in_campaign",children:"In any campaign"}),e.jsx(ft,{value:"not_in_campaign",children:"Not in any campaign"}),xe.map(ve=>e.jsxs(ft,{value:ve.id,children:["In: ",ve.name]},ve.id))]})]}),(M!=="all"||P!=="all"||q!=="all")&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{I("all"),O("all"),$("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{className:"w-[40px]",children:e.jsx(Mo,{checked:Ae,onCheckedChange:ke,"aria-label":"Select all",...Me&&!Ae?{"data-state":"indeterminate"}:{}})}),e.jsx(jt,{className:"cursor-pointer select-none",onClick:()=>_e("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Be,{column:"name"})]})}),e.jsx(jt,{className:"cursor-pointer select-none",onClick:()=>_e("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Be,{column:"stage"})]})}),e.jsx(jt,{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(Be,{column:"brokerage"})]})}),e.jsx(jt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(jt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>_e("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Be,{column:"experience"})]})}),e.jsx(jt,{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(Be,{column:"production"})]})}),e.jsx(jt,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(jt,{className:"w-[50px]"})]})}),e.jsx(qn,{children:Ee.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Ee.map(ve=>{const dt=Se(ve.stage_id),pe=ge.get(ve.id),Ue=(pe==null?void 0:pe.size)??0;return e.jsxs(ks,{className:"cursor-pointer",onClick:()=>{g(ve),_(!0)},children:[e.jsx(ut,{onClick:Xe=>Xe.stopPropagation(),children:e.jsx(Mo,{checked:J.has(ve.id),onCheckedChange:()=>Oe(ve.id),"aria-label":`Select ${ve.first_name}`})}),e.jsxs(ut,{className:"font-medium",children:[ve.first_name," ",ve.last_name]}),e.jsx(ut,{children:dt?e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:dt.color,color:dt.color,backgroundColor:`${dt.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:dt.color}}),dt.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:ve.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:ve.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ve.email&&e.jsx(rr,{className:"h-3.5 w-3.5 text-muted-foreground"}),ve.phone&&e.jsx(Nn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!ve.email&&!ve.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(ut,{className:"hidden lg:table-cell",children:ve.experience_years!=null?`${ve.experience_years} yr`:"—"}),e.jsx(ut,{className:"hidden lg:table-cell",children:ve.annual_production||"—"}),e.jsx(ut,{className:"hidden lg:table-cell",children:Ue>0?e.jsxs(Ye,{variant:"secondary",className:"text-xs",children:[Ue," campaign",Ue>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(ut,{children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:Xe=>{Xe.stopPropagation(),l.mutate(ve.id)},children:e.jsx(kr,{className:"h-3.5 w-3.5"})})})]},ve.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[J.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[J.size," selected · "]}),Ee.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ce,onOpenChange:ne,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(js,{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:J.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Campaign"}),e.jsxs(Rs,{value:re,onValueChange:oe,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a campaign..."})}),e.jsx(Ds,{children:xe.map(ve=>e.jsxs(ft,{value:ve.id,children:[ve.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",ve.warmth_level,")"]})]},ve.id))})]})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(G,{onClick:()=>qe.mutate(),disabled:!re||qe.isPending,children:qe.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(hct,{open:u,onOpenChange:m,stages:s,onSubmit:ve=>a.mutate(ve),isSubmitting:a.isPending}),e.jsx(fct,{prospect:f,stages:s,brokerageId:t,open:y,onOpenChange:_,onUpdate:ve=>{o.mutate(ve),g(dt=>dt?{...dt,...ve}:null)},onDelete:ve=>l.mutate(ve)}),e.jsx(xct,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function yct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=Ime(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",m=new Date,f=o>0?Math.round(r.reduce((N,S)=>N+dy(m,new Date(S.created_at)),0)/o):0,g=s.map(N=>({...N,count:r.filter(S=>S.stage_id===N.id).length})),y={};r.forEach(N=>{const S=N.source||"unknown";y[S]=(y[S]||0)+1});const _=Object.entries(y).sort((N,S)=>S[1]-N[1]),w=new Date;w.setDate(w.getDate()-30);const j=r.filter(N=>new Date(N.created_at)>=w).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:g,bySrc:_,recentCount:j}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(De,{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(ur,{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(Pe,{children:e.jsx(De,{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(Bo,{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(Pe,{children:e.jsx(De,{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(mn,{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(Pe,{children:e.jsx(De,{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(Xh,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(De,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(De,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ye,{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 Kze=[{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 vct({brokerageId:t}){const{toast:s}=Ra(),[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(Kze.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(rr,{className:"h-4 w-4"})," ",c]}),Kze.filter(u=>u.category===c).map(u=>e.jsxs(Pe,{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(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(Ye,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(De,{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(G,{size:"sm",variant:"outline",onClick:m=>{m.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ua,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(G,{size:"sm",onClick:m=>{m.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(ua,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const Zze={call:Nn,email:rr,text:Ki,meeting:fn,note:wn};function bct({brokerageId:t}){const{data:s,isLoading:r}=pt({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(y=>y.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(y=>y.created_by),...(l||[]).map(y=>y.created_by)])],{data:u}=await H.from("profiles").select("id, name, email").in("id",c),m=Object.fromEntries((u||[]).map(y=>[y.id,y])),f=kie(new Date,30);return{recruiters:c.map(y=>{var S,M;const _=(l||[]).filter(I=>I.created_by===y),w=_.filter(I=>new Date(I.created_at)>=f),j={};w.forEach(I=>{j[I.activity_type]=(j[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===y).length;return{id:y,name:((S=m[y])==null?void 0:S.name)||"Unknown",email:((M=m[y])==null?void 0:M.email)||"",totalActivities:_.length,recentActivities:w.length,byType:j,prospectsCreated:N}}).sort((y,_)=>_.recentActivities-y.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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(De,{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(Zi,{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=Zze[o]||wn;return e.jsxs(Ye,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Recent Activity"})}),e.jsx(De,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=Zze[n.activity_type]||wn;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:ds(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 _ct({brokerageId:t}){const{toast:s}=Ra(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=pt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:j,error:N}=await H.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return j}}),u=[...new Set(i.map(j=>j.referred_by))],{data:m=[]}=pt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:j}=await H.from("profiles").select("id, name, email").in("id",u);return j||[]},enabled:u.length>0}),f=Object.fromEntries(m.map(j=>[j.id,j])),g=Tt({mutationFn:async j=>{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:j.first_name,referee_last_name:j.last_name||null,referee_email:j.email||null,referee_phone:j.phone||null,referee_current_brokerage:j.current_brokerage||null,notes:j.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),y=Tt({mutationFn:async({id:j,status:N,incentive_status:S})=>{const M={updated_at:new Date().toISOString()};N&&(M.status=N),S&&(M.incentive_status=S);const{error:I}=await H.from("recruit_referrals").update(M).eq("id",j);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),_=j=>j==="approved"||j==="signed"?e.jsx(ua,{className:"h-3 w-3"}):j==="rejected"?e.jsx(Nc,{className:"h-3 w-3"}):e.jsx(mn,{className:"h-3 w-3"}),w=j=>j==="approved"||j==="signed"||j==="paid"?"bg-green-500/10 text-green-600 border-green-200":j==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return 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(G,{onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Pe,{className:"py-12 text-center",children:[e.jsx(El,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(j=>{var N;return e.jsx(Pe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[j.referee_first_name," ",j.referee_last_name]}),e.jsxs(Ye,{variant:"outline",className:w(j.status),children:[_(j.status)," ",j.status]}),j.incentive_status&&e.jsxs(Ye,{variant:"outline",className:w(j.incentive_status),children:[e.jsx(bo,{className:"h-3 w-3 mr-1"})," ",j.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[j.referee_email&&e.jsx("p",{children:j.referee_email}),j.referee_phone&&e.jsx("p",{children:j.referee_phone}),j.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",j.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=f[j.referred_by])==null?void 0:N.name)||"Unknown"," • ",ds(new Date(j.created_at),"MMM d, yyyy")]})]}),j.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:j.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Rs,{value:j.status,onValueChange:S=>y.mutate({id:j.id,status:S}),children:[e.jsx(Ls,{className:"h-7 text-xs w-[110px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"pending",children:"Pending"}),e.jsx(ft,{value:"contacted",children:"Contacted"}),e.jsx(ft,{value:"approved",children:"Approved"}),e.jsx(ft,{value:"signed",children:"Signed"}),e.jsx(ft,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(Rs,{value:j.incentive_status||"pending",onValueChange:S=>y.mutate({id:j.id,incentive_status:S}),children:[e.jsx(Ls,{className:"h-7 text-xs w-[100px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"pending",children:"Unpaid"}),e.jsx(ft,{value:"paid",children:"Paid"}),e.jsx(ft,{value:"n/a",children:"N/A"})]})]})]})]})},j.id)})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:j=>{j.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(ye,{children:"First Name *"}),e.jsx(Le,{required:!0,value:o.first_name,onChange:j=>l(N=>({...N,first_name:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Last Name"}),e.jsx(Le,{value:o.last_name,onChange:j=>l(N=>({...N,last_name:j.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Email"}),e.jsx(Le,{type:"email",value:o.email,onChange:j=>l(N=>({...N,email:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(Le,{value:o.phone,onChange:j=>l(N=>({...N,phone:j.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Current Brokerage"}),e.jsx(Le,{value:o.current_brokerage,onChange:j=>l(N=>({...N,current_brokerage:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Tr,{value:o.notes,onChange:j=>l(N=>({...N,notes:j.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:g.isPending,children:"Submit"})]})]})]})})]})}function wct({brokerageId:t}){const{toast:s}=Ra(),r=Qt(),[n,a]=k.useState(!1),{data:o}=pt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:g,error:y}=await H.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(y)throw y;return g}}),{data:l=[]}=pt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:g,error:y}=await H.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(y)throw y;return g}}),i=Tt({mutationFn:async g=>{const{error:y}=await H.from("brokerages").update({recruit_form_enabled:g}).eq("id",t);if(y)throw y},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),c=Tt({mutationFn:async({id:g,status:y})=>{const{error:_}=await H.from("recruit_interest_submissions").update({status:y}).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)||""}`,m=()=>{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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(G,{size:"sm",variant:"outline",onClick:m,children:n?e.jsx(ua,{className:"h-3.5 w-3.5"}):e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(G,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(De,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(El,{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(Ye,{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(rr,{className:"h-3 w-3"}),g.email]}),g.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{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:ds(new Date(g.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Rs,{value:g.status,onValueChange:y=>c.mutate({id:g.id,status:y}),children:[e.jsx(Ls,{className:"h-7 text-xs w-[110px]",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"new",children:"New"}),e.jsx(ft,{value:"contacted",children:"Contacted"}),e.jsx(ft,{value:"converted",children:"Converted"}),e.jsx(ft,{value:"dismissed",children:"Dismissed"})]})]})]},g.id))})})]})]})}function jct({brokerageId:t}){const{toast:s}=Ra(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({prospect_id:"",title:"",description:"",due_date:ds(Ll(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=k.useState("pending"),{data:u=[]}=pt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:P,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 P}}),{data:m=[],isLoading:f}=pt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const P=u.map($=>$.id);if(!P.length)return[];const{data:O,error:q}=await H.from("recruit_follow_ups").select("*").in("prospect_id",P).order("due_date");if(q)throw q;return O},enabled:u.length>0}),g=Object.fromEntries(u.map(P=>[P.id,P])),y=Tt({mutationFn:async P=>{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:P.prospect_id,assigned_to:O.id,title:P.title,description:P.description||null,due_date:new Date(P.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:ds(Ll(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:P=>s({title:"Error",description:P.message,variant:"destructive"})}),_=Tt({mutationFn:async({id:P,completed:O})=>{const{error:q}=await H.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",P);if(q)throw q},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=m.filter(P=>i==="pending"?!P.completed_at:i==="completed"?!!P.completed_at:!0),j=w.filter(P=>!P.completed_at&&M0(new Date(P.due_date))&&!Nu(new Date(P.due_date))),N=w.filter(P=>!P.completed_at&&Nu(new Date(P.due_date))),S=w.filter(P=>!P.completed_at&&!M0(new Date(P.due_date))&&!Nu(new Date(P.due_date))),M=w.filter(P=>!!P.completed_at),I=P=>{const O=g[P.prospect_id],q=!P.completed_at&&M0(new Date(P.due_date))&&!Nu(new Date(P.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Mo,{checked:!!P.completed_at,onCheckedChange:$=>_.mutate({id:P.id,completed:$}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${P.completed_at?"line-through text-muted-foreground":""}`,children:P.title}),P.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:P.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(Ye,{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(ul,{className:"h-3 w-3"}):e.jsx(fn,{className:"h-3 w-3"}),ds(new Date(P.due_date),"MMM d, h:mm a")]}),P.is_automated&&e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},P.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(P=>e.jsxs(G,{size:"sm",variant:i===P?"default":"outline",onClick:()=>c(P),className:"capitalize text-xs",children:[P," ",P==="pending"&&j.length+N.length+S.length>0&&`(${j.length+N.length+S.length})`]},P))}),e.jsxs(G,{size:"sm",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(ul,{className:"h-3.5 w-3.5"})," Overdue (",j.length,")"]}),j.map(I)]}),i!=="completed"&&N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(mn,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(fn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(I)]}),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(ua,{className:"h-3.5 w-3.5"})," Completed (",M.length,")"]}),M.map(I)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:P=>{P.preventDefault(),y.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ye,{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:P=>l(O=>({...O,prospect_id:P.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(P=>e.jsxs("option",{value:P.id,children:[P.first_name," ",P.last_name]},P.id))]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Task *"}),e.jsx(Le,{required:!0,value:o.title,onChange:P=>l(O=>({...O,title:P.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Details"}),e.jsx(Tr,{value:o.description,onChange:P=>l(O=>({...O,description:P.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Due Date *"}),e.jsx(Le,{type:"datetime-local",required:!0,value:o.due_date,onChange:P=>l(O=>({...O,due_date:P.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:y.isPending,children:"Schedule"})]})]})]})})]})}const JSs=[{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 Nct({brokerageId:t}){const{toast:s}=Ra(),r=Qt(),[n,a]=k.useState(null),{data:o,isLoading:l}=pt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:j,error:N}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return j}}),[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:JSs,testimonials:[],gallery_images:[],calculator_enabled:!1,calculator_config:{headline:"See What You Could Earn With Us",subtext:"Confidential 60-second calculator — no signup required.",commission_split_pct:80,cap_amount:16e3,monthly_fee:99,transaction_fee:0,show_email_capture:!0,email_capture_label:"Want the full breakdown? Enter your email."},lead_magnet_enabled:!1,lead_magnet_config:{title:"Get the Full Comp Plan PDF",description:"See exactly how splits, caps, and fees work — no call required.",button_text:"Email Me the PDF",pdf_url:null},form_style:"classic",confidential_messaging:!0});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||[],calculator_enabled:o.calculator_enabled??!1,calculator_config:o.calculator_config||{},lead_magnet_enabled:o.lead_magnet_enabled??!1,lead_magnet_config:o.lead_magnet_config||{},form_style:o.form_style||"classic",confidential_messaging:o.confidential_messaging??!0})},[o]);const u=Tt({mutationFn:async()=>{const j={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),calculator_enabled:i.calculator_enabled,calculator_config:JSON.parse(JSON.stringify(i.calculator_config)),lead_magnet_enabled:i.lead_magnet_enabled,lead_magnet_config:JSON.parse(JSON.stringify(i.lead_magnet_config)),form_style:i.form_style,confidential_messaging:i.confidential_messaging,updated_at:new Date().toISOString()};if(i.id){const{error:N}=await H.from("recruit_landing_page_settings").update(j).eq("id",i.id);if(N)throw N}else{const{error:N}=await H.from("recruit_landing_page_settings").insert(j);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),m=async(j,N)=>{const S=j.name.split(".").pop(),M=`${t}/${N}-${Date.now()}.${S}`,{error:I}=await H.storage.from("recruit-landing").upload(M,j);if(I)throw I;const{data:{publicUrl:P}}=H.storage.from("recruit-landing").getPublicUrl(M);return P},f=async(j,N)=>{var M;const S=(M=j.target.files)==null?void 0:M[0];if(S){a(N);try{const I=await m(S,N);c(P=>({...P,[N]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},g=async j=>{var S;const N=(S=j.target.files)==null?void 0:S[0];if(N){a("gallery");try{const M=await m(N,"gallery");c(I=>({...I,gallery_images:[...I.gallery_images,M]})),s({title:"Gallery image added!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}},y=async(j,N)=>{var M;const S=(M=j.target.files)==null?void 0:M[0];if(S){a(`testimonial-${N}`);try{const I=await m(S,`testimonial-${N}`);c(P=>{const O=[...P.testimonials];return O[N]={...O[N],photo_url:I},{...P,testimonials:O}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:_}=pt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:j,error:N}=await H.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return j}}),w=`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:w}),e.jsx(G,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Branding"})}),e.jsx(De,{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(ye,{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(G,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:j=>c(N=>({...N,primary_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:i.primary_color,onChange:j=>c(N=>({...N,primary_color:j.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:j=>c(N=>({...N,accent_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:i.accent_color,onChange:j=>c(N=>({...N,accent_color:j.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Hero Section"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Headline"}),e.jsx(Le,{value:i.hero_headline,onChange:j=>c(N=>({...N,hero_headline:j.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Subtext"}),e.jsx(Tr,{value:i.hero_subtext,onChange:j=>c(N=>({...N,hero_subtext:j.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(ye,{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(G,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"hero_image_url")})]}),i.hero_image_url&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(j=>({...j,hero_image_url:null})),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,benefits:[...j.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(De,{className:"space-y-3",children:[i.benefits.map((j,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Eu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Le,{value:j.icon,onChange:S=>{const M=[...i.benefits];M[N]={...j,icon:S.target.value},c(I=>({...I,benefits:M}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Le,{value:j.title,onChange:S=>{const M=[...i.benefits];M[N]={...j,title:S.target.value},c(I=>({...I,benefits:M}))},placeholder:"Benefit title"}),e.jsx(Le,{value:j.description,onChange:S=>{const M=[...i.benefits];M[N]={...j,description:S.target.value},c(I=>({...I,benefits:M}))},placeholder:"Short description"})]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(S=>({...S,benefits:S.benefits.filter((M,I)=>I!==N)})),children:e.jsx(kr,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{className:"text-base",children:"Testimonials"}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,testimonials:[...j.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(De,{className:"space-y-3",children:[i.testimonials.map((j,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:[j.photo_url?e.jsx("img",{src:j.photo_url,alt:j.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=j.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:M=>y(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(Le,{value:j.name,onChange:M=>{const I=[...i.testimonials];I[N]={...j,name:M.target.value},c(P=>({...P,testimonials:I}))},placeholder:"Name"}),e.jsx(Le,{value:j.role,onChange:M=>{const I=[...i.testimonials];I[N]={...j,role:M.target.value},c(P=>({...P,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Tr,{value:j.quote,onChange:M=>{const I=[...i.testimonials];I[N]={...j,quote:M.target.value},c(P=>({...P,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(M=>({...M,testimonials:M.testimonials.filter((I,P)=>P!==N)})),children:e.jsx(kr,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(bl,{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(De,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((j,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Gallery ${N+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(G,{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,I)=>I!==N)})),children:e.jsx(kr,{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.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-primary"})," Form Style & Trust"]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Application Form Style"}),e.jsxs(Rs,{value:i.form_style,onValueChange:j=>c(N=>({...N,form_style:j})),children:[e.jsx(Ls,{className:"mt-1.5",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"classic",children:"Classic — single-page form (all fields visible)"}),e.jsx(ft,{value:"multi_step",children:"Multi-Step Wizard — 3-step soft CTA (recommended)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"Multi-step wizards convert ~30% better than single long forms."})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(zd,{className:"h-4 w-4 mt-0.5 text-primary"}),e.jsxs("div",{children:[e.jsx(ye,{children:"Show Confidentiality Badges"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Adds "100% Confidential" + "No spam" trust signals around the form.'})]})]}),e.jsx(qr,{checked:i.confidential_messaging,onCheckedChange:j=>c(N=>({...N,confidential_messaging:j}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(rS,{className:"h-4 w-4 text-primary"})," Split & Income Calculator"]}),e.jsx(qr,{checked:i.calculator_enabled,onCheckedChange:j=>c(N=>({...N,calculator_enabled:j}))})]}),i.calculator_enabled&&e.jsxs(De,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Highest-converting recruiting tool. Agents enter their GCI and instantly see what they'd earn at your brokerage."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Calculator Headline"}),e.jsx(Le,{value:i.calculator_config.headline||"",onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,headline:j.target.value}})),placeholder:"See What You Could Earn With Us"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Subtext"}),e.jsx(Le,{value:i.calculator_config.subtext||"",onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,subtext:j.target.value}})),placeholder:"Confidential 60-second calculator"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Your Split %"}),e.jsx(Le,{type:"number",value:i.calculator_config.commission_split_pct??80,onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,commission_split_pct:parseFloat(j.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Agent keeps"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Cap Amount ($)"}),e.jsx(Le,{type:"number",value:i.calculator_config.cap_amount??16e3,onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,cap_amount:parseFloat(j.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Annual cap"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Monthly Fee ($)"}),e.jsx(Le,{type:"number",value:i.calculator_config.monthly_fee??99,onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,monthly_fee:parseFloat(j.target.value)||0}}))})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Per-Txn Fee ($)"}),e.jsx(Le,{type:"number",value:i.calculator_config.transaction_fee??0,onChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,transaction_fee:parseFloat(j.target.value)||0}}))})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm",children:"Capture email at end of calculator"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After seeing results, agents can request a full breakdown via email."})]}),e.jsx(qr,{checked:i.calculator_config.show_email_capture!==!1,onCheckedChange:j=>c(N=>({...N,calculator_config:{...N.calculator_config,show_email_capture:j}}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(oS,{className:"h-4 w-4 text-primary"})," Lead Magnet (Gated PDF)"]}),e.jsx(qr,{checked:i.lead_magnet_enabled,onCheckedChange:j=>c(N=>({...N,lead_magnet_enabled:j}))})]}),i.lead_magnet_enabled&&e.jsxs(De,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Captures emails from agents not ready to talk. Offer a comp plan PDF, recruiting deck, or guide."}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Title"}),e.jsx(Le,{value:i.lead_magnet_config.title||"",onChange:j=>c(N=>({...N,lead_magnet_config:{...N.lead_magnet_config,title:j.target.value}})),placeholder:"Get the Full Comp Plan PDF"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Description"}),e.jsx(Tr,{rows:2,value:i.lead_magnet_config.description||"",onChange:j=>c(N=>({...N,lead_magnet_config:{...N.lead_magnet_config,description:j.target.value}})),placeholder:"See exactly how splits, caps, and fees work..."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Button Text"}),e.jsx(Le,{value:i.lead_magnet_config.button_text||"",onChange:j=>c(N=>({...N,lead_magnet_config:{...N.lead_magnet_config,button_text:j.target.value}})),placeholder:"Email Me the PDF"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"PDF / File URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Le,{value:i.lead_magnet_config.pdf_url||"",onChange:j=>c(N=>({...N,lead_magnet_config:{...N.lead_magnet_config,pdf_url:j.target.value||null}})),placeholder:"https://...",className:"flex-1"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:n==="lead_magnet_pdf",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),n==="lead_magnet_pdf"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"application/pdf,.pdf,.doc,.docx",className:"hidden",onChange:async j=>{var S;const N=(S=j.target.files)==null?void 0:S[0];if(N){a("lead_magnet_pdf");try{const M=await m(N,"lead-magnet");c(I=>({...I,lead_magnet_config:{...I.lead_magnet_config,pdf_url:M}})),s({title:"PDF uploaded!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}}})]})]})]})]})]})]}),e.jsx(e3s,{brokerageId:t}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(G,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function e3s({brokerageId:t}){const{data:s=[]}=pt({queryKey:["lead-magnet-downloads",t],queryFn:async()=>{const{data:r,error:n}=await H.from("recruit_lead_magnet_downloads").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(100);if(n)throw n;return r}});return s.length===0?null:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4 text-primary"})," Lead Magnet Downloads (",s.length,")"]})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:s.map(r=>e.jsx("div",{className:"flex items-center justify-between gap-3 p-2.5 border rounded-lg text-sm",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium truncate",children:[r.first_name||"—"," · ",r.email]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[ds(new Date(r.created_at),"MMM d, yyyy h:mm a")," · via ",r.source]})]})},r.id))})})]})}function t3s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function s3s({video:t}){return t.cta_clicked_at?e.jsx(Ye,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(Ye,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(Ye,{variant:"secondary",children:[e.jsx(Fn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(Ye,{variant:"outline",children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function kct({brokerageId:t}){const{data:s=[],isLoading:r}=HSs(t),{data:n=[]}=pct(t),a=KSs(),o=ZSs(),l=mct(),[i,c]=k.useState(""),[u,m]=k.useState(!1),[f,g]=k.useState({title:"",script_text:"",category:"general"}),y=s.filter(S=>{var I,P,O,q;return i?`${((I=S.prospect)==null?void 0:I.first_name)||""} ${((P=S.prospect)==null?void 0:P.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},w=k.useCallback(S=>{if(!S)return;const M=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(M),me.success("Share link copied")},[]),j=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"}),m(!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:Fn,color:"text-blue-500"},{label:"Viewed",value:_.viewed,icon:Tn,color:"text-amber-500"},{label:"CTA Clicked",value:_.ctaClicked,icon:sa,color:"text-emerald-500"}].map(S=>e.jsx(Pe,{children:e.jsxs(De,{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(ga,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"videos",children:[e.jsx(An,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ss,{value:"scripts",children:[e.jsx(wn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ss,{value:"analytics",children:[e.jsx(co,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(bs,{value:"videos",children:e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Lt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or title...",value:i,onChange:S=>c(S.target.value),className:"pl-9"})]})]})}),e.jsx(De,{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"})}):y.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:y.map(S=>{var M,I,P,O,q,$;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(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:t3s(((I=S.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(P=S.prospect)==null?void 0:P.first_name," ",(O=S.prospect)==null?void 0:O.last_name]}),e.jsx(s3s,{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:[ds(new Date(S.created_at),"MMM d, yyyy"),(($=S.prospect)==null?void 0:$.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(yi,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.id,"email"),title:"Mark as sent",children:e.jsx(Fn,{className:"h-4 w-4"})}),S.share_token&&e.jsx(G,{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(rn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(bs,{value:"scripts",children:e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Lt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:m,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ps,{children:[e.jsx(js,{children:e.jsx(vs,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(Le,{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(ye,{children:"Category"}),e.jsxs(Rs,{value:f.category,onValueChange:S=>g(M=>({...M,category:S})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:kwe.map(S=>e.jsx(ft,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Script"}),e.jsx(Tr,{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(G,{onClick:N,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(De,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(wn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var I;const M=((I=kwe.find(P=>P.value===S.category))==null?void 0:I.label)||S.category;return e.jsx(Pe,{className:"relative group",children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ye,{variant:"outline",className:"text-[10px] mb-2",children:M}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(G,{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(kr,{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(Ye,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(bs,{value:"analytics",children:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(De,{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,I;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(M=S.prospect)==null?void 0:M.first_name," ",(I=S.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{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 Sct({brokerageId:t}){const{toast:s}=Ra(),r=Qt(),{stages:n,prospects:a}=Ime(t),[o,l]=k.useState(!1),[i,c]=k.useState({title:"",target_count:"10",target_stage_id:"",period_start:ds(new Date,"yyyy-MM-dd"),period_end:ds(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:m}=pt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:_,error:w}=await H.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return _}}),f=Tt({mutationFn:async _=>{const{data:{user:w}}=await H.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:j}=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:w.id});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:_=>s({title:"Error",description:_.message,variant:"destructive"})}),g=Tt({mutationFn:async _=>{const{error:w}=await H.from("recruit_goals").delete().eq("id",_);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),y=_=>{const w=n.find(N=>N.id===_.target_stage_id);return{count:a.filter(N=>$g(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:w}};return m?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(G,{size:"sm",onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Pe,{className:"py-12 text-center",children:[e.jsx(Xh,{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:w,stage:j}=y(_),N=Math.min(100,w/_.target_count*100),S=$g(new Date,{start:new Date(_.period_start),end:new Date(_.period_end)});return e.jsxs(Pe,{className:S?"":"opacity-60",children:[e.jsx(Et,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{className:"text-sm",children:_.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ds(new Date(_.period_start),"MMM d")," – ",ds(new Date(_.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(Ye,{className:"text-[10px]",children:"Active"}):e.jsx(Ye,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>g.mutate(_.id),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(De,{className:"space-y-2",children:[j&&e.jsxs(Ye,{variant:"outline",className:"text-[10px]",style:{borderColor:j.color,color:j.color},children:["Stage: ",j.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",_.target_count]})]}),e.jsx(qi,{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(js,{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(ye,{children:"Goal Title *"}),e.jsx(Le,{required:!0,value:i.title,onChange:_=>c(w=>({...w,title:_.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Target Count *"}),e.jsx(Le,{type:"number",min:"1",required:!0,value:i.target_count,onChange:_=>c(w=>({...w,target_count:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{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(w=>({...w,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(ye,{children:"Start Date"}),e.jsx(Le,{type:"date",required:!0,value:i.period_start,onChange:_=>c(w=>({...w,period_start:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"End Date"}),e.jsx(Le,{type:"date",required:!0,value:i.period_end,onChange:_=>c(w=>({...w,period_end:_.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const r3s={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function Cct({email:t,mergeValues:s=r3s,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(js,{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(Ye,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(Ye,{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,m)=>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 ${m===l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:m===l?"Selected":m===0?"Primary":`Alt ${m}`}),e.jsx("span",{className:"text-sm",children:a(u)})]},m))})]}),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 T3e({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}=pt({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}=pt({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=Tt({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(m=>({...m,merge_fields:{...m.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(ye,{className:"text-xs",children:"Sender Display Name"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"Sender Email Address"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"{{city}}"}),e.jsx(Le,{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(ye,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(Le,{value:r.merge_fields.sender_name||"",onChange:c=>i("sender_name",c.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(G,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(Vc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const n3s=uy.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",Gc(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()}}}),Yze=[{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 yh({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{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(sc,{side:"bottom",className:"text-xs",children:a})]})}function a3s({content:t,onChange:s}){const r=_ke({extensions:[jke.configure({heading:{levels:[1,2,3]}}),n3s,Ike.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),Lke.configure({types:["heading","paragraph"]}),Dke,Xat],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(W1,{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(yh,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:tS,tooltip:"Bold"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:dS,tooltip:"Italic"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:XL,tooltip:"Underline"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:KL,tooltip:"Strikethrough"}),e.jsx(Qo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:GM,tooltip:"Heading 1"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:WM,tooltip:"Heading 2"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:ML,tooltip:"Heading 3"}),e.jsx(Qo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:nh,tooltip:"Bullet List"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:g0,tooltip:"Numbered List"}),e.jsx(yh,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:g1,tooltip:"Blockquote"}),e.jsx(yh,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:v0,tooltip:"Divider"}),e.jsx(Qo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(yh,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:X4,tooltip:"Align Left"}),e.jsx(yh,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:Q4,tooltip:"Align Center"}),e.jsx(yh,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:J4,tooltip:"Align Right"}),e.jsx(Qo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(yh,{onClick:n,active:r.isActive("link"),icon:Uo,tooltip:"Insert Link"}),e.jsx(Qo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(yh,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:MS,tooltip:"Undo"}),e.jsx(yh,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:wS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(G,{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(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(iT,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(Ud,{align:"end",className:"w-56",children:Yze.map(o=>e.jsxs(La,{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(vke,{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:"}),Yze.map(o=>e.jsx(Ye,{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}function i3s({open:t,onClose:s,campaignName:r,stat:n}){return e.jsx(fs,{open:t,onOpenChange:a=>!a&&s(),children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5 text-primary"}),r," — Engagement Stats"]}),e.jsx(Gr,{children:"Per-email breakdown of sends, opens, and clicks for this campaign at your brokerage."})]}),!n||n.sent===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Fn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No emails sent yet for this campaign"}),e.jsx("p",{className:"text-sm",children:"Stats will appear once emails start sending"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(_9,{icon:rr,color:"text-blue-500",label:"Total Sent",value:n.sent.toLocaleString()}),e.jsx(_9,{icon:Tn,color:"text-amber-500",label:"Opens",value:`${n.opened.toLocaleString()}`,sub:`${n.openRate.toFixed(1)}% open rate`}),e.jsx(_9,{icon:$m,color:"text-green-500",label:"Clicks",value:`${n.clicked.toLocaleString()}`,sub:`${n.clickRate.toFixed(1)}% click rate`}),e.jsx(_9,{icon:vd,color:"text-destructive",label:"Failed",value:n.failed.toLocaleString()})]}),n.lastSentAt&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(mn,{className:"h-3 w-3"})," Last sent: ",ds(new Date(n.lastSentAt),"MMM d, yyyy h:mm a")]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 mt-4",children:"Per-Email Performance"}),e.jsx("div",{className:"space-y-2",children:n.byEmail.map(a=>{const o=a.sent_count>0?a.opened_count/a.sent_count*100:0,l=a.sent_count>0?a.clicked_count/a.sent_count*100:0;return e.jsx(Pe,{className:"overflow-hidden",children:e.jsxs(De,{className:"py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-xs flex items-center justify-center shrink-0",children:["#",a.email_number]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.title}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-1",children:[e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",a.sent_count.toLocaleString()," sent"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600",children:[e.jsx(Tn,{className:"h-2.5 w-2.5"})," ",a.opened_count.toLocaleString()," (",o.toFixed(1),"%)"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600",children:[e.jsx($m,{className:"h-2.5 w-2.5"})," ",a.clicked_count.toLocaleString()," (",l.toFixed(1),"%)"]}),a.failed_count>0&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-destructive/30 text-destructive",children:[e.jsx(vd,{className:"h-2.5 w-2.5"})," ",a.failed_count.toLocaleString()," failed"]})]})]})]}),a.sent_count>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-amber-500 transition-all",style:{width:`${Math.min(o,100)}%`}})}),e.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all",style:{width:`${Math.min(l,100)}%`}})})]})]})},a.campaign_email_id)})})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground italic",children:"Open rates count when the email is loaded with images on. Click rates count any tracked link click in the email."})]})]})})}function _9({icon:t,color:s,label:r,value:n,sub:a}){return e.jsx(Pe,{children:e.jsx(De,{className:"pt-4 pb-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(t,{className:`h-6 w-6 ${s}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xl font-bold leading-none",children:n}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:r}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]})]})})})}function Mct(t){return pt({queryKey:["recruit-campaign-stats",t],enabled:!!t,staleTime:6e4,queryFn:async()=>{const{data:s,error:r}=await H.from("recruit_campaign_email_stats").select("*").eq("brokerage_id",t);if(r)throw r;const n=s??[],a={};for(const o of n){a[o.campaign_id]||(a[o.campaign_id]={campaign_id:o.campaign_id,sent:0,opened:0,clicked:0,failed:0,openRate:0,clickRate:0,byEmail:[],lastSentAt:null});const l=a[o.campaign_id];l.sent+=o.sent_count,l.opened+=o.opened_count,l.clicked+=o.clicked_count,l.failed+=o.failed_count,l.byEmail.push(o),o.last_sent_at&&(!l.lastSentAt||o.last_sent_at>l.lastSentAt)&&(l.lastSentAt=o.last_sent_at)}return Object.values(a).forEach(o=>{o.openRate=o.sent>0?o.opened/o.sent*100:0,o.clickRate=o.sent>0?o.clicked/o.sent*100:0,o.byEmail.sort((l,i)=>l.email_number-i.email_number)}),a}})}const Qze={cold:{icon:l0,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:b1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:rh,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function Tct({brokerageId:t}){var Ae,Me,ke,Oe;const{user:s}=Fs(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState("editor"),[w,j]=k.useState(null),[N,S]=k.useState(null),{data:M={}}=Mct(t),[I,P]=k.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:O}=pt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:qe,error:ve}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(ve)throw ve;return qe}}),{data:q}=pt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:qe,error:ve}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ve)throw ve;return qe}}),$={first_name:"Sarah",brokerage_name:((Ae=q==null?void 0:q.merge_fields)==null?void 0:Ae.brokerage_name)||(O==null?void 0:O.name)||"Your Brokerage",city:((Me=q==null?void 0:q.merge_fields)==null?void 0:Me.city)||(O==null?void 0:O.city)||"Your City",sender_name:((ke=q==null?void 0:q.merge_fields)==null?void 0:ke.sender_name)||(q==null?void 0:q.sender_name)||"Your Name"},z=qe=>qe.replace(/\{\{first_name\}\}/g,$.first_name).replace(/\{\{brokerage_name\}\}/g,$.brokerage_name).replace(/\{\{city\}\}/g,$.city).replace(/\{\{sender_name\}\}/g,$.sender_name),{data:V=[],isLoading:X}=pt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:qe,error:ve}=await H.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(ve)throw ve;return qe}}),{data:Y={}}=pt({queryKey:["recruit-campaign-emails",t],enabled:V.length>0,queryFn:async()=>{const qe=V.map(Ue=>Ue.id),{data:ve,error:dt}=await H.from("recruit_campaign_emails").select("*").in("campaign_id",qe).order("email_number");if(dt)throw dt;const pe={};return ve.forEach(Ue=>{pe[Ue.campaign_id]||(pe[Ue.campaign_id]=[]),pe[Ue.campaign_id].push(Ue)}),pe}}),J=Object.values(Y).flat().map(qe=>qe.id),{data:Q=[]}=pt({queryKey:["recruit-subject-overrides",t],enabled:J.length>0,queryFn:async()=>{const{data:qe,error:ve}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ve)throw ve;return qe}}),ce={};Q.forEach(qe=>{ce[qe.campaign_email_id]=qe.selected_subject_index});const ne=Tt({mutationFn:async({campaignEmailId:qe,selectedIndex:ve})=>{const{error:dt}=await H.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:qe,selected_subject_index:ve,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(dt)throw dt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),me.success("Subject line updated for your brokerage")},onError:qe=>me.error(qe.message)}),re=Tt({mutationFn:async qe=>{const{error:ve}=await H.from("recruit_campaign_emails").update({title:qe.title,subject_line:qe.subject_line,subject_line_options:qe.subject_line_options,body_html:qe.body_html,body_text:qe.body_text,delay_days:qe.delay_days,updated_at:new Date().toISOString()}).eq("id",qe.id);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email template saved!"),l(null)},onError:qe=>me.error(qe.message)}),oe=Tt({mutationFn:async()=>{const qe=I.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:ve,error:dt}=await H.from("recruit_campaigns").insert({name:I.name,slug:qe,description:I.description||null,theme:I.theme||null,goal:I.goal||null,primary_cta:I.primary_cta||"Learn more",warmth_level:I.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:I.sender_name||null,sender_email:I.sender_email||null,reply_to_email:I.reply_to_email||null,is_active:!0,sort_order:V.length+1}).select().single();if(dt)throw dt;const pe=[{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:Ue}=await H.from("recruit_campaign_emails").insert(pe.map(Xe=>({campaign_id:ve.id,...Xe,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

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

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:pe+7,is_active:!0});if(Xe)throw Xe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:qe=>me.error(qe.message)}),ue=Tt({mutationFn:async qe=>{const{error:ve}=await H.from("recruit_campaigns").delete().eq("id",qe);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:qe=>me.error(qe.message)}),ge=Tt({mutationFn:async qe=>{const{error:ve}=await H.from("recruit_campaign_emails").delete().eq("id",qe);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:qe=>me.error(qe.message)}),_e=Tt({mutationFn:async({emailId:qe,delay_days:ve})=>{const{error:dt}=await H.from("recruit_campaign_emails").update({delay_days:ve,updated_at:new Date().toISOString()}).eq("id",qe);if(dt)throw dt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:qe=>me.error(qe.message)});if(X)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 Be=V.filter(qe=>!qe.brokerage_id),Se=V.filter(qe=>qe.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(G,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-1.5",children:[e.jsx(el,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(G,{size:"sm",onClick:()=>g(!0),className:"gap-1.5",children:[e.jsx(qs,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Pe,{className:"border-primary/20 bg-primary/5",children:e.jsx(De,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(nn,{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(el,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),Se.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(TL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Se.map(qe=>Ee(qe,!0))})]}),Be.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(nn,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Be.map(qe=>Ee(qe,!1))})]}),V.length===0&&e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(rr,{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(G,{className:"mt-4",onClick:()=>g(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),e.jsx(i3s,{open:!!N,onClose:()=>S(null),campaignName:(N==null?void 0:N.name)||"",stat:N&&M[N.id]||null}),i&&e.jsx(Cct,{email:i,mergeValues:$,selectedSubjectIndex:ce[i.id],onClose:()=>c(null)}),e.jsx(fs,{open:!!o,onOpenChange:qe=>!qe&&l(null),children:e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Y_,{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(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(Le,{value:o.title,onChange:qe=>l({...o,title:qe.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(Le,{type:"number",min:0,max:90,value:o.delay_days,onChange:qe=>l({...o,delay_days:parseInt(qe.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(Le,{value:o.subject_line,onChange:qe=>l({...o,subject_line:qe.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{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(Tr,{value:((Oe=o.subject_line_options)==null?void 0:Oe.join(` `))||"",onChange:qe=>l({...o,subject_line_options:qe.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(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ga,{value:y,onValueChange:qe=>_(qe),children:e.jsxs(fa,{className:"h-7",children:[e.jsx(ss,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ss,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),y==="editor"?e.jsx(a3s,{content:o.body_html,onChange:qe=>l({...o,body_html:qe})}):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:[$.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:[$.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:z(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:z(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(G,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(G,{size:"sm",onClick:()=>re.mutate(o),disabled:re.isPending,className:"gap-1.5",children:[e.jsx(Vc,{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(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(qs,{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(ye,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(Le,{value:I.name,onChange:qe=>P({...I,name:qe.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(ye,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Rs,{value:I.warmth_level,onValueChange:qe=>P({...I,warmth_level:qe}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(ft,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(ft,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(Le,{value:I.primary_cta,onChange:qe=>P({...I,primary_cta:qe.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Description"}),e.jsx(Tr,{value:I.description,onChange:qe=>P({...I,description:qe.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Goal"}),e.jsx(Le,{value:I.goal,onChange:qe=>P({...I,goal:qe.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(bf,{children:[e.jsx(_f,{asChild:!0,children:e.jsxs(G,{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(rr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Ji,{className:"h-3.5 w-3.5"})]})}),e.jsxs(wf,{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(ye,{className:"text-xs",children:"Sender Name"}),e.jsx(Le,{value:I.sender_name,onChange:qe=>P({...I,sender_name:qe.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Email"}),e.jsx(Le,{value:I.sender_email,onChange:qe=>P({...I,sender_email:qe.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(ye,{className:"text-xs",children:"Reply-To Email"}),e.jsx(Le,{value:I.reply_to_email,onChange:qe=>P({...I,reply_to_email:qe.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(G,{className:"w-full",disabled:!I.name.trim()||oe.isPending,onClick:()=>oe.mutate(),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!w,onOpenChange:qe=>!qe&&j(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(el,{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."})]}),w&&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(ye,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(Le,{value:w.name,onChange:qe=>j({...w,name:qe.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Rs,{value:w.warmth_level,onValueChange:qe=>j({...w,warmth_level:qe}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"cold",children:"❄️ Cold"}),e.jsx(ft,{value:"warm",children:"☀️ Warm"}),e.jsx(ft,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Goal"}),e.jsx(Le,{value:w.goal||"",onChange:qe=>j({...w,goal:qe.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(rr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Name"}),e.jsx(Le,{value:w.sender_name||"",onChange:qe=>j({...w,sender_name:qe.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Email"}),e.jsx(Le,{value:w.sender_email||"",onChange:qe=>j({...w,sender_email:qe.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(ye,{className:"text-xs",children:"Reply-To Email"}),e.jsx(Le,{value:w.reply_to_email||"",onChange:qe=>j({...w,reply_to_email:qe.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(G,{className:"w-full",onClick:()=>he.mutate(w),disabled:he.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:m,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(vs,{children:"Default Recruiting Email Settings"}),e.jsx(Gr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(T3e,{brokerageId:t})]})})]});function Ee(qe,ve){const dt=Qze[qe.warmth_level]||Qze.cold,pe=dt.icon,Ue=Y[qe.id]||[],Xe=n===qe.id,et=!!(qe.sender_name||qe.sender_email||qe.reply_to_email),Ce=M[qe.id];return e.jsxs(Pe,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Et,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(Xe?null:qe.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 ${dt.bg} flex items-center justify-center`,children:e.jsx(pe,{className:`h-5 w-5 ${dt.color}`})}),e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[qe.name,e.jsx(Ye,{variant:qe.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:qe.is_active?"Active":"Draft"}),ve&&e.jsx(Ye,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),et&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(rr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(vr,{className:"text-xs mt-0.5",children:qe.theme||qe.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Je=>{Je.stopPropagation(),j({...qe})},children:e.jsx(el,{className:"h-4 w-4 text-muted-foreground"})}),ve&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:Je=>{Je.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&ue.mutate(qe.id)},children:e.jsx(kr,{className:"h-4 w-4"})}),Ce&&Ce.sent>0&&e.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 font-medium",title:"Total emails sent",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",Ce.sent.toLocaleString()]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600 font-medium",title:`${Ce.openRate.toFixed(1)}% open rate`,children:[e.jsx(Tn,{className:"h-2.5 w-2.5"})," ",Ce.opened.toLocaleString()," (",Ce.openRate.toFixed(0),"%)"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600 font-medium",title:`${Ce.clickRate.toFixed(1)}% click rate`,children:[e.jsx($m,{className:"h-2.5 w-2.5"})," ",Ce.clicked.toLocaleString()," (",Ce.clickRate.toFixed(1),"%)"]})]}),e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:Je=>{Je.stopPropagation(),S(qe)},title:"View detailed engagement stats",children:[e.jsx(co,{className:"h-3.5 w-3.5"})," Stats"]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(rr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Ue.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:Xe?e.jsx(Sp,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ji,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),Xe&&e.jsxs(De,{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:qe.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:qe.primary_cta||"—"})]})]}),et&&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(rr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[qe.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",qe.sender_name]}),qe.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",qe.sender_email]}),qe.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",qe.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Ue.map((Je,Ge)=>{var lt,He;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[GeWe.stopPropagation(),onBlur:We=>{const tt=parseInt(We.target.value)||0;tt!==Je.delay_days&&_e.mutate({emailId:Je.id,delay_days:tt})},onKeyDown:We=>{We.key==="Enter"&&We.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),Je.email_number===1?"Sent immediately":`Day ${Je.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",z(((lt=Je.subject_line_options)==null?void 0:lt.length)>0&&Je.subject_line_options[ce[Je.id]??0]||Je.subject_line)]})]}),((He=Je.subject_line_options)==null?void 0:He.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(Rs,{value:String(ce[Je.id]??0),onValueChange:We=>ne.mutate({campaignEmailId:Je.id,selectedIndex:parseInt(We)}),children:[e.jsx(Ls,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx($s,{placeholder:"Choose subject line"})}),e.jsx(Ds,{children:Je.subject_line_options.map((We,tt)=>e.jsxs(ft,{value:String(tt),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[tt===0?"Primary":`Alt ${tt}`,":"]}),z(We)]},tt))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>c(Je),children:e.jsx(Tn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...Je}),_("editor")},children:e.jsx(Pa,{className:"h-4 w-4"})}),ve&&Ue.length>1&&e.jsx(G,{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(Je.id)},children:e.jsx(kr,{className:"h-4 w-4"})})]})]})})]},Je.id)})}),ve&&e.jsxs(G,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>xe.mutate(qe.id),disabled:xe.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},qe.id)}}const Xze={active:{icon:sl,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:Ih,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:wi,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:Nc,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},Jze={sent:{icon:rr,color:"text-blue-500"},opened:{icon:Tn,color:"text-amber-500"},clicked:{icon:$m,color:"text-green-500"},failed:{icon:vd,color:"text-destructive"}};function Act({brokerageId:t}){var Ae,Me,ke,Oe,qe;const{user:s}=Fs(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(new Set),[u,m]=k.useState("assignments"),[f,g]=k.useState(null),[y,_]=k.useState(""),[w,j]=k.useState("all"),[N,S]=k.useState("all"),{data:M={}}=pt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("recruit_campaign_emails").select("*").order("email_number");if(dt)throw dt;const pe={};return(ve??[]).forEach(Ue=>{pe[Ue.campaign_id]||(pe[Ue.campaign_id]=[]),pe[Ue.campaign_id].push(Ue)}),pe}}),{data:I}=pt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(dt)throw dt;return ve}}),{data:P}=pt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(dt)throw dt;return ve}}),{data:O=[]}=pt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(dt)throw dt;return ve}}),q={};O.forEach(ve=>{q[ve.campaign_email_id]=ve.selected_subject_index});const $={first_name:((Ae=f==null?void 0:f.prospect)==null?void 0:Ae.first_name)||"Sarah",brokerage_name:((Me=P==null?void 0:P.merge_fields)==null?void 0:Me.brokerage_name)||(I==null?void 0:I.name)||"Your Brokerage",city:((ke=P==null?void 0:P.merge_fields)==null?void 0:ke.city)||(I==null?void 0:I.city)||"Your City",sender_name:((Oe=P==null?void 0:P.merge_fields)==null?void 0:Oe.sender_name)||(P==null?void 0:P.sender_name)||"Your Name"},z=ve=>{const dt=M[ve.campaign_id]||[],pe=ve.current_email_number+1;return dt.find(Ue=>Ue.email_number===pe)||null},{data:V=[],isLoading:X}=pt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let dt=[],pe=0;for(;;){const{data:Ue,error:Xe}=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(pe,pe+1e3-1);if(Xe)throw Xe;if(dt=dt.concat(Ue??[]),!Ue||Ue.length<1e3)break;pe+=1e3}return dt}}),{data:Y=[]}=pt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:ve,error:dt}=await H.from("recruit_campaign_sends").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign_email:recruit_campaign_emails(title, campaign_id) `).eq("brokerage_id",t).neq("status","failed").order("sent_at",{ascending:!1}).limit(500);if(dt)throw dt;return ve}}),{data:J=[]}=pt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:ve,error:dt}=await H.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(dt)throw dt;return ve}}),{data:Q=[]}=pt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let dt=[],pe=0;for(;;){const{data:Ue,error:Xe}=await H.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(pe,pe+1e3-1);if(Xe)throw Xe;if(dt=dt.concat(Ue??[]),!Ue||Ue.length<1e3)break;pe+=1e3}return dt}}),ce=new Set(V.map(ve=>`${ve.prospect_id}-${ve.campaign_id}`)),ne=Tt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const ve=new Date,dt=Array.from(i).filter(Ue=>!ce.has(`${Ue}-${o}`)).map(Ue=>({prospect_id:Ue,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:ve.toISOString(),started_at:ve.toISOString()}));if(dt.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:pe}=await H.from("recruit_campaign_assignments").insert(dt);if(pe)throw pe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),c(new Set)},onError:ve=>me.error(ve.message)}),re=Tt({mutationFn:async({id:ve,newStatus:dt})=>{const{error:pe}=await H.from("recruit_campaign_assignments").update({status:dt,updated_at:new Date().toISOString()}).eq("id",ve);if(pe)throw pe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),oe=Tt({mutationFn:async()=>{const{data:ve,error:dt}=await H.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(dt)throw dt;return ve},onSuccess:ve=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${ve.sent} emails delivered, ${ve.skipped} skipped, ${ve.failed} failed`)},onError:ve=>me.error(`Send failed: ${ve.message}`)}),he=V.filter(ve=>ve.status==="active").length;V.filter(ve=>ve.status==="completed").length;const xe=V.filter(ve=>ve.status==="active"&&ve.next_send_at&&new Date(ve.next_send_at)<=new Date).length,{data:ue={}}=Mct(t),ge=V.reduce((ve,dt)=>ve+Math.max(0,dt.current_email_number||0),0),_e=Object.values(ue).reduce((ve,dt)=>ve+dt.opened,0),Be=Object.values(ue).reduce((ve,dt)=>ve+dt.clicked,0);Object.values(ue).reduce((ve,dt)=>ve+dt.failed,0);const Se=ge>0?Math.round(_e/ge*100):0,Ee=ge>0?Be/ge*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:[xe>0&&e.jsxs(G,{variant:"outline",onClick:()=>oe.mutate(),disabled:oe.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Jh,{className:"h-4 w-4 mr-1"}),oe.isPending?"Sending...":`Send Next Wave (${xe})`]}),e.jsxs(G,{onClick:()=>a(!0),children:[e.jsx(Fn,{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(Pe,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(ur,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:V.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(sl,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:he}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(rr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:ge.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Tn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Se,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Open Rate (",_e.toLocaleString(),")"]})]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx($m,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Ee.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click Rate (",Be.toLocaleString(),")"]})]})]})})]}),e.jsxs(ga,{value:u,onValueChange:m,children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"assignments",children:["Active Drips (",he,")"]}),e.jsxs(ss,{value:"history",children:["Send History (",ge.toLocaleString(),")"]})]}),e.jsx(bs,{value:"assignments",className:"mt-4",children:X?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"})}):V.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Fn,{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:V.map(ve=>{var Ce,Je,Ge,lt;const dt=Xze[ve.status]||Xze.active,pe=dt.icon,Xe=(M[ve.campaign_id]||[]).length||4,et=z(ve);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(Ye,{className:`text-xs ${dt.color} border-0`,children:[e.jsx(pe,{className:"h-3 w-3 mr-1"}),dt.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(Ce=ve.prospect)==null?void 0:Ce.first_name," ",(Je=ve.prospect)==null?void 0:Je.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(Ge=ve.prospect)==null?void 0:Ge.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(lt=ve.campaign)==null?void 0:lt.name," · Email ",ve.current_email_number,"/",Xe,ve.next_send_at&&ve.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(mn,{className:"h-3 w-3 inline"})," Next: ",ds(new Date(ve.next_send_at),"MMM d, h:mm a"),new Date(ve.next_send_at)<=new Date&&e.jsx(Ye,{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:[et&&e.jsx(G,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>g(ve),children:e.jsx(Tn,{className:"h-3.5 w-3.5"})}),ve.status==="active"&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>re.mutate({id:ve.id,newStatus:"paused"}),children:e.jsx(Ih,{className:"h-3.5 w-3.5"})}),ve.status==="paused"&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>re.mutate({id:ve.id,newStatus:"active"}),children:e.jsx(sl,{className:"h-3.5 w-3.5"})}),(ve.status==="active"||ve.status==="paused")&&e.jsx(G,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>re.mutate({id:ve.id,newStatus:"cancelled"}),children:e.jsx(Nc,{className:"h-3.5 w-3.5"})})]})]},ve.id)})})}),e.jsxs(bs,{value:"history",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Filter:"}),e.jsxs(Rs,{value:w,onValueChange:j,children:[e.jsx(Ls,{className:"w-[220px] h-8 text-xs",children:e.jsx($s,{placeholder:"All campaigns"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All campaigns"}),J.map(ve=>e.jsx(ft,{value:ve.id,children:ve.name},ve.id))]})]}),e.jsxs(Rs,{value:N,onValueChange:S,children:[e.jsx(Ls,{className:"w-[160px] h-8 text-xs",children:e.jsx($s,{placeholder:"All statuses"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All statuses"}),e.jsx(ft,{value:"sent",children:"Sent (no engagement)"}),e.jsx(ft,{value:"opened",children:"Opened"}),e.jsx(ft,{value:"clicked",children:"Clicked"})]})]}),(w!=="all"||N!=="all")&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>{j("all"),S("all")},children:"Clear"})]}),(()=>{var dt;const ve=Y.filter(pe=>{var Ue;return!(w!=="all"&&((Ue=pe.campaign_email)==null?void 0:Ue.campaign_id)!==w||N==="opened"&&!pe.opened_at||N==="clicked"&&!pe.clicked_at||N==="sent"&&(pe.opened_at||pe.clicked_at))});return ve.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(rr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:Y.length===0?"No emails sent yet":"No emails match these filters"}),e.jsx("p",{className:"text-sm",children:Y.length===0?"Emails will appear here once campaigns start sending":"Try clearing the filters above"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",ve.length," of ",Y.length," recent sends",w!=="all"&&` · ${(dt=J.find(pe=>pe.id===w))==null?void 0:dt.name}`]}),e.jsx("div",{className:"space-y-1",children:ve.map(pe=>{var Ce,Je,Ge;const Ue=Jze[pe.status]||Jze.sent,Xe=Ue.icon,et=(Ce=J.find(lt=>{var He;return lt.id===((He=pe.campaign_email)==null?void 0:He.campaign_id)}))==null?void 0:Ce.name;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(Xe,{className:`h-4 w-4 flex-shrink-0 ${Ue.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Je=pe.prospect)==null?void 0:Je.first_name," ",(Ge=pe.prospect)==null?void 0:Ge.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",pe.email_number]}),et&&e.jsx(Ye,{variant:"outline",className:"ml-2 text-[10px] px-1.5 py-0 font-normal",children:et})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:pe.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[pe.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",ds(new Date(pe.opened_at),"MMM d")]}),pe.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx($m,{className:"h-3 w-3"})," ",ds(new Date(pe.clicked_at),"MMM d")]}),e.jsx("span",{children:ds(new Date(pe.sent_at),"MMM d, h:mm a")})]})]},pe.id)})})]})})()]})]}),e.jsx(fs,{open:n,onOpenChange:ve=>{a(ve),ve||(_(""),c(new Set),l(""))},children:e.jsxs(ps,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(js,{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(ye,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs(Rs,{value:o,onValueChange:l,children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Choose a campaign..."})}),e.jsx(Ds,{children:J.map(ve=>e.jsx(ft,{value:ve.id,children:ve.name},ve.id))})]})]}),o&&(()=>{const ve=y.toLowerCase(),dt=Q.filter(Xe=>`${Xe.first_name} ${Xe.last_name}`.toLowerCase().includes(ve)||Xe.email.toLowerCase().includes(ve)),pe=dt.filter(Xe=>!ce.has(`${Xe.id}-${o}`)),Ue=pe.length>0&&pe.every(Xe=>i.has(Xe.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{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(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:y,onChange:Xe=>_(Xe.target.value),className:"pl-9 h-9"})]}),e.jsxs(G,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(Ue){const Xe=new Set(i);pe.forEach(et=>Xe.delete(et.id)),c(Xe)}else{const Xe=new Set(i);pe.forEach(et=>Xe.add(et.id)),c(Xe)}},children:[e.jsx(vL,{className:"h-3.5 w-3.5 mr-1"}),Ue?"Deselect All":`Select All (${pe.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:dt.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:y?"No prospects match your search":"No prospects found for this brokerage"}):dt.map(Xe=>{const et=ce.has(`${Xe.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${et?"opacity-40":""}`,children:[e.jsx(Mo,{checked:i.has(Xe.id),disabled:et,onCheckedChange:Ce=>{const Je=new Set(i);Ce?Je.add(Xe.id):Je.delete(Xe.id),c(Je)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Xe.first_name," ",Xe.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Xe.email})]}),et&&e.jsx(Ye,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},Xe.id)})}),dt.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",dt.length," of ",Q.length," prospects",pe.length0&&e.jsx(Pe,{className:"bg-primary/5 border-primary/20",children:e.jsxs(De,{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:(qe=J.find(ve=>ve.id===o))==null?void 0:qe.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(Rn,{className:"px-6 py-4 border-t",children:[e.jsx(G,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(G,{onClick:()=>ne.mutate(),disabled:ne.isPending||!o||i.size===0,children:[e.jsx(Fn,{className:"h-4 w-4 mr-1"}),ne.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const ve=z(f);return ve?e.jsx(Cct,{email:ve,mergeValues:$,selectedSubjectIndex:q[ve.id],onClose:()=>g(null)}):null})()]})}function Ect({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:m}=pt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:j,error:N}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(N)throw N;return j},enabled:!!t});k.useEffect(()=>{if(u){if(c.current){c.current=!1;return}n(u.map(j=>({id:j.id,name:j.name,color:j.color,sort_order:j.sort_order}))),o([]),i(!1)}},[u]);const f=Tt({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 j=r.filter(S=>S.id&&!S.isNew),N=r.filter(S=>!S.id||S.isNew);for(const S of j){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:j=>me.error(j.message)}),g=(j,N,S)=>{n(M=>M.map((I,P)=>P===j?{...I,[N]:S}:I)),i(!0)},y=()=>{const j=r.length>0?Math.max(...r.map(N=>N.sort_order)):0;n(N=>[...N,{name:"",color:"#6366f1",sort_order:j+1,isNew:!0}]),i(!0)},_=j=>{const N=r[j];N.id&&!N.isNew&&o(S=>[...S,N.id]),n(S=>S.filter((M,I)=>I!==j)),i(!0)},w=(j,N)=>{const S=j+N;if(S<0||S>=r.length)return;const M=[...r];[M[j],M[S]]=[M[S],M[j]],M.forEach((I,P)=>I.sort_order=P+1),n(M),i(!0)};return m?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((j,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:()=>w(N,-1),disabled:N===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>w(N,1),disabled:N===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(Eu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:j.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(Le,{value:j.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(G,{variant:"ghost",size:"icon",onClick:()=>_(N),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(kr,{className:"h-4 w-4"})})]},j.id||`new-${N}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:y,className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(G,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(Vc,{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 o3s({brokerageId:t}){const{data:s=[],isLoading:r}=pt({queryKey:["recruit-unsubscribed",t],queryFn:async()=>{const{data:n,error:a}=await H.from("recruit_prospects").select("id, first_name, last_name, email, unsubscribed_at, unsubscribe_reason, current_brokerage").eq("brokerage_id",t).not("unsubscribed_at","is",null).order("unsubscribed_at",{ascending:!1}).limit(500);if(a)throw a;return n||[]},enabled:!!t});return r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 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("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(NS,{className:"h-5 w-5 text-muted-foreground"}),"Unsubscribed Prospects"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Prospects who opted out of recruiting emails. They will not receive further outreach."})]}),e.jsxs(Ye,{variant:"secondary",className:"text-base px-3 py-1",children:[s.length," total"]})]}),s.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(NS,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No prospects have unsubscribed. Nice work!"})]})}):e.jsx("div",{className:"grid gap-3",children:s.map(n=>e.jsxs(Pe,{className:"hover:shadow-sm transition-shadow",children:[e.jsx(Et,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"text-base",children:[n.first_name," ",n.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rr,{className:"h-3 w-3"}),n.email]}),n.current_brokerage&&e.jsxs("span",{children:["· ",n.current_brokerage]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground whitespace-nowrap",children:[e.jsx(fn,{className:"h-3 w-3"}),n.unsubscribed_at&&ds(new Date(n.unsubscribed_at),"MMM d, yyyy")]})]})}),n.unsubscribe_reason&&e.jsx(De,{className:"pt-0",children:e.jsxs("div",{className:"text-sm bg-muted/40 rounded-md px-3 py-2 italic text-muted-foreground",children:['"',n.unsubscribe_reason,'"']})})]},n.id))})]})}function l3s(){var i;const[t,s]=k.useState(""),[r,n]=k.useState("board"),{data:a=[],isLoading:o}=pt({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(Rs,{value:l,onValueChange:s,children:[e.jsxs(Ls,{className:"w-[280px]",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),e.jsx($s,{placeholder:"Select brokerage"})]}),e.jsx(Ds,{children:a.map(c=>e.jsx(ft,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(ga,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ss,{value:"pipeline",children:"Pipeline"}),e.jsxs(ss,{value:"contacts",children:[e.jsx(ur,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ss,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ss,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ss,{value:"referrals",children:"Referrals"}),e.jsx(ss,{value:"interest",children:"Interest Form"}),e.jsx(ss,{value:"landing-page",children:"Landing Page"}),e.jsx(ss,{value:"goals",children:"Goals"}),e.jsx(ss,{value:"metrics",children:"Metrics"}),e.jsx(ss,{value:"templates",children:"Email Templates"}),e.jsxs(ss,{value:"campaigns",children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ss,{value:"drip-assignments",children:[e.jsx(Fn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ss,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ss,{value:"email-settings",children:[e.jsx(el,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ss,{value:"pipeline-stages",children:[e.jsx(v1,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]}),e.jsxs(ss,{value:"unsubscribed",children:[e.jsx(NS,{className:"h-3.5 w-3.5 mr-1"}),"Unsubscribed"]})]}),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(G,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(Tp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(G,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(nT,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(gct,{brokerageId:l}):e.jsx(fde,{brokerageId:l})]}),e.jsx(bs,{value:"contacts",children:e.jsx(fde,{brokerageId:l})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(kct,{brokerageId:l})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(jct,{brokerageId:l})}),e.jsx(bs,{value:"referrals",children:e.jsx(_ct,{brokerageId:l})}),e.jsx(bs,{value:"interest",children:e.jsx(wct,{brokerageId:l})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Nct,{brokerageId:l})}),e.jsx(bs,{value:"goals",children:e.jsx(Sct,{brokerageId:l})}),e.jsx(bs,{value:"metrics",children:e.jsx(yct,{brokerageId:l})}),e.jsx(bs,{value:"templates",children:e.jsx(vct,{brokerageId:l})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Tct,{brokerageId:l})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Act,{brokerageId:l})}),e.jsx(bs,{value:"activity",children:e.jsx(bct,{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(T3e,{brokerageId:l})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Ect,{brokerageId:l})})}),e.jsx(bs,{value:"unsubscribed",children:e.jsx(o3s,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ta,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function c3s(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Fs(),[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(Ta,{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(Rs,{value:o,onValueChange:r,children:[e.jsxs(Ls,{className:"w-[280px]",children:[e.jsx(Ta,{className:"mr-2 h-4 w-4"}),e.jsx($s,{placeholder:"Select brokerage"})]}),e.jsx(Ds,{children:t.map(i=>e.jsx(ft,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ga,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ss,{value:"pipeline",children:"Pipeline"}),e.jsxs(ss,{value:"contacts",children:[e.jsx(ur,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ss,{value:"video-outreach",children:[e.jsx(An,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ss,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ss,{value:"referrals",children:"Referrals"}),e.jsx(ss,{value:"interest",children:"Interest Form"}),e.jsx(ss,{value:"landing-page",children:"Landing Page"}),e.jsx(ss,{value:"goals",children:"Goals"}),e.jsx(ss,{value:"metrics",children:"Metrics"}),e.jsx(ss,{value:"templates",children:"Email Templates"}),e.jsxs(ss,{value:"campaigns",children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ss,{value:"drip-assignments",children:[e.jsx(Fn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ss,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ss,{value:"email-settings",children:[e.jsx(el,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ss,{value:"pipeline-stages",children:[e.jsx(v1,{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(G,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(Tp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(G,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(nT,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(gct,{brokerageId:o}):e.jsx(fde,{brokerageId:o})]}),e.jsx(bs,{value:"contacts",children:e.jsx(fde,{brokerageId:o})}),e.jsx(bs,{value:"video-outreach",children:e.jsx(kct,{brokerageId:o})}),e.jsx(bs,{value:"follow-ups",children:e.jsx(jct,{brokerageId:o})}),e.jsx(bs,{value:"referrals",children:e.jsx(_ct,{brokerageId:o})}),e.jsx(bs,{value:"interest",children:e.jsx(wct,{brokerageId:o})}),e.jsx(bs,{value:"landing-page",children:e.jsx(Nct,{brokerageId:o})}),e.jsx(bs,{value:"goals",children:e.jsx(Sct,{brokerageId:o})}),e.jsx(bs,{value:"metrics",children:e.jsx(yct,{brokerageId:o})}),e.jsx(bs,{value:"templates",children:e.jsx(vct,{brokerageId:o})}),e.jsx(bs,{value:"campaigns",children:e.jsx(Tct,{brokerageId:o})}),e.jsx(bs,{value:"drip-assignments",children:e.jsx(Act,{brokerageId:o})}),e.jsx(bs,{value:"activity",children:e.jsx(bct,{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(T3e,{brokerageId:o})]})}),e.jsx(bs,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(Ect,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ta,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function d3s(){const[t,s]=k.useState(""),{data:r,isLoading:n}=pt({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"),m=c||[],f=u||[],g=i.map(y=>{const _=m.filter(N=>N.brokerage_id===y.id),w=f.filter(N=>N.brokerage_id===y.id),j=_.length>0?_.reduce((N,S)=>S.created_at>N?S.created_at:N,_[0].created_at):null;return{brokerage_id:y.id,brokerage_name:y.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:j,categories:w.length}});return g.sort((y,_)=>_.total_items-y.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(dh,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(De,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(De,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsx(Lt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(De,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Brokerage"}),e.jsx(jt,{className:"text-center",children:"Total"}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(An,{className:"h-3 w-3"})," Videos"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(wn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(pl,{className:"h-3 w-3"})," Links"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Fd,{className:"h-3 w-3"})," Events"]})}),e.jsx(jt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(bl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(jt,{className:"text-center",children:"Categories"}),e.jsx(jt,{children:"Last Upload"})]})}),e.jsx(qn,{children:n?e.jsx(ks,{children:e.jsx(ut,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(ks,{children:e.jsx(ut,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(ks,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(ut,{className:"text-center",children:i.total_items>0?e.jsx(Ye,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:i.videos||"–"}),e.jsx(ut,{className:"text-center",children:i.pdfs||"–"}),e.jsx(ut,{className:"text-center",children:i.links||"–"}),e.jsx(ut,{className:"text-center",children:i.events||"–"}),e.jsx(ut,{className:"text-center",children:i.graphics||"–"}),e.jsx(ut,{className:"text-center",children:i.categories||"–"}),e.jsx(ut,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ds(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function u3s(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 h3s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function hw(t){const s=[];for(let r=0,n=t.length;rJp||t.height>Jp)&&(t.width>Jp&&t.height>Jp?t.width>t.height?(t.height*=Jp/t.width,t.width=Jp):(t.width*=Jp/t.height,t.height=Jp):t.width>Jp?(t.height*=Jp/t.width,t.width=Jp):(t.width*=Jp/t.height,t.height=Jp))}function gde(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 g3s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function y3s(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),g3s(a)}const Pp=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Pp(r,s)};function v3s(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function b3s(t,s){return Pct(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function _3s(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?v3s(r):b3s(r,n);return document.createTextNode(`${a}{${o}}`)}function e9e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=h3s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(_3s(l,r,a,n)),s.appendChild(i)}function w3s(t,s,r){e9e(t,s,":before",r),e9e(t,s,":after",r)}const t9e="application/font-woff",s9e="image/jpeg",j3s={woff:t9e,woff2:t9e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:s9e,jpeg:s9e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function N3s(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function A3e(t){const s=N3s(t).toLowerCase();return j3s[s]||""}function k3s(t){return t.split(/,/)[1]}function Swe(t){return t.search(/^(data:)/)!==-1}function S3s(t,s){return`data:${s};base64,${t}`}async function Lct(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 Hye={};function C3s(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 E3e(t,s,r){const n=C3s(t,s,r.includeQueryParams);if(Hye[n]!=null)return Hye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await Lct(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),k3s(i)));a=S3s(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 Hye[n]=a,a}async function M3s(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):gde(s)}async function T3s(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 gde(i)}const r=t.poster,n=A3e(r),a=await E3e(r,n,s);return gde(a)}async function A3s(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await Lme(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function E3s(t,s){return Pp(t,HTMLCanvasElement)?M3s(t):Pp(t,HTMLVideoElement)?T3s(t,s):Pp(t,HTMLIFrameElement)?A3s(t,s):t.cloneNode(Dct(t))}const P3s=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",Dct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function I3s(t,s,r){var n,a;if(Dct(s))return s;let o=[];return P3s(t)&&t.assignedNodes?o=hw(t.assignedNodes()):Pp(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=hw(t.contentDocument.body.childNodes):o=hw(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Pp(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>Lme(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function L3s(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):Pct(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`),Pp(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 D3s(t,s){Pp(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Pp(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function O3s(t,s){if(Pp(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function R3s(t,s,r){return Pp(s,Element)&&(L3s(t,s,r),w3s(t,s,r),D3s(t,s),O3s(t,s)),s}async function F3s(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oE3s(n,s)).then(n=>I3s(t,n,s)).then(n=>R3s(t,n,s)).then(n=>F3s(n,s))}const Oct=/url\((['"]?)([^'"]+?)\1\)/g,z3s=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,B3s=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function $3s(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function q3s(t){const s=[];return t.replace(Oct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!Swe(r))}async function U3s(t,s,r,n,a){try{const o=r?u3s(s,r):s,l=A3e(s);let i;return a||(i=await E3e(o,l,n)),t.replace($3s(s),`$1${i}$3`)}catch{}return t}function V3s(t,{preferredFontFormat:s}){return s?t.replace(B3s,r=>{for(;;){const[n,,a]=z3s.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function Rct(t){return t.search(Oct)!==-1}async function Fct(t,s,r){if(!Rct(t))return t;const n=V3s(t,r);return q3s(n).reduce((o,l)=>o.then(i=>U3s(i,l,s,r)),Promise.resolve(n))}async function Y5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await Fct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function H3s(t,s){await Y5("background",t,s)||await Y5("background-image",t,s),await Y5("mask",t,s)||await Y5("-webkit-mask",t,s)||await Y5("mask-image",t,s)||await Y5("-webkit-mask-image",t,s)}async function G3s(t,s){const r=Pp(t,HTMLImageElement);if(!(r&&!Swe(t.src))&&!(Pp(t,SVGImageElement)&&!Swe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await E3e(n,A3e(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 W3s(t,s){const n=hw(t.childNodes).map(a=>zct(a,s));await Promise.all(n).then(()=>t)}async function zct(t,s){Pp(t,Element)&&(await H3s(t,s),await G3s(t,s),await W3s(t,s))}function K3s(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 r9e={};async function n9e(t){let s=r9e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},r9e[t]=s,s}async function a9e(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),Lct(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function i9e(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 Z3s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{hw(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=n9e(c).then(m=>a9e(m,s)).then(m=>i9e(m).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(m=>{console.error("Error loading remote css",m.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(n9e(a.href).then(i=>a9e(i,s)).then(i=>i9e(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{hw(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function Y3s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>Rct(s.style.getPropertyValue("src")))}async function Q3s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=hw(t.ownerDocument.styleSheets),n=await Z3s(r,s);return Y3s(n)}function Bct(t){return t.trim().replace(/["']/g,"")}function X3s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(Bct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function J3s(t,s){const r=await Q3s(t,s),n=X3s(t);return(await Promise.all(r.filter(o=>n.has(Bct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return Fct(o.cssText,l,s)}))).join(` `)}async function eCs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await J3s(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 tCs(t,s={}){const{width:r,height:n}=Ict(t,s),a=await Lme(t,s,!0);return await eCs(a,s),await zct(a,s),K3s(a,s),await y3s(a,r,n)}async function sCs(t,s={}){const{width:r,height:n}=Ict(t,s),a=await tCs(t,s),o=await gde(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||f3s(),u=s.canvasWidth||r,m=s.canvasHeight||n;return l.width=u*c,l.height=m*c,s.skipAutoScale||x3s(l),l.style.width=`${u}`,l.style.height=`${m}`,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 rCs(t,s={}){return(await sCs(t,s)).toDataURL()}const YA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Dme={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},w9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},nCs=({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})]})]}),$ct=mt.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=Dme[s],m=[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:YA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",YA(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:m})}),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(nCs,{branding:n,dim:l})]})]})]})});$ct.displayName="LuxuryDarkTemplate";const aCs=({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})]})]}),qct=mt.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var y;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(y=t.photos)==null?void 0:y[a],u=Dme[s],m=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%":m?"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:YA(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(aCs,{branding:n,dim:l,accentColor:g})]})]})});qct.displayName="ModernCleanTemplate";const iCs=({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})]})]}),Uct=mt.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=Dme[s],m={"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:m[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:YA(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:m["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(iCs,{branding:n,dim:l})]})]})]})});Uct.displayName="BoldColorfulTemplate";const oCs=({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})]})]}),Vct=mt.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=Dme[s],m=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:m?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:m?"100%":"42%",height:m?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:m?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*(m?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:YA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",YA(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(oCs,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:m?"100%":"58%",height:m?"60%":"100%",position:"relative",overflow:"hidden",order:m?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"}})]})]})})});Vct.displayName="EditorialTemplate";const lCs=[{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:"📉"}],o9e=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Pu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Pu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Au,{className:"h-4 w-4"})}],cCs=[{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:"📰"}],l9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),c9e={"luxury-dark":$ct,"modern-clean":qct,"bold-colorful":Uct,editorial:Vct};function dCs(){const[t,s]=k.useState(""),[r,n]=k.useState("address"),[a,o]=k.useState(!1),[l,i]=k.useState([]),[c,u]=k.useState(null),[m,f]=k.useState(0),[g,y]=k.useState("just-listed"),[_,w]=k.useState(["instagram-square"]),[j,N]=k.useState("luxury-dark"),[S,M]=k.useState(!1),[I,P]=k.useState(""),[O,q]=k.useState(""),[$,z]=k.useState(""),[V,X]=k.useState(!1),[Y,J]=k.useState(!1),[Q,ce]=k.useState([]),[ne,re]=k.useState("search"),oe=k.useRef({});k.useEffect(()=>{(async()=>{const{data:{user:Me}}=await H.auth.getUser();if(!Me)return;const{data:ke}=await H.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Me.id).single();if(ke){P(ke.name||""),z(ke.avatar_url||"");const Oe=ke.brokerages;q((Oe==null?void 0:Oe.name)||"")}})()},[]);const he=async()=>{var Ae;if(t.trim()){o(!0),i([]);try{const{data:Me,error:ke}=await H.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(ke)throw ke;if(Me.error)throw new Error(Me.error);i(Me.listings||[]),((Ae=Me.listings)==null?void 0:Ae.length)===0&&me.info("No listings found. Try a different search.")}catch(Me){me.error(Me.message||"Search failed")}finally{o(!1)}}},xe=Ae=>{var Me;u(Ae),f(0),re("customize"),Ae.soldDate||(Me=Ae.status)!=null&&Me.toLowerCase().includes("sold")?y("just-sold"):y("just-listed")},ue=Ae=>{w(Me=>Me.includes(Ae)?Me.filter(ke=>ke!==Ae):[...Me,Ae])},ge=k.useCallback(async()=>{if(!(!c||_.length===0)){X(!0),ce([]),re("generate");try{await new Promise(Me=>setTimeout(Me,500));const Ae=[];for(const Me of _){const ke=`${j}-${Me}`,Oe=oe.current[ke];if(!Oe)continue;const qe=w9[Me],ve=await rCs(Oe,{width:qe.width,height:qe.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Ae.push({format:Me,imageUrl:ve})}ce(Ae),me.success(`Generated ${Ae.length} social post${Ae.length>1?"s":""}!`)}catch(Ae){me.error(Ae.message||"Generation failed")}finally{X(!1)}}},[c,_,j,m,S,I,O,$,g]),_e=async()=>{if(!(!c||_.length===0)){X(!0),ce([]),re("generate");try{const Ae={...c,photos:c.photos.length>0?[c.photos[m]]:[]},Me=[];for(const ke of _){const{data:Oe,error:qe}=await H.functions.invoke("generate-listing-social-post",{body:{listing:Ae,postType:g,format:ke,branding:S?{enabled:!0,agentName:I,brokerage:O}:{enabled:!1}}});if(qe)throw qe;if(Oe.error)throw new Error(Oe.error);Me.push({format:ke,imageUrl:Oe.imageUrl})}ce(Me),me.success(`Generated ${Me.length} AI post${Me.length>1?"s":""}!`)}catch(Ae){me.error(Ae.message||"AI generation failed")}finally{X(!1)}}},Be=()=>Y?_e():ge(),Se=(Ae,Me)=>{var Oe;const ke=document.createElement("a");ke.href=Ae,ke.download=`${((Oe=c==null?void 0:c.address)==null?void 0:Oe.replace(/\s+/g,"-"))||"listing"}-${g}-${Me}.png`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke)},Ee=c?{listing:c,postType:g,format:"instagram-square",branding:S?{enabled:!0,agentName:I,brokerage:O,agentPhotoUrl:$||void 0}:{enabled:!1},selectedPhotoIndex:m}:null;return e.jsx(Ms,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(dh,{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:()=>re("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ne==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(sn,{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&&re("customize"),disabled:!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ne==="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(nn,{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 ${ne==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(bl,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ne==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(sn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(WQe,{})]}),e.jsx(vr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(De,{className:"space-y-4",children:[e.jsx(ga,{value:r,onValueChange:Ae=>n(Ae),children:e.jsxs(fa,{children:[e.jsxs(ss,{value:"address",children:[e.jsx(aa,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ss,{value:"mls",children:[e.jsx(Lh,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:t,onChange:Ae=>s(Ae.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Ae=>Ae.key==="Enter"&&he()}),e.jsxs(G,{onClick:he,disabled:a||!t.trim(),children:[a?e.jsx(ys,{className:"h-4 w-4 animate-spin"}):e.jsx(sn,{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((Ae,Me)=>{var ke;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>xe(Ae),children:e.jsx(De,{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:(ke=Ae.photos)!=null&&ke[0]?e.jsx("img",{src:Ae.photos[0],alt:Ae.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(xn,{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:l9e(Ae.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Ae.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ae.city,", ",Ae.state," ",Ae.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Ae.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(eS,{className:"h-3 w-3"})," ",Ae.bedrooms]}),Ae.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(au,{className:"h-3 w-3"})," ",Ae.bathrooms]}),Ae.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(xS,{className:"h-3 w-3"})," ",Ae.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:Ae.mlsNumber}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:Ae.status})]})]})]})})},Ae.mlsNumber||Me)})})]})]}),ne==="customize"&&c&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Et,{className:"pb-3",children:e.jsx(Lt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(De,{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[m],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(G,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Ae=>Math.max(0,Ae-1)),disabled:m===0,children:e.jsx(tl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m+1," of ",c.photos.length]}),e.jsx(G,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Ae=>Math.min(c.photos.length-1,Ae+1)),disabled:m===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:l9e(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(G,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{re("search"),u(null)},children:[e.jsx(w0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Pe,{className:"lg:col-span-2",children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(vr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(De,{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($l,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:Y?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Y?"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:Y,onCheckedChange:J}),Y&&e.jsx(Kv,{className:"h-4 w-4 text-purple-500"})]})]}),!Y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx($l,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:cCs.map(Ae=>e.jsxs("button",{onClick:()=>N(Ae.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${j===Ae.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Ae.preview}),e.jsx("span",{className:"text-sm font-medium",children:Ae.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Ae.description})]},Ae.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:lCs.map(Ae=>e.jsxs("button",{onClick:()=>y(Ae.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${g===Ae.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Ae.icon})," ",Ae.label]},Ae.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:o9e.map(Ae=>e.jsxs("button",{onClick:()=>ue(Ae.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${_.includes(Ae.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Ae.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Ae.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ae.dimensions})]})]},Ae.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Zi,{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:[$&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:$,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(ye,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Le,{value:I,onChange:Ae=>P(Ae.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Le,{value:O,onChange:Ae=>q(Ae.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Y&&Ee&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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*(w9[_[0]||"instagram-square"].height/w9[_[0]||"instagram-square"].width)},children:(()=>{const Ae=c9e[j],Me=_[0]||"instagram-square";return e.jsx(Ae,{...Ee,format:Me})})()})})]}),e.jsx(G,{onClick:Be,disabled:_.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-5 w-5 animate-spin"})," Generating ",_.length," post",_.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Y?e.jsx(Kv,{className:"h-5 w-5"}):e.jsx(nn,{className:"h-5 w-5"}),"Generate ",_.length," Social Post",_.length>1?"s":"",Y&&e.jsx(Ye,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ne==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(ys,{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:Y?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>re("customize"),children:[e.jsx(w0,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.map((Ae,Me)=>{const ke=o9e.find(Oe=>Oe.value===Ae.format);return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Ae.imageUrl,alt:`${Ae.format} social post`,className:"w-full rounded"})}),e.jsxs(De,{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:[ke==null?void 0:ke.icon,e.jsx("span",{className:"text-sm font-medium",children:ke==null?void 0:ke.label})]}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:ke==null?void 0:ke.dimensions})]}),e.jsxs(G,{size:"sm",className:"w-full gap-1.5",onClick:()=>Se(Ae.imageUrl,Ae.format),children:[e.jsx(vi,{className:"h-3.5 w-3.5"})," Download"]})]})]},Me)})})]})]}),ne==="generate"&&!Y&&c&&Ee&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:_.map(Ae=>{const Me=c9e[j],ke=w9[Ae];return e.jsx("div",{style:{width:ke.width,height:ke.height},children:e.jsx(Me,{ref:Oe=>{oe.current[`${j}-${Ae}`]=Oe},...Ee,format:Ae})},`${j}-${Ae}`)})})]})})}function uCs(){return pt({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 hCs(t){return pt({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 mCs(){const t=Qt();return Tt({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 Hct(){const t=Qt();return Tt({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 pCs(){const t=Qt();return Tt({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 fCs(){const t=Qt();return Tt({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 xCs(){const t=Qt();return Tt({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 gCs(){const t=Qt();return Tt({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 yCs(){const t=Qt();return Tt({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 vCs(){const t=Qt();return Tt({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 bCs(){const t=Qt();return Tt({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 _Cs(){return pt({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 wCs(t){return pt({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 Gct(t){return pt({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 jCs(){const t=Qt();return Tt({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 NCs(){const{user:t}=Fs(),s=ar(),{data:r,isLoading:n}=uCs(),a=mCs(),o=Hct(),l=pCs(),[i,c]=k.useState(!1),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(!0),w=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:y,created_by:t.id});me.success("Course created"),c(!1),m(""),g(""),_(!0),s(`/admin/lms/${S.id}`)}catch{me.error("Failed to create course")}},j=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(Qh,{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(G,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(co,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(G,{onClick:()=>c(!0),children:[e.jsx(qs,{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(Pe,{className:"animate-pulse",children:e.jsxs(Et,{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,I=S.access||[],P=I.length===0?"No access set":I.some($=>$.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Pe,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(Et,{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(Lt,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(vr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(Ye,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(De,{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(Ah,{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(g0,{className:"h-3.5 w-3.5"}):e.jsx(kS,{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(ur,{className:"h-3.5 w-3.5"}),P]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(G,{size:"sm",variant:"ghost",onClick:$=>{$.stopPropagation(),j(S)},children:[S.is_published?e.jsx(Cp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Tn,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(G,{size:"sm",variant:"ghost",className:"text-destructive",onClick:$=>{$.stopPropagation(),N(S.id)},children:e.jsx(kr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(ba,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Ah,{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(G,{onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:c,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Course Title"}),e.jsx(Le,{value:u,onChange:S=>m(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{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:y,onCheckedChange:_})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(G,{onClick:w,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function kCs(){const{courseId:t}=ao(),s=ar(),{data:r,isLoading:n}=hCs(t),a=Hct(),o=fCs(),l=xCs(),i=gCs(),c=yCs(),u=vCs(),m=bCs(),{data:f}=pt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:He}=await H.from("brokerages").select("id, name").order("name");return He||[]}}),[g,y]=k.useState(null),[_,w]=k.useState(!1),[j,N]=k.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,M]=k.useState(null),[I,P]=k.useState({title:"",resource_type:"link",url:""}),[O,q]=k.useState(new Set),[$,z]=k.useState(null),[V,X]=k.useState(0),[Y,J]=k.useState(!1),Q=k.useRef(null),ce=k.useRef(null),[ne,re]=k.useState(!1),[oe,he]=k.useState(""),[xe,ue]=k.useState(""),[ge,_e]=k.useState(""),[Be,Se]=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(G,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ee=r.modules||[],Ae=r.access||[],Me=Ae.some(He=>He.access_type==="all"),ke=Ae.filter(He=>He.access_type==="brokerage").map(He=>He.brokerage_id),Oe=(f||[]).filter(He=>He.name.toLowerCase().includes(oe.toLowerCase())),qe=He=>{const We=new Set(O);We.has(He)?We.delete(He):We.add(He),q(We)},ve=async()=>{if(!$)return null;J(!0),X(0);try{const{data:He,error:We}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:$.name}});if(We)throw new Error(We.message);const{videoId:tt,libraryId:Ke}=He,{data:rt,error:it}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt,libraryId:Ke}});if(it)throw new Error(it.message);const It=new XMLHttpRequest;return await new Promise((Vt,hs)=>{It.upload.onprogress=Es=>{Es.lengthComputable&&X(Math.round(Es.loaded/Es.total*100))},It.onload=()=>It.status>=200&&It.status<300?Vt():hs(new Error(`Upload failed: ${It.status}`)),It.onerror=()=>hs(new Error("Upload failed")),It.open("PUT",rt.uploadUrl),It.setRequestHeader("AccessKey",rt.apiKey),It.send($)}),`https://iframe.mediadelivery.net/embed/${Ke}/${tt}`}catch(He){return console.error("Bunny upload error:",He),me.error("Video upload failed"),null}finally{J(!1),X(0)}},dt=async()=>{if(j.title.trim())try{let He=j.video_url.trim()||void 0;if($){const We=await ve();if(!We)return;He=We}await o.mutateAsync({course_id:r.id,title:j.title.trim(),description:j.description.trim()||void 0,video_url:He,text_content:j.text_content.trim()||void 0,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):void 0,sort_order:Ee.length}),me.success("Module added"),w(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),z(null)}catch{me.error("Failed to add module")}},pe=async()=>{if(g)try{let He=j.video_url.trim()||null;if($){const We=await ve();if(!We)return;He=We}await l.mutateAsync({id:g.id,title:j.title.trim(),description:j.description.trim()||null,video_url:He,text_content:j.text_content.trim()||null,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):null}),me.success("Module updated"),y(null),z(null)}catch{me.error("Failed to update")}},Ue=async He=>{if(confirm("Delete this module?"))try{await i.mutateAsync(He),me.success("Module deleted")}catch{me.error("Failed to delete")}},Xe=async He=>{if(I.title.trim())try{await c.mutateAsync({module_id:He,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),me.success("Resource added"),M(null),P({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},et=async()=>{try{await m.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),me.success("Access updated: All brokerages / all agents")}catch{me.error("Failed to update access")}},Ce=async He=>{const We=Ae.filter(it=>it.access_type==="brokerage").map(it=>it.brokerage_id),tt=We.includes(He);let Ke;tt?Ke=We.filter(it=>it!==He):Ke=[...We,He];const rt=Ke.map(it=>({access_type:"brokerage",brokerage_id:it}));try{await m.mutateAsync({courseId:r.id,accessRules:rt}),me.success(tt?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},Je=async()=>{try{await m.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},Ge=async(He,We)=>{const tt=We==="up"?He-1:He+1;if(!(tt<0||tt>=Ee.length))try{await Promise.all([l.mutateAsync({id:Ee[He].id,sort_order:tt}),l.mutateAsync({id:Ee[tt].id,sort_order:He})])}catch{me.error("Failed to reorder")}},lt=async()=>{try{await a.mutateAsync({id:r.id,title:xe,description:ge||null}),me.success("Course updated"),Se(!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(G,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Ga,{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(Ye,{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(g0,{className:"h-3.5 w-3.5"}):e.jsx(kS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ee.length," module",Ee.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>{ue(r.title),_e(r.description||""),Se(!0)},children:[e.jsx(Pa,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(G,{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(Cp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Tn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ga,{defaultValue:"modules",className:"w-full",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"modules",children:"Modules"}),e.jsx(ss,{value:"access",children:"Access & Permissions"}),e.jsx(ss,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"modules",className:"mt-6 space-y-4",children:[Ee.map((He,We)=>e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>qe(He.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:tt=>{tt.stopPropagation(),Ge(We,"up")},disabled:We===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Sp,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:tt=>{tt.stopPropagation(),Ge(We,"down")},disabled:We===Ee.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Ji,{className:"h-3.5 w-3.5"})})]})}),e.jsx(Ye,{variant:"outline",className:"shrink-0 font-mono text-xs",children:We+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:He.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[He.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(An,{className:"h-3 w-3"})," Video"]}),He.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(wn,{className:"h-3 w-3"})," Text"]}),He.duration_minutes&&e.jsxs("span",{children:[He.duration_minutes," min"]}),He.resources&&He.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(pl,{className:"h-3 w-3"})," ",He.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{size:"sm",variant:"ghost",onClick:tt=>{var Ke;tt.stopPropagation(),y(He),N({title:He.title,description:He.description||"",video_url:He.video_url||"",text_content:He.text_content||"",duration_minutes:((Ke=He.duration_minutes)==null?void 0:Ke.toString())||""})},children:e.jsx(Pa,{className:"h-3.5 w-3.5"})}),e.jsx(G,{size:"sm",variant:"ghost",className:"text-destructive",onClick:tt=>{tt.stopPropagation(),Ue(He.id)},children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})]}),O.has(He.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[He.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:He.description}),He.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:He.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:He.video_url})]}),He.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:He.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(G,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{M(He.id),P({title:"",resource_type:"link",url:""})},children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),He.resources&&He.resources.length>0?e.jsx("div",{className:"space-y-1",children:He.resources.map(tt=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:tt.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:tt.title}),tt.url&&e.jsx("a",{href:tt.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(tt.id),children:e.jsx(Er,{className:"h-3 w-3"})})]},tt.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},He.id)),e.jsxs(G,{variant:"outline",className:"w-full border-dashed",onClick:()=>{w(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(bs,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(De,{className:"space-y-5",children:[e.jsxs("div",{className:Pt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Me?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:et,children:[e.jsx("div",{className:Pt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Me?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(Nd,{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:Me,onCheckedChange:et})]}),!Me&&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:ke.length===0?"No brokerages selected — agents won't see this course":`${ke.length} brokerage${ke.length!==1?"s":""} selected`})]}),ke.length>0&&e.jsx(G,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:Je,children:"Clear all"})]}),e.jsx(Le,{placeholder:"Search brokerages...",value:oe,onChange:He=>he(He.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Oe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Oe.map(He=>{const We=ke.includes(He.id);return e.jsxs("div",{className:Pt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",We?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ce(He.id),children:[e.jsx("div",{className:Pt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",We?"bg-primary border-primary":"border-muted-foreground/30"),children:We&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:He.name}),We&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},He.id)})})]})]})]})}),e.jsxs(bs,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(De,{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(Er,{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(p1,{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:ce,type:"file",accept:"image/*",className:"hidden",onChange:async He=>{var tt;const We=(tt=He.target.files)==null?void 0:tt[0];if(!(!We||!r)){re(!0);try{const Ke=We.name.split(".").pop(),rt=`${r.id}/thumbnail.${Ke}`,{error:it}=await H.storage.from("lms-thumbnails").upload(rt,We,{upsert:!0});if(it)throw it;const{data:It}=H.storage.from("lms-thumbnails").getPublicUrl(rt),Vt=`${It.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{re(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(G,{variant:"outline",size:"sm",disabled:ne,onClick:()=>{var He;return(He=ce.current)==null?void 0:He.click()},children:[ne?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ci,{className:"h-4 w-4 mr-2"}),ne?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Course Settings"})}),e.jsxs(De,{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:He=>a.mutateAsync({id:r.id,is_sequential:He}).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:He=>a.mutateAsync({id:r.id,is_published:He}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:_||!!g,onOpenChange:He=>{He||(w(!1),y(null))},children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{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(ye,{children:"Title"}),e.jsx(Le,{value:j.title,onChange:He=>N(We=>({...We,title:He.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:j.description,onChange:He=>N(We=>({...We,description:He.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Pt("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",$?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var He;return(He=Q.current)==null?void 0:He.click()},children:[e.jsx("input",{ref:Q,type:"file",accept:"video/*",className:"hidden",onChange:He=>{var tt;const We=(tt=He.target.files)==null?void 0:tt[0];We&&(z(We),N(Ke=>({...Ke,video_url:""})))}}),$?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:$.name}),e.jsx(G,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:He=>{He.stopPropagation(),z(null)},children:e.jsx(Er,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(ci,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),Y&&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(ys,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(qi,{value:V,className:"h-1.5"})]}),!$&&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(Le,{value:j.video_url,onChange:He=>N(We=>({...We,video_url:He.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Text Content"}),e.jsx(Tr,{value:j.text_content,onChange:He=>N(We=>({...We,text_content:He.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Duration (minutes)"}),e.jsx(Le,{type:"number",value:j.duration_minutes,onChange:He=>N(We=>({...We,duration_minutes:He.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>{w(!1),y(null),z(null)},children:"Cancel"}),e.jsxs(G,{onClick:g?pe:dt,disabled:!j.title.trim()||Y,children:[Y?e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Vc,{className:"h-4 w-4 mr-2"}),Y?"Uploading...":g?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!S,onOpenChange:He=>{He||M(null)},children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Title"}),e.jsx(Le,{value:I.title,onChange:He=>P(We=>({...We,title:He.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Type"}),e.jsxs(Rs,{value:I.resource_type,onValueChange:He=>P(We=>({...We,resource_type:He})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"link",children:"Link"}),e.jsx(ft,{value:"pdf",children:"PDF"}),e.jsx(ft,{value:"template",children:"Template"}),e.jsx(ft,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"URL"}),e.jsx(Le,{value:I.url,onChange:He=>P(We=>({...We,url:He.target.value})),placeholder:"https://..."})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsx(G,{onClick:()=>S&&Xe(S),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:Be,onOpenChange:Se,children:e.jsxs(ps,{children:[e.jsxs(js,{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(ye,{children:"Title"}),e.jsx(Le,{value:xe,onChange:He=>ue(He.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:ge,onChange:He=>_e(He.target.value),rows:3})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>Se(!1),children:"Cancel"}),e.jsx(G,{onClick:lt,disabled:!xe.trim(),children:"Save"})]})]})})]})}function SCs(){return pt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_stats");if(s)throw s;return t}})}function CCs(){return pt({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 pt({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 TCs(){const t=ar(),{data:s,isLoading:r}=SCs(),{data:n,isLoading:a}=CCs(),[o,l]=k.useState(null),{data:i,isLoading:c}=MCs(o),[u,m]=k.useState(""),f=n==null?void 0:n.find(_=>_.course_id===o),g=i==null?void 0:i.filter(_=>{var w,j;return!u||((w=_.agent_name)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=_.email)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))}),y=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Ah,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:ur,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:_o,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Bo,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:co,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(G,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Ga,{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(Qh,{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:y.map(_=>e.jsx(Pe,{className:Pt("transition-all",r&&"animate-pulse"),children:e.jsxs(De,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_.icon,{className:Pt("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(co,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Pe,{className:"animate-pulse",children:e.jsx(De,{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 w=o===_.course_id;return e.jsx(Pe,{className:Pt("cursor-pointer transition-all hover:shadow-md",w?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(w?null:_.course_id),children:e.jsxs(De,{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(Ye,{variant:_.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:_.is_published?"Live":"Draft"})]})}),e.jsx(da,{className:Pt("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",w&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.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(qi,{value:_.avg_completion_pct,className:"h-2"})]})]})},_.course_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(De,{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(ew,{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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:u,onChange:_=>m(_.target.value),placeholder:"Search agents...",className:"pl-9"})]}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(_=>e.jsx(Pe,{className:"animate-pulse",children:e.jsx(De,{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((_,w)=>{const j=_.completion_pct>=100;return e.jsx(Pe,{className:Pt("transition-all",j&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",w===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":w===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":w===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:w+1}),e.jsxs(Cn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Wa,{src:_.avatar_url||void 0}),e.jsx(Mn,{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}),j&&e.jsxs(Ye,{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(mn,{className:"h-3 w-3"}),ds(new Date(_.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Pt("text-sm font-bold",j?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[_.completion_pct,"%"]}),e.jsx(qi,{value:_.completion_pct,className:"h-1.5 mt-1"})]})]})})},_.user_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(De,{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(Pe,{className:"border-dashed",children:e.jsxs(De,{className:"py-16 text-center",children:[e.jsx(ur,{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 ACs(){const{user:t}=Fs(),s=ar(),{data:r,isLoading:n}=_Cs();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(Qh,{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(Pe,{className:"animate-pulse",children:e.jsxs(De,{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(ECs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Ah,{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 ECs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Gct(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(Pe,{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(Qh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(De,{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(Ah,{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(g0,{className:"h-3.5 w-3.5"}):e.jsx(kS,{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(qi,{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 PCs(){const{courseId:t}=ao(),s=ar(),{user:r}=Fs(),{data:n,isLoading:a}=wCs(t),{data:o}=Gct(t),l=jCs(),[i,c]=k.useState(null),u=(n==null?void 0:n.modules)||[],m=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),f=m.size,g=u.length>0?Math.round(f/u.length*100):0;k.useEffect(()=>{if(u.length>0&&!i){const S=u.find(M=>!m.has(M.id));c((S==null?void 0:S.id)||u[0].id)}},[u,i,m]);const y=u.find(S=>S.id===i),_=u.findIndex(S=>S.id===i),w=(S,M)=>{if(!(n!=null&&n.is_sequential)||M===0)return!1;for(let I=0;I{if(!(!y||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:y.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 I=S.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const P=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return P?`https://iframe.mediadelivery.net/embed/${P[1]}/${P[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(G,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Ga,{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(qi,{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(Pe,{className:"lg:sticky lg:top-4",children:e.jsxs(De,{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(Li,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,M)=>{const I=w(S,M),P=m.has(S.id),O=S.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&c(S.id),className:Pt("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",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx(zd,{className:"h-4 w-4 text-muted-foreground"}):P?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(jd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Pt("font-medium truncate",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(mn,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:y?e.jsxs(e.Fragment,{children:[y.video_url&&e.jsx(Pe,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:N(y.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Pe,{children:e.jsxs(De,{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:y.title}),y.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:y.description})]}),m.has(y.id)?e.jsxs(Ye,{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(G,{size:"sm",onClick:j,disabled:l.isPending,children:[e.jsx(sa,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),y.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:y.text_content}),y.resources&&y.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:y.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(wn,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(Qh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(pl,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(rn,{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(G,{variant:"outline",size:"sm",disabled:_===0,onClick:()=>_>0&&c(u[_-1].id),children:[e.jsx(Ga,{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(Ye,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Pe,{children:e.jsx(De,{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(G,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function ICs({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(ba,{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 Lf({children:t,className:s="",delay:r=0,direction:n="up"}){const a=k.useRef(null),o=E3(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 LCs({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(Lf,{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(Lf,{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 DCs({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(Lf,{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(ur,{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(Lf,{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(Er,{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 OCs({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(Lf,{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(Lf,{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(g1,{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 RCs({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(Lf,{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(Lf,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(Le,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(Tr,{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(G,{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(ba,{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(ou,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function FCs({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o,showConfidentialBadges:l=!0}){const[i,c]=k.useState(1),[u,m]=k.useState(""),f=3,g=!!t.first_name&&!!t.email,y=_=>{m(_),s(w=>({...w,why_interested:_})),setTimeout(()=>c(2),200)};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(Lf,{children:e.jsxs("div",{className:"text-center mb-8",children:[l&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold bg-white/15 text-white backdrop-blur mb-4",children:[e.jsx(zd,{className:"h-2.5 w-2.5"})," 100% Confidential"]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Start a Confidential Conversation"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"No high-pressure sales calls. Ever."})]})}),e.jsx(Lf,{delay:.15,children:e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-7",children:[[1,2,3].map(_=>e.jsx("div",{className:"h-1 flex-1 rounded-full transition-colors duration-500",style:{backgroundColor:_<=i?a:"#e5e7eb"}},_)),e.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[i,"/",f]})]}),e.jsxs(pNe,{mode:"wait",children:[i===1&&e.jsxs(gs.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-3",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"What's most important to you?"}),e.jsx("p",{className:"text-sm text-gray-500 mb-5",children:"Pick the one that resonates most. We'll tailor the conversation."}),[{val:"Better commission split / cap",label:"Better Splits & Caps",icon:"💰"},{val:"Better technology and tools",label:"Better Tech & Tools",icon:"🛠️"},{val:"Better training and mentorship",label:"Better Training",icon:"📚"},{val:"Better culture and team",label:"Better Culture",icon:"🤝"},{val:"Just exploring options confidentially",label:"Just Exploring",icon:"🔍"}].map(_=>e.jsxs("button",{type:"button",onClick:()=>y(_.val),className:"w-full flex items-center gap-3 p-4 rounded-xl border-2 border-gray-100 hover:border-gray-300 transition-all text-left group",children:[e.jsx("span",{className:"text-2xl",children:_.icon}),e.jsx("span",{className:"font-medium text-gray-700 group-hover:text-gray-900 flex-1",children:_.label}),e.jsx(ba,{className:"h-4 w-4 text-gray-300 group-hover:text-gray-500 group-hover:translate-x-1 transition-all"})]},_.val))]},"step1"),i===2&&e.jsxs(gs.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"How can we reach you?"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"We'll text first, on your schedule."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(Le,{required:!0,value:t.first_name,onChange:_=>s(w=>({...w,first_name:_.target.value})),className:"h-11",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(Le,{value:t.last_name,onChange:_=>s(w=>({...w,last_name:_.target.value})),className:"h-11",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(Le,{type:"email",required:!0,value:t.email,onChange:_=>s(w=>({...w,email:_.target.value})),className:"h-11",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Phone (preferred)"}),e.jsx(Le,{value:t.phone,onChange:_=>s(w=>({...w,phone:_.target.value})),className:"h-11",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(G,{type:"button",variant:"ghost",onClick:()=>c(1),className:"h-11",children:[e.jsx(Ga,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsxs(G,{type:"button",disabled:!g,onClick:()=>c(3),className:"flex-1 h-11 text-white font-semibold",style:{background:`linear-gradient(135deg, ${a}, ${o})`},children:["Continue ",e.jsx(ba,{className:"h-4 w-4 ml-1"})]})]})]},"step2"),i===3&&e.jsxs(gs.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",style:{color:o},children:"A few quick details (optional)"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"Helps us prepare a more personalized comp comparison."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(Le,{value:t.current_brokerage,onChange:_=>s(w=>({...w,current_brokerage:_.target.value})),className:"h-11",placeholder:"(stays private)"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(Le,{type:"number",min:"0",value:t.experience_years,onChange:_=>s(w=>({...w,experience_years:_.target.value})),className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(Le,{value:t.annual_production,onChange:_=>s(w=>({...w,annual_production:_.target.value})),className:"h-11",placeholder:"e.g. $5M"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-gray-700 text-sm font-medium",children:"Anything else?"}),e.jsx(Tr,{value:t.why_interested,onChange:_=>s(w=>({...w,why_interested:_.target.value})),rows:2,className:"resize-none",placeholder:"Optional message..."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(G,{type:"button",variant:"ghost",onClick:()=>c(2),className:"h-11",children:[e.jsx(Ga,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsx(G,{type:"button",onClick:r,disabled:n,className:"flex-1 h-12 text-white font-semibold rounded-xl",style:{background:`linear-gradient(135deg, ${a}, ${o})`},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"}),"Sending..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4"})," Start the Conversation"]})})]})]},"step3")]}),l&&e.jsxs("div",{className:"mt-6 pt-5 border-t border-gray-100 grid grid-cols-3 gap-2 text-[10px] text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(ou,{className:"h-3 w-3"})," Confidential"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Ki,{className:"h-3 w-3"})," Text first"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Nn,{className:"h-3 w-3"})," No spam"]})]})]})})]})]})}function zCs({config:t,primaryColor:s,accentColor:r,brokerageId:n,brokerageName:a}){const{toast:o}=Ra(),[l,i]=k.useState("250000"),[c,u]=k.useState("70"),[m,f]=k.useState("150"),[g,y]=k.useState(""),[_,w]=k.useState(!1),[j,N]=k.useState(!1),S=t.commission_split_pct??80,M=t.cap_amount??16e3,I=t.monthly_fee??99,P=t.transaction_fee??0,O=k.useMemo(()=>{const z=parseFloat(l)||0,V=parseFloat(c)||0,X=parseFloat(m)||0,Y=z*(V/100)-X*12,J=1-S/100,Q=z*J,ce=Math.min(Q,M),ne=z-ce-I*12-P,re=ne-Y;return{currentNet:Y,newNet:ne,diff:re}},[l,c,m,S,M,I,P]),q=z=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(z),$=async z=>{if(z.preventDefault(),!!g){N(!0);try{const{error:V}=await H.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:g,source:"calculator"});if(V)throw V;w(!0),o({title:"Sent!",description:"Check your email for the full breakdown."})}catch(V){o({title:"Error",description:V.message,variant:"destructive"})}finally{N(!1)}}};return e.jsx("section",{className:"py-20 md:py-28 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(Lf,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-semibold mb-4",style:{backgroundColor:`${s}15`,color:r},children:[e.jsx(zd,{className:"h-3 w-3"})," 100% Confidential — No Signup Required"]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-3",style:{color:r},children:t.headline||"See What You Could Earn With Us"}),e.jsx("p",{className:"text-gray-500 text-lg font-light max-w-xl mx-auto",children:t.subtext||"Confidential 60-second calculator — no signup required."})]})}),e.jsx(Lf,{delay:.15,children:e.jsxs("div",{className:"bg-white rounded-3xl shadow-xl overflow-hidden grid md:grid-cols-2",children:[e.jsxs("div",{className:"p-8 md:p-10 border-r border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(rS,{className:"h-5 w-5",style:{color:s}}),e.jsx("h3",{className:"font-semibold",style:{color:r},children:"Your Numbers"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-gray-600 text-sm",children:"Your GCI Last 12 Months"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx(Le,{type:"number",value:l,onChange:z=>i(z.target.value),className:"pl-7 h-11 text-base",placeholder:"250,000"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-gray-600 text-sm",children:"Your Current Commission Split (%)"}),e.jsx(Le,{type:"number",value:c,onChange:z=>u(z.target.value),className:"mt-1.5 h-11 text-base",placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-gray-600 text-sm",children:"Your Current Monthly Fees"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx(Le,{type:"number",value:m,onChange:z=>f(z.target.value),className:"pl-7 h-11 text-base",placeholder:"150"})]})]})]})]}),e.jsxs("div",{className:"p-8 md:p-10 text-white",style:{background:`linear-gradient(160deg, ${r}, ${s})`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(Bo,{className:"h-5 w-5"}),e.jsxs("h3",{className:"font-semibold",children:["Your Earnings at ",a]})]}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between border-b border-white/20 pb-3",children:[e.jsx("span",{className:"text-white/70 text-sm",children:"Current take-home"}),e.jsx("span",{className:"text-xl font-semibold",children:q(O.currentNet)})]}),e.jsxs("div",{className:"flex items-baseline justify-between border-b border-white/20 pb-3",children:[e.jsx("span",{className:"text-white/70 text-sm",children:"With us"}),e.jsx("span",{className:"text-xl font-semibold",children:q(O.newNet)})]})]}),e.jsxs(gs.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},className:"bg-white/10 backdrop-blur rounded-2xl p-5 text-center",children:[e.jsx("p",{className:"text-white/80 text-xs uppercase tracking-wide mb-1",children:O.diff>=0?"You could earn":"Difference"}),e.jsxs("p",{className:"text-4xl font-bold mb-1",children:[O.diff>=0?"+":"",q(O.diff)]}),e.jsx("p",{className:"text-white/70 text-xs",children:O.diff>=0?"more per year":"per year"})]},O.diff),t.show_email_capture&&!_&&e.jsxs("form",{onSubmit:$,className:"mt-6 space-y-2",children:[e.jsx("p",{className:"text-white/80 text-xs",children:t.email_capture_label||"Want the full breakdown? Enter your email."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{type:"email",required:!0,value:g,onChange:z=>y(z.target.value),placeholder:"you@email.com",className:"bg-white/95 border-0 text-gray-900 h-10 text-sm"}),e.jsx(G,{type:"submit",disabled:j,className:"h-10 bg-white text-gray-900 hover:bg-white/90 text-sm font-semibold",children:"Send"})]})]}),_&&e.jsxs("div",{className:"mt-6 flex items-center gap-2 text-sm text-white/90 bg-white/10 rounded-lg p-3",children:[e.jsx(ua,{className:"h-4 w-4"})," Check your inbox shortly."]})]})]})}),e.jsx("p",{className:"text-center text-xs text-gray-400 mt-4",children:"Estimates only. Actual results vary by individual production and plan terms."})]})})}function BCs({config:t,primaryColor:s,accentColor:r,brokerageId:n}){const{toast:a}=Ra(),[o,l]=k.useState(""),[i,c]=k.useState(""),[u,m]=k.useState(!1),[f,g]=k.useState(!1),y=async _=>{_.preventDefault(),g(!0);try{const{error:w}=await H.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:o,first_name:i||null,source:"lead_magnet",user_agent:navigator.userAgent,referrer:document.referrer||null});if(w)throw w;m(!0),t.pdf_url&&window.open(t.pdf_url,"_blank","noopener,noreferrer")}catch(w){a({title:"Error",description:w.message,variant:"destructive"})}finally{g(!1)}};return e.jsx("section",{className:"py-20 md:py-24 px-6 bg-white",children:e.jsx("div",{className:"max-w-3xl mx-auto",children:e.jsx(Lf,{children:e.jsx("div",{className:"rounded-3xl p-8 md:p-12 shadow-xl border border-gray-100",style:{background:`linear-gradient(135deg, ${s}08, ${r}08)`},children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-8",children:[e.jsx("div",{className:"shrink-0 h-24 w-24 rounded-2xl flex items-center justify-center shadow-lg",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:e.jsx(oS,{className:"h-12 w-12 text-white"})}),e.jsxs("div",{className:"flex-1 text-center md:text-left",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold mb-3",style:{backgroundColor:`${s}15`,color:r},children:[e.jsx(zd,{className:"h-2.5 w-2.5"})," No call required — instant download"]}),e.jsx("h3",{className:"text-2xl md:text-3xl font-bold tracking-tight mb-2",style:{color:r},children:t.title||"Get the Full Comp Plan PDF"}),e.jsx("p",{className:"text-gray-500 leading-relaxed mb-5",children:t.description||"See exactly how splits, caps, and fees work — no call required."}),u?e.jsxs("div",{className:"flex items-center gap-2 p-4 rounded-xl bg-green-50 border border-green-200 text-green-800 text-sm",children:[e.jsx(ua,{className:"h-5 w-5 shrink-0"}),e.jsxs("span",{children:["Sent! ",t.pdf_url?"Your download should open in a new tab.":"Check your email shortly."]})]}):e.jsxs("form",{onSubmit:y,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(Le,{value:i,onChange:_=>c(_.target.value),placeholder:"First name (optional)",className:"h-11"}),e.jsx(Le,{type:"email",required:!0,value:o,onChange:_=>l(_.target.value),placeholder:"your@email.com",className:"h-11"})]}),e.jsxs(G,{type:"submit",disabled:f,className:"w-full sm:w-auto h-12 px-6 text-white font-semibold",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:[e.jsx(oS,{className:"h-4 w-4 mr-2"}),f?"Sending...":t.button_text||"Email Me the PDF"]})]})]})]})})})})})}function $Cs(){const{slug:t}=ao(),{toast:s}=Ra(),[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:""});k.useEffect(()=>{document.body.classList.add("recruit-landing-page");const z=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]",'div[id^="hubspot"]',".widget-visible"].forEach(J=>document.querySelectorAll(J).forEach(Q=>Q.style.display="none"))};z();const V=[setTimeout(z,500),setTimeout(z,1500),setTimeout(z,3e3)],X=new MutationObserver(z);return X.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-landing-page"),V.forEach(clearTimeout),X.disconnect()}},[]);const{data:l,isLoading:i,error:c}=pt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:z,error:V}=await H.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(V)throw V;return z},enabled:!!t}),{data:u}=pt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:z,error:V}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(V&&V.code!=="PGRST116")throw V;return z},enabled:!!(l!=null&&l.id)}),m=Tt({mutationFn:async()=>{const z={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:V}=await H.from("recruit_interest_submissions").insert(z);if(V)throw V;H.functions.invoke("recruit-lead-notify",{body:{lead:z,brokerage_id:l.id}}).catch(X=>console.error("Lead notification error:",X))},onSuccess:()=>n(!0),onError:z=>s({title:"Error",description:z.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(Ta,{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",y=(f==null?void 0:f.accent_color)||"#2a4c64",_=(f==null?void 0:f.benefits)||[],w=(f==null?void 0:f.testimonials)||[],j=(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.",M=(f==null?void 0:f.calculator_enabled)===!0,I=(f==null?void 0:f.calculator_config)||{},P=(f==null?void 0:f.lead_magnet_enabled)===!0,O=(f==null?void 0:f.lead_magnet_config)||{},q=(f==null?void 0:f.form_style)||"classic",$=(f==null?void 0:f.confidential_messaging)!==!1;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}, ${y})`},children:e.jsx(ua,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:y},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:y},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":y},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:y},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}, ${y})`},children:["Apply Now ",e.jsx(ba,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(ICs,{headline:N,subtext:S,primaryColor:g,accentColor:y,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(LCs,{benefits:_,accentColor:y,primaryColor:g}),e.jsx(DCs,{images:j,primaryColor:g,accentColor:y}),e.jsx(OCs,{testimonials:w,primaryColor:g,accentColor:y}),M&&e.jsx(zCs,{config:I,primaryColor:g,accentColor:y,brokerageId:l.id,brokerageName:l.name}),P&&e.jsx(BCs,{config:O,primaryColor:g,accentColor:y,brokerageId:l.id}),q==="multi_step"?e.jsx(FCs,{form:a,setForm:o,onSubmit:()=>m.mutate(),isPending:m.isPending,primaryColor:g,accentColor:y,showConfidentialBadges:$}):e.jsx(RCs,{form:a,setForm:o,onSubmit:()=>m.mutate(),isPending:m.isPending,primaryColor:g,accentColor:y}),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 qCs(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 UCs(){var g,y,_,w;const{shareToken:t}=ao(),s=k.useRef(!1),{data:r,isLoading:n,error:a}=pt({queryKey:["public-recruit-video",t],queryFn:async()=>{var P;if(!t)throw new Error("No token");const{data:j,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",(P=j.video)==null?void 0:P.owner_user_id).single(),{data:M}=await H.from("brokerages").select("name").eq("id",j.brokerage_id).single(),{data:I}=await H.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",j.brokerage_id).maybeSingle();return{rv:j,profile:S,brokerage:M,settings:I}},enabled:!!t});if(k.useEffect(()=>{var j;!((j=r==null?void 0:r.rv)!=null&&j.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",m=((y=o.prospect)==null?void 0:y.first_name)||"there",f=(_=o.video)!=null&&_.playback_url?qCs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Pl,{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 ",m,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(G,{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(fn,{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"})]})]})}const VCs="relzejiswnotikjgvjhz",d9e=`https://${VCs}.supabase.co/functions/v1/recruit-unsubscribe`;function HCs(){const[t]=Ul(),s=t.get("token")||"",[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(""),[m,f]=k.useState({});k.useEffect(()=>{document.body.classList.add("recruit-unsubscribe-page");const y=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]",'div[id^="hubspot"]',".widget-visible"].forEach(N=>document.querySelectorAll(N).forEach(S=>S.style.display="none"))};y();const _=[setTimeout(y,500),setTimeout(y,1500),setTimeout(y,3e3)],w=new MutationObserver(y);return w.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-unsubscribe-page"),_.forEach(clearTimeout),w.disconnect()}},[]),k.useEffect(()=>{if(!s){f({error:"Missing unsubscribe token in link."}),n(!1);return}fetch(`${d9e}?token=${encodeURIComponent(s)}`).then(async y=>{const _=await y.json();if(!y.ok)throw new Error(_.error||"Lookup failed");f(_),_.already_unsubscribed&&i(!0)}).catch(y=>f({error:y.message||"Could not load status"})).finally(()=>n(!1))},[s]);const g=async()=>{o(!0);try{const y=await fetch(d9e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:s,reason:c.trim()||null})}),_=await y.json();if(!y.ok)throw new Error(_.error||"Failed");i(!0)}catch(y){f({...m,error:y.message||"Could not unsubscribe"})}finally{o(!1)}};return 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.jsx("div",{className:"w-full max-w-lg bg-white rounded-2xl shadow-xl border border-slate-200 p-8 sm:p-10",children:r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-slate-500",children:[e.jsx(ys,{className:"h-8 w-8 animate-spin"}),e.jsx("p",{className:"text-sm",children:"Loading…"})]}):m.error?e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(ul,{className:"h-7 w-7 text-red-500"})}),e.jsx("h1",{className:"text-xl font-semibold text-slate-800",children:"Link Invalid"}),e.jsx("p",{className:"text-sm text-slate-500",children:m.error}),e.jsx("p",{className:"text-xs text-slate-400 pt-2",children:"If you continue to receive emails you don't want, please reply directly to one of them and we'll remove you immediately."})]}):l?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-emerald-50 flex items-center justify-center",children:e.jsx(sa,{className:"h-7 w-7 text-emerald-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["You're unsubscribed",m.first_name?`, ${m.first_name}`:""]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You won't receive any more recruiting emails from ",m.brokerage_name||"this brokerage",". Your conversation remains 100% confidential."]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-slate-400 pt-2",children:[e.jsx(jS,{className:"h-3.5 w-3.5"}),"Confidential opt-out · Confirmed"]})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(jS,{className:"h-7 w-7 text-slate-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["Unsubscribe",m.first_name?`, ${m.first_name}`:"","?"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You'll be removed from ",m.brokerage_name||"this brokerage","'s recruiting emails immediately. Everything stays confidential."]}),m.email&&e.jsx("p",{className:"text-xs text-slate-400",children:m.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"reason",className:"text-xs text-slate-500",children:"Optional — what's the main reason? (helps us improve)"}),e.jsx(Tr,{id:"reason",value:c,onChange:y=>u(y.target.value),placeholder:"e.g. Not currently looking, too many emails, already moved…",rows:3,className:"resize-none"})]}),e.jsx(G,{onClick:g,disabled:a,className:"w-full h-11",variant:"default",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Unsubscribing…"]}):"Confirm Unsubscribe"}),e.jsx("p",{className:"text-[11px] text-slate-400 text-center",children:"No login required. We process your request instantly."})]})})})}function GCs(){const t=ar(),s=Qt(),{isAdmin:r}=Fs(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(null),{data:u,isLoading:m}=pt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:P},error:O}=await H.auth.getUser();if(O)throw O;if(!P)return[];const{data:q,error:$}=await H.from("social_accounts").select("*").eq("user_id",P.id).order("created_at",{ascending:!1});if($)throw $;return q}}),f=Tt({mutationFn:async P=>{const{data:{user:O},error:q}=await H.auth.getUser();if(q)throw q;if(!O)throw new Error("Not authenticated");const{error:$}=await H.from("social_accounts").delete().eq("id",P).eq("user_id",O.id);if($)throw $},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:P,error:O}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get authorization URL")}catch(P){console.error("Meta OAuth error:",P),me.error("Failed to start connection. Please try again."),a(!1)}},y=async()=>{a(!0);try{const{data:P,error:O}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(P){console.error("LinkedIn OAuth error:",P),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:P,error:O}=await H.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(P){console.error("Google OAuth error:",P),me.error("Failed to start Google connection. Please try again."),a(!1)}},w=(u==null?void 0:u.filter(P=>P.platform==="facebook"))||[],j=(u==null?void 0:u.filter(P=>P.platform==="instagram"))||[],N=(u==null?void 0:u.filter(P=>P.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(P=>P.platform==="google_business"))||[],M=((u==null?void 0:u.length)||0)>0,I=async(P,O)=>{l(P),c(null);try{const{data:q,error:$}=await H.functions.invoke("meta-api-test",{body:{testType:"all",accountId:P}});if($)throw $;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(Ye,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(nn,{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(G,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(De,{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(mn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(Ye,{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(Pe,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(De,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(wi,{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(Pe,{children:[e.jsx(Et,{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(Au,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"Facebook"}),e.jsx(vr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(zo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(P=>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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:P.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Au,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.page_name||P.platform_username||"Facebook Page"}),e.jsx(Ye,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Facebook?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(G,{onClick:g,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{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(Pu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"Instagram"}),e.jsx(vr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(zo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.map(P=>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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:P.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Pu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",P.platform_username||"Instagram Account"]}),e.jsx(Ye,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Instagram?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(G,{onClick:g,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),j.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{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(Ap,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"LinkedIn"}),e.jsx(vr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(zo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.map(P=>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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:P.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(Ap,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.platform_username||"LinkedIn Account"}),e.jsx(Ye,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect LinkedIn?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(G,{onClick:y,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{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(Pe,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(Ye,{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(Ye,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Et,{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(aa,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"Google Business"}),e.jsx(vr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(zo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(P=>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(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:P.profile_picture_url||""}),e.jsx(Mn,{children:e.jsx(aa,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.page_name||P.platform_username||"Google Business"}),e.jsx(Ye,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Tc,{children:[e.jsx(Pm,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})}),e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Disconnect Google Business?"}),e.jsx(lc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.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(G,{onClick:r?_:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(zo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||j.length>0)&&e.jsxs(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Et,{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(Z_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(vr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(P=>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(Au,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:P.page_name||"Facebook Page"})]}),e.jsx(G,{size:"sm",variant:"outline",onClick:()=>I(P.id),disabled:o===P.id,children:o===P.id?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Z_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${P.id}`)),j.map(P=>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(Pu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",P.platform_username||"Instagram"]})]}),e.jsx(G,{size:"sm",variant:"outline",onClick:()=>I(P.id),disabled:o===P.id,children:o===P.id?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Z_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${P.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((P,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[P.status==="success"?e.jsx(sa,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):P.status==="pending"?e.jsx(ys,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(Nc,{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:P.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:P.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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-lg",children:"How it works"})}),e.jsx(De,{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 WCs(){const[t]=Ul(),s=ar(),[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"),m=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:y}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:m,callbackPath:"/social-connections/callback"}});if(y)throw y;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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[r==="loading"&&e.jsx(ys,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(wi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Nc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Lt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(G,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function KCs(){const[t]=Ul(),s=ar(),[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"),m=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:m}});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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{className:"text-center",children:[r==="loading"&&e.jsx(ys,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(wi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Nc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Lt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:r!=="loading"&&e.jsx(G,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function ZCs(){const[t]=Ul(),s=ar(),[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"),m=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,m),n("error"),o(m||"Failed to connect LinkedIn account"),me.error(m||"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:y}=await H.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(y)throw y;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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Et,{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(ys,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(wi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Nc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Lt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Ap,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(vr,{children:a})]}),e.jsx(De,{className:"flex justify-center",children:e.jsx(G,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function YCs(){const t=ar(),[s,r]=k.useState(null),{data:n,isLoading:a}=cct(s||void 0,!0),{data:o,isLoading:l}=M3e(!0),{cartItems:i}=Lue(),c=i.reduce((m,f)=>m+f.quantity,0),u=m=>{t(`/marketplace/${m.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(m=>e.jsx(ws,{className:"h-10 w-24 flex-shrink-0"},m))}),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(m=>e.jsx(ws,{className:"h-72 w-full"},m))})]})}):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(G,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(bp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(Ye,{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(G,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(m=>e.jsx(G,{variant:s===m.id?"default":"outline",size:"sm",onClick:()=>r(m.id),children:m.name},m.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(m=>{var f;return e.jsxs(Pe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(m),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[m.images&&m.images.length>0?e.jsx("img",{src:((f=m.images.find(g=>g.is_primary))==null?void 0:f.image_url)||m.images[0].image_url,alt:m.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Al,{className:"h-12 w-12 text-muted-foreground"})}),m.category&&e.jsx(Ye,{className:"absolute top-2 left-2",variant:"secondary",children:m.category.name})]}),e.jsxs(De,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:m.name}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:m.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(m.base_price).toFixed(2)]}),m.variants&&m.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.variants.length," options"]})]})]})]},m.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Al,{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 Wct=k.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Wct.displayName="Breadcrumb";const Kct=k.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Pt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Kct.displayName="BreadcrumbList";const Kie=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Pt("inline-flex items-center gap-1.5",t),...s}));Kie.displayName="BreadcrumbItem";const Cwe=k.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?S2e:"a";return e.jsx(a,{ref:n,className:Pt("transition-colors hover:text-foreground",s),...r})});Cwe.displayName="BreadcrumbLink";const Zct=k.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Pt("font-normal text-foreground",t),...s}));Zct.displayName="BreadcrumbPage";const Mwe=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(da,{})});Mwe.displayName="BreadcrumbSeparator";function QCs(){var J,Q;const{productId:t}=ao(),s=ar(),{data:r,isLoading:n}=J4s(t||""),{addToCart:a,cartItems:o}=Lue(),[l,i]=k.useState(null),[c,u]=k.useState(1),[m,f]=k.useState(0),[g,y]=k.useState(null),[_,w]=k.useState(!1),[j,N]=k.useState(!1),S=(J=r==null?void 0:r.variants)==null?void 0:J.find(ce=>ce.id===l),M=((Q=r==null?void 0:r.variants)==null?void 0:Q.filter(ce=>ce.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),P=S?Number(S.price_adjustment):0,O=I+P,q=Number((r==null?void 0:r.shipping_fee)||0),$=o.reduce((ce,ne)=>ce+ne.quantity,0),z=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;w(!0);const ne=ce.target.files[0],re=ne.name.split(".").pop(),oe=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${re}`;try{const{error:he}=await H.storage.from("marketplace").upload(oe,ne);if(he)throw he;const{data:{publicUrl:xe}}=H.storage.from("marketplace").getPublicUrl(oe);y(xe),me.success("Artwork uploaded successfully")}catch(he){me.error("Failed to upload artwork: "+he.message)}finally{w(!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)}},X=()=>{r!=null&&r.images&&f(ce=>(ce+1)%r.images.length)},Y=()=>{r!=null&&r.images&&f(ce=>(ce-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(ws,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ws,{className:"h-8 w-3/4"}),e.jsx(ws,{className:"h-6 w-1/4"}),e.jsx(ws,{className:"h-24 w-full"}),e.jsx(ws,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ms,{title:r.name,children:[e.jsx(Wct,{className:"mb-6",children:e.jsxs(Kct,{children:[e.jsx(Kie,{children:e.jsx(Cwe,{asChild:!0,children:e.jsx(la,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(Mwe,{}),e.jsx(Kie,{children:e.jsx(Cwe,{asChild:!0,children:e.jsx(la,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(Mwe,{}),e.jsx(Kie,{children:e.jsx(Zct,{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[m].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(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Y,children:e.jsx(tl,{className:"h-6 w-6"})}),e.jsx(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:X,children:e.jsx(da,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Al,{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((ce,ne)=>e.jsx("button",{onClick:()=>f(ne),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ne===m?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ce.image_url,alt:"",className:"w-full h-full object-cover"})},ce.id))}),r.video&&e.jsx(Pe,{children:e.jsxs(De,{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(Ye,{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(ye,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(ce=>e.jsxs(G,{variant:l===ce.id?"default":"outline",onClick:()=>i(ce.id),children:[ce.name,Number(ce.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(ce.price_adjustment)>0?"+":"","$",Number(ce.price_adjustment).toFixed(2),")"]})]},ce.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(G,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>y(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:z,className:"hidden",id:"artwork-upload",disabled:_}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(ci,{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(ye,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(Le,{type:"number",value:c,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(G,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(G,{size:"lg",className:"flex-1",onClick:V,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(bp,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(G,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(bp,{className:"h-5 w-5"}),$>0&&e.jsx(Ye,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:$})]})]}),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(Al,{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(G,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function XCs(){const t=ar(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=Lue(),[u,m]=k.useState(!1),[f,g]=k.useState(""),y=async()=>{if(s.length===0){me.error("Your cart is empty");return}m(!0);try{const{data:_,error:w}=await H.functions.invoke("marketplace-checkout",{body:{items:s.map(j=>{var N;return{product_id:j.product.id,variant_id:((N=j.variant)==null?void 0:N.id)||null,quantity:j.quantity,artwork_url:j.artworkUrl||null}}),notes:f.trim()||null}});if(w)throw w;if(_!=null&&_.url)c(),window.open(_.url,"_blank");else throw new Error("No checkout URL received")}catch(_){me.error("Checkout failed: "+_.message)}finally{m(!1)}};return s.length===0?e.jsx(Ms,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(j0,{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(G,{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 w,j;return e.jsx(Pe,{children:e.jsx(De,{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:((w=_.product.images.find(N=>N.is_primary))==null?void 0:w.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(j0,{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(G,{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(kr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{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(v0,{className:"h-3 w-3"})}),e.jsx(Le,{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(G,{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(qs,{className:"h-3 w-3"})})]})]})]})})},`${_.product.id}-${((j=_.variant)==null?void 0:j.id)||"base"}`)}),e.jsx(G,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Order Summary"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((_,w)=>_+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(Qo,{}),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(Qo,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Tr,{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(G,{className:"w-full",size:"lg",onClick:y,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(ba,{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 JCs(){const t=ar(),{data:s,isLoading:r}=dSs();return r?e.jsx(Ms,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(ws,{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(Al,{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(G,{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(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(De,{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:ds(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(Ye,{className:C3e[n.status],children:CT[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(G,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(rn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(da,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const u9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function e5s({currentStatus:t,statusHistory:s}){const r=u9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:u9e.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(mn,{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:CT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ds(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function t5s(){var N;const{orderId:t}=ao(),s=ar(),{data:r,isLoading:n,refetch:a}=uSs(t||""),o=pSs(),l=fSs(),[i,c]=k.useState(!1),[u,m]=k.useState(null),[f,g]=k.useState(""),[y,_]=k.useState(null),w=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)}},j=async()=>{if(u){_(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),c(!1),g(""),m(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(ws,{className:"h-64 w-full"}),e.jsx(ws,{className:"h-48 w-full"})]}),e.jsx(ws,{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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsx(Lt,{children:"Order Status"}),e.jsx(Ye,{className:C3e[r.status],children:CT[r.status]})]}),e.jsx(De,{children:e.jsx(e5s,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Items"})}),e.jsx(De,{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(K_,{className:"h-4 w-4"}),"View Artwork",e.jsx(rn,{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(K_,{className:"h-4 w-4"}),"View Proof",e.jsx(rn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(G,{size:"sm",onClick:()=>w(S.id),disabled:y===S.id,children:[y===S.id?e.jsx(ys,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(ah,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>{m(S.id),c(!0)},disabled:y===S.id,children:[e.jsx(YL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(Ye,{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(Ye,{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(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(aT,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(De,{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(G,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(rn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Order Summary"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ds(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(Qo,{}),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(Qo,{}),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(Qo,{}),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(js,{children:[e.jsx(vs,{children:"Request Changes"}),e.jsx(Gr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Tr,{placeholder:"Describe the changes needed...",value:f,onChange:S=>g(S.target.value),rows:4}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(G,{onClick:j,disabled:!f.trim()||y!==null,children:[y?e.jsx(ys,{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(Al,{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(G,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function s5s(){const t=ar(),[s]=Ul();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(Pe,{children:e.jsxs(De,{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(Al,{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(G,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(ba,{className:"h-4 w-4 ml-2"})]}),e.jsx(G,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function r5s(){const{user:t}=Fs(),[s,r]=k.useState("store"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,m]=k.useState(5),[f,g]=k.useState(""),[y,_]=k.useState(!1),[w,j]=k.useState(!1),[N,S]=k.useState(""),[M,I]=k.useState(null),[P,O]=k.useState(!1),{hasSubmittedReview:q,submitReview:$,markPostedToGoogle:z}=uQe(),{data:V}=uct(),{data:X,isLoading:Y}=dct(),{data:J,isLoading:Q}=wSs(n),{data:ce,isLoading:ne}=jSs(t==null?void 0:t.id),{data:re=0}=kSs(t==null?void 0:t.id),oe=SSs(),he=new Set((ce==null?void 0:ce.map(Ee=>Ee.item_id))||[]),xe=async()=>{if(o)try{const Ee=await oe.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(Ee){me.error(Ee.message||"Failed to purchase item")}},ue=async()=>{if(!f.trim()){me.error("Please write a review");return}_(!0);const Ee=await $(u,f);_(!1),Ee.success?(me.success("Thank you for your review! You earned 25 points!"),S(f),j(!0),g(""),m(5)):me.error(Ee.error||"Failed to submit review")},ge=()=>{navigator.clipboard.writeText(N),me.success("Review copied to clipboard!")},_e=()=>{z(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Be=()=>{j(!1),c(!1),S("")};return Y||Q||ne?e.jsx(Ms,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ws,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Ee=>e.jsx(ws,{className:"h-64"},Ee))})]})}):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(Pe,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(De,{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(ea,{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:re.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(_o,{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(rh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(bf,{open:P,onOpenChange:O,children:e.jsxs(Pe,{className:"border-primary/20",children:[e.jsx(_f,{asChild:!0,children:e.jsx(Et,{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(_o,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-base",children:"How to Earn Points"}),e.jsx(vr,{children:"See all the ways you can earn spendable points"})]})]}),P?e.jsx(Sp,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Ji,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(wf,{children:e.jsx(De,{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(Ee=>Ee.is_active).map(Ee=>{const Ae=Me=>{switch(Me){case"event_attendance":return e.jsx(fn,{className:"h-5 w-5"});case"leave_review":return e.jsx(ea,{className:"h-5 w-5"});case"add_listing":return e.jsx(xn,{className:"h-5 w-5"});case"first_contact":return e.jsx(ur,{className:"h-5 w-5"});case"first_video":return e.jsx(An,{className:"h-5 w-5"});case"first_community_post":return e.jsx(Ki,{className:"h-5 w-5"});default:return e.jsx(bo,{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:Ae(Ee.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ee.action_name}),Ee.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ee.description})]}),e.jsxs(Ye,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ee.points]})]},Ee.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(rh,{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(Ye,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!q&&e.jsx(Pe,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(De,{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(Ki,{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(G,{onClick:()=>c(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(ea,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ga,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"store",className:"flex items-center gap-2",children:[e.jsx(j0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ss,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(bs,{value:"store",className:"mt-6",children:[X&&X.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(G,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),X.map(Ee=>e.jsxs(G,{variant:n===Ee.id?"default":"outline",size:"sm",onClick:()=>a(Ee.id),children:[Ee.icon&&`${Ee.icon} `,Ee.name]},Ee.id))]}),!J||J.length===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(bo,{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:J.map(Ee=>{const Ae=Ee.item_type==="reelflow_credits",Me=!Ae&&he.has(Ee.id),ke=!Ae&&Ee.max_quantity!==null&&Ee.current_quantity===0,Oe=re>=Ee.points_cost;return e.jsxs(Pe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Me?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Ee),children:[Ee.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ee.preview_image_url,alt:Ee.name,className:"w-full h-full object-cover"}),Me&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})}),ke&&!Me&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Ye,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(bo,{className:"h-12 w-12 text-muted-foreground/50"}),Me&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Ye,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Et,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Lt,{className:"text-lg",children:Ee.name}),e.jsxs(Ye,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),Ee.points_cost]})]}),Ee.category&&e.jsxs(Ye,{variant:"outline",className:"w-fit",children:[Ee.category.icon&&`${Ee.category.icon} `,Ee.category.name]})]}),e.jsxs(De,{children:[e.jsx(vr,{className:"mb-4 line-clamp-2",children:Ee.description||"No description available"}),Ee.max_quantity!==null&&!Me&&!Ae&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ee.current_quantity," of ",Ee.max_quantity," remaining"]}),Ae&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Ee.max_quantity," ReelFlow credits per purchase"]}),Me?e.jsx(G,{className:"w-full",onClick:qe=>{qe.stopPropagation(),Ee.file_url&&Vye(Ee.file_url,Ee.name)},disabled:!Ee.file_url,children:Ee.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(G,{className:"w-full",onClick:qe=>{qe.stopPropagation(),l(Ee)},disabled:ke||!Oe,children:ke?"Sold Out":Oe?e.jsxs(e.Fragment,{children:[e.jsx(j0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ee.points_cost-re} more pts`})]})]},Ee.id)})})]}),e.jsx(bs,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Pe,{children:e.jsx(De,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Al,{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:ce.map(Ee=>{var Ae,Me,ke,Oe,qe,ve,dt;return e.jsxs(Pe,{className:"overflow-hidden",children:[(Ae=Ee.item)!=null&&Ae.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ee.item.preview_image_url,alt:((Me=Ee.item)==null?void 0:Me.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(bo,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Et,{className:"pb-2",children:[e.jsx(Lt,{className:"text-lg",children:((ke=Ee.item)==null?void 0:ke.name)||"Unknown Item"}),e.jsxs(vr,{className:"text-xs",children:["Purchased for ",Ee.points_spent," points • ",new Date(Ee.purchased_at).toLocaleDateString()]})]}),e.jsx(De,{children:((Oe=Ee.item)==null?void 0:Oe.item_type)==="reelflow_credits"?e.jsxs(G,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(sa,{className:"h-4 w-4 mr-2 text-green-500"}),(qe=Ee.item)==null?void 0:qe.max_quantity," Credits Applied"]}):e.jsx(G,{className:"w-full",onClick:()=>{var pe,Ue;(pe=Ee.item)!=null&&pe.file_url&&Vye(Ee.item.file_url,(Ue=Ee.item)==null?void 0:Ue.name)},disabled:!((ve=Ee.item)!=null&&ve.file_url),children:((dt=Ee.item)==null?void 0:dt.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ee.id)})})})]})]}),e.jsx(Tc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Confirm Purchase"}),e.jsxs(lc,{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:[re," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[re-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:xe,disabled:oe.isPending,children:oe.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Ee=>{!Ee&&w?Be():c(Ee)},children:e.jsx(ps,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(js,{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(G,{variant:"outline",className:"w-full",onClick:ge,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(Rn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(G,{variant:"outline",onClick:Be,children:"Maybe Later"}),e.jsxs(G,{onClick:_e,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{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(Ee=>e.jsx("button",{type:"button",onClick:()=>m(Ee),className:"focus:outline-none",children:e.jsx(ea,{className:`h-8 w-8 transition-colors ${u>=Ee?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ee))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Tr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ee=>g(Ee.target.value),rows:4})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(G,{onClick:ue,disabled:y,className:"bg-yellow-600 hover:bg-yellow-700",children:y?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(fs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[M==null?void 0:M.name,e.jsxs(Ye,{variant:"secondary",className:"font-bold",children:[e.jsx(ea,{className:"h-3 w-3 mr-1"}),M==null?void 0:M.points_cost]})]}),(M==null?void 0:M.category)&&e.jsxs(Ye,{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&&!he.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(Rn,{children:M&&M.item_type!=="reelflow_credits"&&he.has(M.id)?e.jsx(G,{className:"w-full",onClick:()=>{M.file_url&&Vye(M.file_url,M.name)},disabled:!M.file_url,children:M.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})}):M&&e.jsx(G,{className:"w-full",onClick:()=>{I(null),l(M)},disabled:M.item_type!=="reelflow_credits"&&M.max_quantity!==null&&M.current_quantity===0||re{const{user:t}=Fs(),s=Qt(),r=pt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:m}=await H.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(m)throw m;return u||[]},enabled:!!t}),n=pt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:m}=await H.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(m)throw m;return u||[]},enabled:!!t}),a=Tt({mutationFn:async u=>{const{data:m,error:f}=await H.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return m},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Tt({mutationFn:async({id:u,...m})=>{const{data:f,error:g}=await H.from("smart_presentations").update(m).eq("id",u).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Tt({mutationFn:async u=>{const{data:m,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 m},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=Tt({mutationFn:async u=>{const{error:m}=await H.from("smart_presentations").update({status:"archived"}).eq("id",u);if(m)throw m},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation archived")}}),c=Tt({mutationFn:async u=>{const{error:m}=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(m)throw m},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}},n5s=()=>{const t=ar(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Yct(),o=i=>i.status==="draft"?e.jsx(Ye,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(Ye,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(Ye,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(Ye,{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(G,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(ws,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Pe,{children:e.jsxs(De,{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(sy,{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(G,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsx(De,{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(wn,{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 ",ds(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{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(G,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(G,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(vx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(La,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(La,{onClick:()=>a.mutate(i),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(La,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(zM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},h9e={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."}]},a5s=[{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 i5s(t){const s=h9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(h9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return a5s}function o5s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState("script"),[i,c]=k.useState(0),[u,m]=k.useState(0),{canRecord:f}=wit(),g=B3(),[y,_]=k.useState(""),[w,j]=k.useState(!1),[N,S]=k.useState(!0),[M,I]=k.useState(!1),[P,O]=k.useState(null),q=i5s(t),$=()=>{l("script"),c(0),m(0),_(""),j(!1),S(!0),I(!1),O(null)},z=Q=>{!Q&&(o==="uploading"||o==="processing")||(a(Q),Q||$())},V=Q=>{O(Q),_(q[Q].text),j(!1)},X=()=>{l("record"),S(y.trim().length>0)},Y=()=>{_(""),S(!1),l("record")},J=k.useCallback(async(Q,ce)=>{l("uploading");try{const ne=t||"Presentation Video",{videoId:re,uploadUrl:oe,libraryId:he}=await ER(ne),{apiKey:xe}=await PR(re),ue=new XMLHttpRequest;ue.upload.onprogress=Ee=>{Ee.lengthComputable&&c(Ee.loaded/Ee.total*100)},await new Promise((Ee,Ae)=>{ue.onload=()=>ue.status>=200&&ue.status<300?Ee():Ae(new Error("Upload failed")),ue.onerror=()=>Ae(new Error("Upload failed")),ue.open("PUT",oe),ue.setRequestHeader("AccessKey",xe),ue.send(Q)}),l("processing");let ge=0;const _e=Date.now(),Be=9e4;let Se=null;for(;ge<4;){if(await new Promise(Ae=>setTimeout(Ae,3e3)),Date.now()-_e>Be){const Ae=Q.size/1048576,Me=`https://iframe.mediadelivery.net/embed/${he}/${re}?responsive=true`;await g.mutateAsync({bunny_video_id:re,playback_url:Me,file_size_mb:Ae,title:ne,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Me),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ee=await FA(re);if(ge=Ee.status,m(Ee.encodeProgress||0),ge===4)Se={playbackUrl:Ee.directPlayUrl,thumbnailUrl:Ee.thumbnailUrl,previewUrl:Ee.previewUrl||null,duration:Ee.length||ce,fileSizeMb:(Ee.storageSize||Q.size)/(1024*1024)};else if(ge===5||ge===6)throw new Error("Video processing failed")}if(!Se)throw new Error("No video data");await g.mutateAsync({bunny_video_id:re,contact_id:s||void 0,playback_url:Se.playbackUrl,thumbnail_url:Se.thumbnailUrl,preview_url:Se.previewUrl,duration_seconds:Se.duration,file_size_mb:Se.fileSizeMb,title:ne,status:"ready",touch_type:"presentation"}),r(Se.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ne){console.error("Recording upload error:",ne),me.error("Failed to process video. Please try again."),l("record")}},[t,s,r,g]);return e.jsxs(fs,{open:n,onOpenChange:z,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{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(js,{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((Q,ce)=>e.jsxs("button",{onClick:()=>V(ce),className:Pt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",P===ce?"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(wn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Q.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Q.text})]},ce))})]}),y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Pa,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Tr,{value:y,onChange:Q=>_(Q.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:y})]}),!y&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(Tr,{value:y,onChange:Q=>{_(Q.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(G,{variant:"ghost",size:"sm",onClick:Y,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(G,{onClick:X,disabled:!1,children:y.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(vd,{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 5 minutes. Saved to your library & auto-attached."}),y.trim()&&e.jsxs(G,{variant:"ghost",size:"sm",onClick:()=>S(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(Cp,{className:"h-3 w-3"}):e.jsx(Tn,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(Pme,{maxDurationSeconds:300,onRecordingComplete:J,onRecordingStateChange:I,onError:Q=>me.error(Q),teleprompterContent:y.trim()?e.jsx(Blt,{text:y,isVisible:N,onToggleVisibility:()=>S(!N),isRecording:M,startCountdown:!1}):void 0}),e.jsx(G,{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(ys,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(qi,{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(ys,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(qi,{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(wi,{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 l5s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState("idle"),[u,m]=k.useState(0),f=k.useRef(null),g=B3(),{data:y}=ime(),_=(y==null?void 0:y.total_storage_mb)||0,j=((y==null?void 0:y.max_storage_mb)||1024)-_,N=()=>{l(null),c("idle"),m(0)},S=q=>{!q&&i!=="idle"&&i!=="done"||(a(q),q||N())},M=q=>{var V;const $=(V=q.target.files)==null?void 0:V[0];if(!$)return;if(!$.type.startsWith("video/")){me.error("Please select a video file");return}const z=$.size/(1024*1024);if(z>500){me.error("Video file must be less than 500MB");return}if(z>j){me.error(`Not enough storage. You have ${j.toFixed(1)} MB remaining.`);return}l($)},I=k.useCallback(async()=>{if(o){c("creating"),m(0);try{const q=t||o.name,{data:$,error:z}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:q,isAgentVideo:!0}});if(z)throw new Error(z.message);const{videoId:V,libraryId:X}=$;c("uploading");const{data:Y,error:J}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(J)throw new Error(J.message);await new Promise((ne,re)=>{const oe=new XMLHttpRequest;oe.upload.addEventListener("progress",he=>{he.lengthComputable&&m(Math.round(he.loaded/he.total*100))}),oe.addEventListener("load",()=>oe.status>=200&&oe.status<300?ne():re(new Error(`Upload failed (${oe.status})`))),oe.addEventListener("error",()=>re(new Error("Upload failed"))),oe.open("PUT",Y.uploadUrl),oe.setRequestHeader("AccessKey",Y.apiKey),oe.send(o)}),c("processing");const Q=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${X}/${V}`;await g.mutateAsync({bunny_video_id:V,playback_url:ce,file_size_mb:Q,title:q,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),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]),P=()=>{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(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(ci,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(js,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Er,{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(ci,{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(ys,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:P()})]}),e.jsx(qi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>S(!1),disabled:O,children:"Cancel"}),e.jsx(G,{onClick:I,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const m9e=[{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"}],p9e=()=>{const t=ar(),{id:s}=ao(),{user:r}=Fs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Yct(),{isGmailConnected:c,gmailEmail:u}=Ff(),[m,f]=k.useState(!1),[g,y]=k.useState("client"),[_,w]=k.useState(!1),[j,N]=k.useState(""),[S,M]=k.useState([]),[I,P]=k.useState(!1),[O,q]=k.useState(null),[$,z]=k.useState(!1),[V,X]=k.useState(""),[Y,J]=k.useState(""),[Q,ce]=k.useState(""),[ne,re]=k.useState("buyer"),[oe,he]=k.useState(""),[xe,ue]=k.useState(null),[ge,_e]=k.useState(""),[Be,Se]=k.useState([]),[Ee,Ae]=k.useState("schedule_call"),[Me,ke]=k.useState("Schedule a Call"),[Oe,qe]=k.useState(""),[ve,dt]=k.useState(""),[pe,Ue]=k.useState(null),[Xe,et]=k.useState(s||null),[Ce,Je]=k.useState(null),[Ge,lt]=k.useState(!1),He=async(Ft,Ps)=>{if(!r)return;const yr=5*1024*1024;if(Ft.size>yr){me.error("Image must be under 5MB");return}if(!Ft.type.startsWith("image/")){me.error("Please upload an image file");return}Ue(Ps);try{const Is=Ft.name.split(".").pop()||"jpg",Ar=`${r.id}/${Date.now()}.${Is}`,{error:tn}=await H.storage.from("listing-photos").upload(Ar,Ft);if(tn)throw tn;const{data:{publicUrl:na}}=H.storage.from("listing-photos").getPublicUrl(Ar);It(Ps,{image_url:na}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{Ue(null)}};k.useEffect(()=>{s&&We(s)},[s]);const We=async Ft=>{const{data:Ps,error:yr}=await H.from("smart_presentations").select("*").eq("id",Ft).single();if(yr||!Ps)return;const Is=Ps;if(w(!0),_e(Is.title),X(Is.client_name||""),he(Is.property_address||""),Se(Is.sections||[]),Ae(Is.cta_type||"schedule_call"),ke(Is.cta_label||"Schedule a Call"),qe(Is.cta_url||""),dt(Is.heading||""),Je(Is.share_token),lt(Is.status==="published"),et(Is.id),y("builder"),Is.contact_id){const{data:Ar}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Is.contact_id).maybeSingle();Ar&&(q(Ar),J(Ar.email||""),ce(Ar.phone||""))}};k.useEffect(()=>{if(!r||j.length<1){M([]);return}const Ft=setTimeout(async()=>{P(!0);const{data:Ps}=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.%${j}%,last_name.ilike.%${j}%,email.ilike.%${j}%`).limit(10);M(Ps||[]),P(!1)},300);return()=>clearTimeout(Ft)},[j,r]);const tt=Ft=>{q(Ft),X(`${Ft.first_name} ${Ft.last_name||""}`.trim()),J(Ft.email||""),ce(Ft.phone||""),z(!1)},Ke=async()=>{if(!V.trim()){me.error("Client name is required");return}const Ft=V.trim().split(" "),Ps=Ft[0],yr=Ft.slice(1).join(" ")||null,{data:Is,error:Ar}=await H.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Ps,last_name:yr,email:Y||null,phone:Q||null,lead_source:"Smart Presentation"}).select().single();if(Ar){me.error("Failed to create client");return}q(Is),me.success("Client created & saved to Agent OS"),y("template")},rt=Ft=>{ue(Ft);const Ps=(Ft.sections||[]).map(yr=>({...yr,is_visible:!0,video_url:"",text:""}));if(Se(Ps),_e(Ft.name+(V?` for ${V}`:"")),Ft.cta_config){const yr=Ft.cta_config;Ae(yr.type||"schedule_call"),ke(yr.label||"Schedule a Call")}y("builder")},it=()=>{Se([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),_e(V?`Presentation for ${V}`:"New Presentation"),y("builder")},It=(Ft,Ps)=>{Se(yr=>yr.map((Is,Ar)=>Ar===Ft?{...Is,...Ps}:Is))},Vt=Ft=>{It(Ft,{is_visible:!Be[Ft].is_visible})},hs=()=>{Se(Ft=>[...Ft,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Es=Ft=>{Se(Ps=>Ps.filter((yr,Is)=>Is!==Ft))},Ts=async()=>{if(!ge.trim()){me.error("Title is required");return}try{if(Xe){const Ft=await l.mutateAsync({id:Xe,title:ge,sections:Be,client_name:V,property_address:oe||null,cta_type:Ee,cta_label:Me,cta_url:Oe||null,heading:ve||null});me.success("Saved")}else{const Ft=await o.mutateAsync({title:ge,contact_id:(O==null?void 0:O.id)||void 0,client_name:V,property_address:oe||void 0,template_id:(xe==null?void 0:xe.id)||void 0,sections:Be,cta_type:Ee,cta_label:Me,cta_url:Oe||void 0,heading:ve||void 0});et(Ft.id),Je(Ft.share_token),me.success("Presentation created!")}}catch(Ft){console.error("Failed to save presentation:",Ft);const Ps=(Ft==null?void 0:Ft.message)||(Ft==null?void 0:Ft.toString())||"Unknown error";me.error(`Failed to save: ${Ps}`)}},cr=async()=>{try{await Ts();const Ft=Xe;if(Ft){const Ps=await i.mutateAsync(Ft);Je(Ps.share_token),lt(!0),y("share")}}catch(Ft){console.error("Failed to publish presentation:",Ft),me.error(`Failed to publish: ${(Ft==null?void 0:Ft.message)||"Unknown error"}`)}},zr=Ce?`https://presentations.relevelup.com/${Ce}`:"";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(G,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Ga,{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((Ft,Ps)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Pt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",g===Ft?"bg-primary text-primary-foreground":Ps<["client","template","builder","share"].indexOf(g)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Ps<["client","template","builder","share"].indexOf(g)?e.jsx(ua,{className:"h-4 w-4"}):Ps+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Ft}),Ps<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},Ft))}),g==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{q(null),X(""),J(""),ce(""),z(!1),y("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(Fn,{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(ba,{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(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(De,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:j,onChange:Ft=>N(Ft.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(ws,{className:"h-12 w-full"}),S.map(Ft=>e.jsxs("button",{onClick:()=>tt(Ft),className:Pt("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===Ft.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[Ft.first_name," ",Ft.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ft.email||Ft.phone||"No contact info"})]},Ft.id)),!j&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),j&&S.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(G,{onClick:()=>y("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(ba,{className:"h-4 w-4"})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(El,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(De,{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(ye,{className:"text-xs",children:"Name *"}),e.jsx(Le,{value:V,onChange:Ft=>{X(Ft.target.value),z(!0),q(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Email"}),e.jsx(Le,{value:Y,onChange:Ft=>J(Ft.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Phone"}),e.jsx(Le,{value:Q,onChange:Ft=>ce(Ft.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Client Type"}),e.jsxs(Rs,{value:ne,onValueChange:re,children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"buyer",children:"Buyer"}),e.jsx(ft,{value:"seller",children:"Seller"}),e.jsx(ft,{value:"recruit",children:"Recruit"}),e.jsx(ft,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Property Address"}),e.jsx(Le,{value:oe,onChange:Ft=>he(Ft.target.value),placeholder:"Optional"})]})]}),$&&V&&e.jsxs(G,{onClick:Ke,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(ba,{className:"h-4 w-4"})]})]})]})]})]}),g==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ga,{defaultValue:"system",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"mine",children:"My Core Templates"}),e.jsx(ss,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ss,{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(Ft=>e.jsx(ws,{className:"h-32"},Ft))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Ft=>!Ft.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(Ft=>!Ft.is_system).map(Ft=>e.jsx(f9e,{template:Ft,onSelect:rt},Ft.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(Ft=>Ft.is_system).map(Ft=>e.jsx(f9e,{template:Ft,onSelect:rt},Ft.id))})}),e.jsx(bs,{value:"blank",className:"mt-4",children:e.jsx(Pe,{children:e.jsxs(De,{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(G,{onClick:it,children:"Start from Scratch"})]})})})]}),e.jsxs(G,{variant:"outline",onClick:()=>y("client"),className:"gap-2",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back"]})]}),g==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Presentation Title"}),e.jsx(Le,{value:ge,onChange:Ft=>_e(Ft.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Page Heading"}),e.jsx(Le,{value:ve,onChange:Ft=>dt(Ft.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(ye,{children:"Client Name"}),e.jsx(Le,{value:V,onChange:Ft=>X(Ft.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Property Address"}),e.jsx(Le,{value:oe,onChange:Ft=>he(Ft.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(G,{variant:"outline",size:"sm",onClick:hs,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Be.map((Ft,Ps)=>e.jsx(Pe,{className:Pt(!Ft.is_visible&&"opacity-50"),children:e.jsx(De,{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(Eu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:Ft.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Le,{value:Ft.title,onChange:yr=>It(Ps,{title:yr.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(G,{variant:"ghost",size:"icon",onClick:()=>Vt(Ps),children:Ft.is_visible?e.jsx(Tn,{className:"h-4 w-4"}):e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"icon",onClick:()=>Es(Ps),className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]})]}),e.jsx(Le,{value:Ft.description||"",onChange:yr=>It(Ps,{description:yr.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(ye,{className:"text-xs",children:"Video URL"}),e.jsx(Le,{value:Ft.video_url||"",onChange:yr=>It(Ps,{video_url:yr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(o5s,{sectionTitle:Ft.title,contactId:O==null?void 0:O.id,onVideoReady:yr=>It(Ps,{video_url:yr})}),e.jsx(l5s,{sectionTitle:Ft.title,contactId:O==null?void 0:O.id,onVideoReady:yr=>It(Ps,{video_url:yr})}),e.jsx(N3e,{userId:r==null?void 0:r.id,onSelect:yr=>It(Ps,{video_url:yr})})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Ft.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:Ft.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(G,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>It(Ps,{image_url:""}),children:e.jsx(Er,{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:[pe===Ps?e.jsx(ys,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(p1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:pe===Ps?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:pe===Ps,onChange:yr=>{var Ar;const Is=(Ar=yr.target.files)==null?void 0:Ar[0];Is&&He(Is,Ps),yr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Text (optional)"}),e.jsx(xy,{content:Ft.text||"",onChange:yr=>It(Ps,{text:yr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Ps))})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Call to Action"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"CTA Type"}),e.jsxs(Rs,{value:Ee,onValueChange:Ft=>{Ae(Ft);const Ps=m9e.find(yr=>yr.value===Ft);Ps&&ke(Ps.label)},children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:m9e.map(Ft=>e.jsx(ft,{value:Ft.value,children:Ft.label},Ft.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Button Label"}),e.jsx(Le,{value:Me,onChange:Ft=>ke(Ft.target.value)})]}),e.jsxs("div",{children:[e.jsxs(ye,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(Le,{value:Oe,onChange:Ft=>qe(Ft.target.value),placeholder:"https://calendly.com/..."}),!Oe&&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(G,{variant:"outline",onClick:()=>y("template"),className:"gap-2",children:[e.jsx(Ga,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(G,{variant:"outline",onClick:Ts,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(G,{onClick:cr,disabled:i.isPending,className:"gap-2",children:[e.jsx(Fn,{className:"h-4 w-4"}),Ge?"Update & Reshare":"Publish & Share"]})]})]})]}),g==="share"&&Ce&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(De,{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(ua,{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(Le,{value:zr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(G,{onClick:()=>{navigator.clipboard.writeText(zr),me.success("Link copied!")},children:e.jsx(yi,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(G,{variant:"outline",className:"gap-2",onClick:()=>{const Ft=`Hi ${V||""}! I put together something for you — check it out: ${zr}`;navigator.clipboard.writeText(Ft),me.success("Message copied!")},children:[e.jsx(Ki,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(G,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${Y||""}?subject=${encodeURIComponent(ge)}&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: ${zr} Looking forward to connecting!`)}`)},children:[e.jsx(rr,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(X1,{open:m,onOpenChange:f,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:Y||O.email||""}:Y?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:Y}:void 0,defaultSubject:ge,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${zr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(G,{variant:"outline",onClick:()=>y("builder"),children:[e.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(G,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},f9e=({template:t,onSelect:s})=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(De,{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(Ye,{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(G,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),c5s=()=>{var w;const{shareToken:t}=ao(),[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:j,error:N}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!j){c(!0),a(!1);return}const{data:S}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let M;if(S!=null&&S.brokerage_id){const{data:P}=await H.from("brokerages").select("name").eq("id",S.brokerage_id).single();M=(P==null?void 0:P.name)||void 0}let I=null;if(j.contact_id){const{data:P}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();I=P}r({...j,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:M,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await 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{}},m=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(ws,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ws,{className:"h-64 w-full"}),e.jsx(ws,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(j=>j.is_visible!==!1),g=f[o],y=j=>{const N=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const I=j.replace("/play/","/embed/"),P=I.includes("?")?"&":"?";return`${I}${P}responsive=true`}if(j.includes("iframe.mediadelivery.net")){if(j.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const P=j.includes("?")?"&":"?";return`${j}${P}responsive=true`}return""}const S=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const M=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return M?`https://iframe.mediadelivery.net/embed/${M[1]}/${M[2]}?responsive=true`:j},_=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[g!=null&&g.video_url&&y(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:y(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((j,N)=>e.jsx("button",{onClick:()=>l(N),className:Pt("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: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})]})]})},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(G,{size:"lg",onClick:m,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(rn,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(FWe,{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 d5s({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=E4t(t),o=D4t(),l=O4t(),i=R4t(),c=F4t(),[u,m]=k.useState(""),[f,g]=k.useState("rating"),y=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}),m("")},w=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},j=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(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(W_,{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:y})]}),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(ys,{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(Eu,{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:()=>w(N),className:"scale-75"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>j(N),children:e.jsx(kr,{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(ye,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(Le,{value:u,onChange:N=>m(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(Rs,{value:f,onValueChange:g,children:[e.jsx(Ls,{className:"w-28 h-9 text-xs",children:e.jsx($s,{})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"rating",children:"Rating"}),e.jsx(ft,{value:"open_text",children:"Text"})]})]}),e.jsx(G,{size:"sm",variant:"outline",onClick:_,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})})]})}function u5s({open:t,onOpenChange:s,openHouse:r}){const n=BWe(),{user:a}=Fs(),o=k.useRef(null),[l,i]=k.useState(r.auto_forward_to_card??!1),[c,u]=k.useState(r.disclosure_pdf_url??""),[m,f]=k.useState(r.enable_survey??!1),[g,y]=k.useState(!1),[_,w]=k.useState(!1),j=async M=>{var $;const I=($=M.target.files)==null?void 0:$[0];if(!I||!a)return;if(I.size>20*1024*1024){kn({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){kn({title:"Only PDF files are accepted",variant:"destructive"});return}y(!0);const P=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:O}=await H.storage.from("open-house-photos").upload(P,I,{upsert:!0});if(O){kn({title:"Upload failed",description:O.message,variant:"destructive"}),y(!1);return}const{data:q}=H.storage.from("open-house-photos").getPublicUrl(P);u(q.publicUrl),y(!1),kn({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{w(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:m}),kn({title:"Settings saved!"}),s(!1)}catch{kn({title:"Failed to save",variant:"destructive"})}finally{w(!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(js,{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(ye,{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(ye,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:j,className:"hidden"}),c?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(wn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:N,children:e.jsx(Er,{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(ys,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(d5s,{openHouseId:r.id,enableSurvey:m,onToggleSurvey:f}),e.jsx(G,{onClick:S,disabled:_,className:"w-full",children:_?"Saving...":"Save Settings"})]})]})})}const Qct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function h5s({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:Qct[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 m5s({openHouseId:t}){const{data:s,isLoading:r}=L4t(t),{data:n}=zWe(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))],m=u.length;return m===0?e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(W_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(De,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(W_,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[m," respondent",m!==1?"s":""]})]})}),e.jsx(De,{children:e.jsxs(ga,{defaultValue:"summary",children:[e.jsxs(fa,{className:"mb-4",children:[e.jsxs(ss,{value:"summary",className:"text-xs gap-1",children:[e.jsx(co,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ss,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Zi,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(bs,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(h5s,{question:f,responses:l},f.id)),c.map(f=>{const g=l.filter(y=>y.question_id===f.id&&y.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(y=>{const _=a[y.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:y.text_value})]},y.id)})})]},f.id)})]}),e.jsx(bs,{value:"individual",className:"space-y-4",children:u.map(f=>{const g=a[f],y=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:y.map(_=>{const w=o.find(j=>j.id===_.question_id);return w?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:w.question_text}),e.jsx("span",{className:"font-medium",children:_.rating_value!=null?Qct[_.rating_value]||_.rating_value:_.text_value})]},_.id):null})})]},f)})})]})})]})}const Twe="guestbook.relevelup.com";function p5s(){const{data:t,isLoading:s}=C4t(),r=M4t(),n=BWe(),a=T4t(),[o,l]=k.useState(!1),[i,c]=k.useState(null),{user:u}=Fs(),m=Fa(),[f,g]=k.useState(null),[y,_]=k.useState(null),[w,j]=k.useState(!1),N=k.useRef(null),[S,M]=k.useState({property_address:"",city:"",state:"",zip:"",event_date:ds(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=$=>{var V;const z=(V=$.target.files)==null?void 0:V[0];if(z){if(z.size>5*1024*1024){kn({title:"Photo must be under 5MB",variant:"destructive"});return}g(z),_(URL.createObjectURL(z))}},P=()=>{g(null),_(null),N.current&&(N.current.value="")},O=async()=>{if(!S.property_address){kn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let $;if(f&&u){j(!0);const z=f.name.split(".").pop(),V=`${m}/${Date.now()}.${z}`,{error:X}=await H.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(X){kn({title:"Photo upload failed",description:X.message,variant:"destructive"}),j(!1);return}const{data:Y}=H.storage.from("open-house-photos").getPublicUrl(V);$=Y.publicUrl,j(!1)}await r.mutateAsync({...S,photo_url:$}),l(!1),M({property_address:"",city:"",state:"",zip:"",event_date:ds(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),P()},q=$=>{navigator.clipboard.writeText(`https://${Twe}/${$}`),kn({title:"Link copied!"})};return e.jsxs(Ms,{title:"Guest Book",children:[e.jsx(Pl,{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(Oi,{asChild:!0,children:e.jsxs(G,{children:[e.jsx(qs,{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(js,{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($=>({...$,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($=>({...$,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(ye,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Le,{value:S.property_address,onChange:$=>M(z=>({...z,property_address:$.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(ye,{children:"City"}),e.jsx(Le,{value:S.city,onChange:$=>M(z=>({...z,city:$.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"State"}),e.jsx(Le,{value:S.state,onChange:$=>M(z=>({...z,state:$.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"ZIP"}),e.jsx(Le,{value:S.zip,onChange:$=>M(z=>({...z,zip:$.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Date"}),e.jsx(Le,{type:"date",value:S.event_date,onChange:$=>M(z=>({...z,event_date:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Start Time"}),e.jsx(Le,{type:"time",value:S.start_time,onChange:$=>M(z=>({...z,start_time:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"End Time"}),e.jsx(Le,{type:"time",value:S.end_time,onChange:$=>M(z=>({...z,end_time:$.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Welcome Message"}),e.jsx(Tr,{value:S.agent_greeting,onChange:$=>M(z=>({...z,agent_greeting:$.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:I,className:"hidden"}),y?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:y,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:P,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var $;return($=N.current)==null?void 0:$.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(p1,{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(G,{onClick:O,disabled:r.isPending||w,className:"w-full",children:w?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map($=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Et,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},$))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map($=>e.jsx(f5s,{openHouse:$,isExpanded:i===$.id,onToggle:()=>c(i===$.id?null:$.id),onCopyLink:()=>q($.slug||""),onToggleActive:()=>n.mutate({id:$.id,is_active:!$.is_active}),onDelete:()=>a.mutate($.id)},$.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(b0,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(G,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function f5s({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=zWe(s?t.id:void 0),{data:i}=pt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:P,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=P.brokerages;return{...P,brokerage_name:(q==null?void 0:q.name)||null}},enabled:!!t.agent_id}),[c,u]=k.useState(!1),[m,f]=k.useState(!1),[g,y]=k.useState(!1),_=k.useRef(null),w=`https://${Twe}/${t.slug}`,j=P=>{if(!P)return"";const[O,q]=P.split(":"),$=parseInt(O),z=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${q} ${z}`},N=()=>{if(!(l!=null&&l.length))return;const P=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(X=>[X.first_name,X.last_name||"",X.email||"",X.phone||"",X.visitor_intent||"",X.wants_market_updates?"Yes":"No",(X.message||"").replace(/"/g,'""'),ds(new Date(X.created_at),"MM/dd/yyyy h:mm a")]),q=[P,...O].map(X=>X.map(Y=>`"${Y}"`).join(",")).join(` `),$=new Blob([q],{type:"text/csv"}),z=URL.createObjectURL($),V=document.createElement("a");V.href=z,V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,V.click(),URL.revokeObjectURL(z)},S=k.useCallback(()=>{if(!_.current)return;const P=_.current.querySelector("svg");if(!P)return;const O=new XMLSerializer().serializeToString(P),q=document.createElement("canvas");q.width=1024,q.height=1024;const $=q.getContext("2d"),z=new Image;z.onload=()=>{$==null||$.drawImage(z,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()},z.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),M=k.useCallback(()=>{var ve;if(!_.current)return;const P=_.current.querySelector("svg");if(!P)return;const O=new XMLSerializer().serializeToString(P),q="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),$=ds(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),z=t.start_time?`${j(t.start_time)}${t.end_time?" – "+j(t.end_time):""}`:"",V=[t.city,t.state].filter(Boolean).join(", "),X=t.agent_greeting||"Welcome! Please sign in below.",Y=!!t.photo_url,J=!!i,Q=Y||J,ce=Y&&J,ne=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",re=ce?"28px":"34px",oe=ce?"0.2in 0.75in":Q?"0.3in 0.75in":"0.4in 0.75in",he=Q?"0.15in":"0.3in",xe=Q?"0.15in":"0.3in",ue=ce?"14px 36px":"22px 44px",ge=ce?"20px":"24px",_e=Q?"0.2in":"0.35in",Be=ce?"1.8in":"2.4in",Se=Q?"0.15in":"0.3in",Ee=ce?"140px":Q?"160px":"200px",Ae=ce?"16px":"24px",Me=ce?"10px 20px":"16px 28px",ke=ce?"44px":"56px",Oe="0.15in",qe=window.open("","_blank");qe&&(qe.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
${$}
${z?`
Time
${z}
`:""}
${X}
${i?`
${i.avatar_url?`${i.name}`:`
${((ve=i.name)==null?void 0:ve.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
`),qe.document.close(),setTimeout(()=>{qe.focus(),qe.print()},500))},[t,w,i]),I=async()=>{y(!0);try{const{error:P}=await H.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(P)throw P;kn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(P){kn({title:"Failed to send",description:P.message,variant:"destructive"})}finally{y(!1)}};return e.jsxs(Pe,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Et,{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(Lt,{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(Ye,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(Ye,{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(Zi,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(Ye,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(Ta,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(G,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(Sp,{className:"h-4 w-4"}):e.jsx(Ji,{className:"h-4 w-4"})})]}),e.jsxs(vr,{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(aa,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),ds(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(mn,{className:"h-3 w-3"}),j(t.start_time),t.end_time?` – ${j(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(ur,{className:"h-3 w-3"}),t.visitor_count," signed in"]}),t.qr_scan_count>0&&e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(b0,{className:"h-3 w-3"}),t.qr_scan_count," scan",t.qr_scan_count===1?"":"s"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(G,{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(y1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(b0,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(el,{className:"h-3.5 w-3.5"})}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>window.open(w,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(rn,{className:"h-3.5 w-3.5"})}),e.jsx(G,{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(Cp,{className:"h-3.5 w-3.5"}):e.jsx(Tn,{className:"h-3.5 w-3.5"})}),e.jsx(G,{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(kr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(De,{className:"pt-0",children:[e.jsx(Qo,{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://",Twe,"/",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(G,{variant:"outline",size:"sm",onClick:N,className:"h-7 text-xs gap-1",children:[e.jsx(vi,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(P=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[P.first_name,P.last_name?` ${P.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[P.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:P.email}),P.phone&&e.jsx("div",{className:"text-xs",children:P.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:P.visitor_intent?e.jsx(Ye,{variant:"outline",className:"text-xs capitalize",children:P.visitor_intent}):P.partial_signin?e.jsx(Ye,{variant:"outline",className:"text-xs text-amber-600 border-amber-300 dark:text-amber-400 dark:border-amber-700",children:"Didn't finish"}):null}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ds(new Date(P.created_at),"h:mm a")})]},P.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(m5s,{openHouseId:t.id})})]}),e.jsx(fs,{open:c,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-sm",children:[e.jsxs(js,{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(qR,{value:w,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:w}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(G,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(G,{variant:"outline",className:"flex-1",onClick:M,children:[e.jsx(BL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(G,{variant:"default",className:"w-full",onClick:I,disabled:g,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(u5s,{open:m,onOpenChange:f,openHouse:t})]})}function x5s(){const{slug:t}=ao();return t?e.jsx(uYe,{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 Xct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Fs(),l=B3(),i=k.useRef(null),c=k.useRef(null),[u,m]=k.useState(!1),[f,g]=k.useState(!1),[y,_]=k.useState(0),w=async N=>{if(o){m(!0);try{const S=N.name.split(".").pop()||"jpg",M=`${o.id}/card-${Date.now()}.${S}`,{error:I}=await H.storage.from("listing-photos").upload(M,N);if(I)throw I;const{data:{publicUrl:P}}=H.storage.from("listing-photos").getPublicUrl(M);r(P),me.success("Photo uploaded")}catch(S){me.error(S.message||"Failed to upload photo")}finally{m(!1)}}},j=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 ER(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:P}=await PR(S);await new Promise(($,z)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",X=>{X.lengthComputable&&_(Math.round(X.loaded/X.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?$():z(new Error("Upload failed"))}),V.addEventListener("error",()=>z(new Error("Upload failed"))),V.open("PUT",I),V.setRequestHeader("AccessKey",P),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(ye,{children:"Media (optional)"}),e.jsxs(ga,{defaultValue:"photo",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ss,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(bl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ss,{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(G,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Er,{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(ys,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(gf,{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&&w(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(G,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Er,{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(ys,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",y,"%"]}),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:`${y}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ci,{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(k3e,{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&&j(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 g5s=[{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 y5s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:g5s.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 s6={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 x9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Fs(),c=Qt(),[u,m]=k.useState(!1),[f,g]=k.useState("type"),[y,_]=k.useState(""),[w,j]=k.useState(null),[N,S]=k.useState(!1),[M,I]=k.useState("home_anniversary"),[P,O]=k.useState(""),[q,$]=k.useState(""),[z,V]=k.useState(""),[X,Y]=k.useState(""),[J,Q]=k.useState("elegant"),[ce,ne]=k.useState(null),[re,oe]=k.useState(null),he=k.useState(!1);!he[0]&&t&&s&&(he[1](!0),m(!0),I(s),r&&j(r),n&&O(n),a&&$(a),o&&V(o),g(n?"details":"contact"));const{data:xe}=pt({queryKey:["contacts-for-card",i==null?void 0:i.id,y],queryFn:async()=>{let Oe=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);y&&(Oe=Oe.or(`first_name.ilike.%${y}%,last_name.ilike.%${y}%`));const{data:qe,error:ve}=await Oe;if(ve)throw ve;return qe},enabled:!!(i!=null&&i.id)&&u}),{data:ue}=pt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Oe,error:qe}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(qe)throw qe;return Oe},enabled:!!(i!=null&&i.id)}),ge=Oe=>{j(Oe.id),O(`${Oe.first_name}${Oe.last_name?" "+Oe.last_name:""}`),$([Oe.address,Oe.city,Oe.state].filter(Boolean).join(", ")),V(Oe.home_anniversary||""),g("details")},_e=Oe=>{I(Oe),g("contact")},Be=async()=>{var Oe;if(!(!i||!ue)){S(!0);try{const qe={owner_user_id:i.id,contact_id:w,card_type:M,template:J,recipient_name:P,property_address:q||null,home_anniversary_date:z||null,custom_message:X||null,property_photo_url:ce||null,video_url:re||null,agent_name:ue.name||"Agent",agent_photo_url:ue.avatar_url,agent_phone:ue.phone,agent_email:ue.email,agent_brokerage:((Oe=ue.brokerage)==null?void 0:Oe.name)||null},{error:ve}=await H.from("sendable_cards").insert(qe);if(ve)throw ve;me.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),Se()}catch(qe){me.error(qe.message||"Failed to create card")}finally{S(!1)}}},Se=()=>{m(!1),g("type"),I("home_anniversary"),_(""),j(null),O(""),$(""),V(""),Y(""),Q("elegant"),ne(null),oe(null)},Ee={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"},Ae=s6[M],Me=M==="home_anniversary",ke=["home_anniversary","just_listed","just_sold"].includes(M);return e.jsxs(fs,{open:u,onOpenChange:Oe=>{Oe?m(!0):(Se(),l==null||l(!1))},children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(vs,{children:f==="type"?"What type of card?":f==="contact"?`${Ee[M]} — Choose a Contact`:`${Ee[M]} — Customize`})}),f==="type"&&e.jsx(y5s,{onSelect:_e}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("type"),children:[e.jsx(Ga,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search contacts...",value:y,onChange:Oe=>_(Oe.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[xe==null?void 0:xe.map(Oe=>e.jsxs("button",{onClick:()=>ge(Oe),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(Zi,{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:[Oe.first_name," ",Oe.last_name]}),Oe.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Oe.address]})]}),Oe.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"})]},Oe.id)),(xe==null?void 0:xe.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(G,{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(G,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("contact"),children:[e.jsx(Ga,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Recipient Name"}),e.jsx(Le,{value:P,onChange:Oe=>O(Oe.target.value),placeholder:"John & Jane Smith"})]}),ke&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Address"}),e.jsx(Le,{value:q,onChange:Oe=>$(Oe.target.value),placeholder:"123 Main St, Austin, TX"})]}),Me&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Home Anniversary Date"}),e.jsx(Le,{type:"date",value:z,onChange:Oe=>V(Oe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Message (optional)"}),e.jsx(Tr,{value:X,onChange:Oe=>Y(Oe.target.value),placeholder:Ae.defaultMessage,rows:3})]}),e.jsx(Xct,{photoUrl:ce,videoUrl:re,onPhotoChange:ne,onVideoChange:oe,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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:Oe,label:qe,gradient:ve})=>e.jsxs("button",{onClick:()=>Q(Oe),className:`p-2 rounded-lg border-2 transition-all text-center ${J===Oe?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${ve}`}),e.jsx("span",{className:"text-[10px] font-medium",children:qe})]},Oe))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(G,{variant:"outline",onClick:()=>g("contact"),className:"flex-1",children:"Back"}),e.jsx(G,{onClick:Be,disabled:!P||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const v5s={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 b5s({card:t}){const{user:s}=Fs(),{isGmailConnected:r}=Ff(),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:w})=>{w!=null&&w.email&&i(w.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,m]=k.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,g]=k.useState(""),y=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Tt({mutationFn:async()=>{var M;if(!l)throw new Error("Recipient email is required");const w=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:j}=await H.auth.getSession(),N=(M=j==null?void 0:j.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:w,contactId:t.contact_id||void 0})});if(!S.ok){const I=await S.json();throw new Error(I.error||"Failed to send")}return S.json()},onSuccess:async()=>{await 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:w=>{me.error(w.message||"Failed to send email")}});return r?e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(Oi,{asChild:!0,children:e.jsx(G,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Fn,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(js,{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(ye,{children:"To"}),e.jsx(Le,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Subject"}),e.jsx(Le,{value:u,onChange:w=>m(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Note (optional)"}),e.jsx(Tr,{value:f,onChange:w=>g(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:y})]}),e.jsx(G,{onClick:()=>_.mutate(),disabled:!l||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(G,{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(Fn,{className:"h-3 w-3"})})}function _5s({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||""),[m,f]=k.useState(t.home_anniversary_date||""),[g,y]=k.useState(t.custom_message||""),[_,w]=k.useState(t.template),[j,N]=k.useState(t.property_photo_url),[S,M]=k.useState(t.video_url||null),I=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),y(t.custom_message||""),w(t.template),N(t.property_photo_url),M(t.video_url||null)),n(O)},P=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:m||null,custom_message:g.trim()||null,template:_,property_photo_url:j||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:I,children:[e.jsx(Oi,{asChild:!0,children:e.jsx(G,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Pa,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ye,{children:"Recipient Name"}),e.jsx(Le,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Address"}),e.jsx(Le,{value:c,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Home Anniversary Date"}),e.jsx(Le,{type:"date",value:m,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Message (optional)"}),e.jsx(Tr,{value:g,onChange:O=>y(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Xct,{photoUrl:j,videoUrl:S,onPhotoChange:N,onVideoChange:M,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(O=>e.jsxs("button",{onClick:()=>w(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(G,{onClick:P,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function w5s(){const{user:t}=Fs(),s=Qt(),[r,n]=k.useState(""),[a,o]=Ul(),l=a.get("cardType"),i=a.get("contactId"),c=a.get("name"),u=a.get("address"),m=a.get("date"),f=!!l,{data:g,isLoading:y}=pt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:M,error:I}=await H.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return M},enabled:!!(t!=null&&t.id)}),_=Tt({mutationFn:async M=>{const{error:I}=await H.from("sendable_cards").delete().eq("id",M);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),w=M=>{const I=`https://cardstudio.relevelup.com/c/${M}`;navigator.clipboard.writeText(I),me.success("Share link copied!")},j=g==null?void 0:g.filter(M=>{var I;return!r||M.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=M.property_address)==null?void 0:I.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(x9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:m||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search cards...",value:r,onChange:M=>n(M.target.value),className:"pl-9"})]}),y?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(Pe,{className:"animate-pulse",children:e.jsxs(De,{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))}):j!=null&&j.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(M=>e.jsxs(Pe,{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(Ye,{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(De,{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(Tn,{className:"h-3 w-3"}),M.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ql(new Date(M.created_at),{addSuffix:!0})})]}),M.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ds(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(G,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(M.share_token),children:[e.jsx(yi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(_5s,{card:M}),e.jsx(b5s,{card:M}),e.jsx(G,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${M.share_token}`,"_blank"),children:e.jsx(rn,{className:"h-3 w-3"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>_.mutate(M.id),children:e.jsx(kr,{className:"h-3 w-3"})})]})]})]},M.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(De,{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(rr,{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(x9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:m||void 0,onOpenChange:()=>o({})})]})})]})})}function EI({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 j5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:m,propertyPhotoUrl:f,videoUrl:g}=t,y=s6[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(EI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(EI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(EI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(EI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(EI,{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:y.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:y.title[0]}),y.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:y.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||y.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}),m&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:m})]})]}),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(Nn,{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(rr,{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 Gye({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 g9e={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 N5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:m,propertyPhotoUrl:f,videoUrl:g}=t,y=s6[s],_=g9e[s]||g9e.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(Gye,{delay:0,x:"10%",y:"10%",color:_.orbs[0],size:200}),e.jsx(Gye,{delay:1,x:"70%",y:"60%",color:_.orbs[1],size:180}),e.jsx(Gye,{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:y.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:y.title[0]}),y.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:y.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:y.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(xn,{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||y.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}),m&&e.jsx("p",{className:"text-xs text-violet-300/60",children:m})]})]}),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(Nn,{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(rr,{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 k5s({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 y9e={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 S5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:m,propertyPhotoUrl:f,videoUrl:g}=t,y=s6[s],_=y9e[s]||y9e.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:[y.emojis.map((w,j)=>e.jsx(k5s,{emoji:w,delay:j*1.2,x:`${15+j*14}%`,duration:5+j%3},j)),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:y.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:y.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:y.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:y.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:[y.title.join(" ")," ",y.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(aa,{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||y.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}),m&&e.jsx("p",{className:`text-xs ${_.text} opacity-60`,children:m})]})]}),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(Nn,{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(rr,{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 j9({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 Wye({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 v9e={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 C5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:m,propertyPhotoUrl:f,videoUrl:g}=t,y=s6[s],_=v9e[s]||v9e.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(j9,{delay:0,x:"5%",y:"10%",size:300,color:_.mesh[0]}),e.jsx(j9,{delay:2,x:"60%",y:"50%",size:250,color:_.mesh[1]}),e.jsx(j9,{delay:4,x:"30%",y:"70%",size:200,color:_.mesh[2]}),e.jsx(j9,{delay:1,x:"80%",y:"15%",size:180,color:_.mesh[0]}),e.jsx(Wye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Wye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Wye,{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:y.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:y.title[0]}),y.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:y.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(aa,{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||y.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}),m&&e.jsx("p",{className:"text-xs text-white/30",children:m})]})]}),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(Nn,{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(rr,{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 Kye({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 N9({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 b9e={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 M5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:m,propertyPhotoUrl:f,videoUrl:g}=t,y=s6[s],_=b9e[s]||b9e.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(Kye,{delay:0,x:"20%",angle:15,color:_.stripe}),e.jsx(Kye,{delay:2,x:"75%",angle:-12,color:_.stripe}),e.jsx(Kye,{delay:4,x:"50%",angle:5,color:_.stripe}),e.jsx(N9,{delay:0,x:"30%"}),e.jsx(N9,{delay:1.5,x:"60%"}),e.jsx(N9,{delay:3,x:"45%"}),e.jsx(N9,{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:y.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:y.title[0]})}),y.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:y.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(aa,{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||y.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}),m&&e.jsx("p",{className:"text-[11px] text-white/25",children:m})]})]}),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(Nn,{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(rr,{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 Jct(){const{shareToken:t}=ao(),{data:s,isLoading:r,error:n}=pt({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()-Fl(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(N5s,{...o});case"warm":return e.jsx(S5s,{...o});case"glass":return e.jsx(C5s,{...o});case"cinematic":return e.jsx(M5s,{...o});case"elegant":default:return e.jsx(j5s,{...o})}}function T5s(){const t=Fa();return pt({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 A5s(){const t=Fa(),s=Qt();return Tt({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 E5s(){const t=ar(),{isGmailConnected:s,gmailEmail:r}=Ff(),{data:n,isLoading:a}=T5s(),o=A5s(),[l,i]=k.useState(!1),[c,u]=k.useState(!0),[m,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")}},y=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:m,onOpenChange:f,children:[e.jsx(Oi,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(el,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(el,{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(rr,{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(Ye,{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(G,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(rn,{className:"h-3 w-3"}),"Connect"]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Smart Drips sends emails from your Gmail account. Connect Gmail to get started."})]}),e.jsx(Qo,{}),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(zL,{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(Qo,{}),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(r0,{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:y,disabled:a||o.isPending})]}),c&&e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(r0,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function P5s(){const t=Fa();return pt({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 I5s(){const t=Fa();return pt({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 L5s(){const t=Fa(),s=Qt();return Tt({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 D5s(){const t=Qt();return Tt({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 O5s(){const t=Qt();return Tt({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 R5s(){const t=Fa(),s=Qt();return Tt({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 F5s=[{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 z5s({open:t,onOpenChange:s,campaignId:r,campaignName:n}){const{data:a,isLoading:o}=T_s(r||void 0),l=E_s(),i=yit(),c=async(f,g)=>{try{await l.mutateAsync({id:f,status:g}),me.success(`Enrollment ${g}`)}catch{me.error("Failed to update")}},u=async f=>{if(r)try{const g=await i.mutateAsync({campaignId:r,contactIds:[f]});g.enrolled>0?me.success("Contact re-enrolled — first email queued"):g.skipped>0?me.message("Already active in this campaign"):me.error("Could not re-enroll")}catch{me.error("Failed to re-enroll")}},m=f=>{const g={active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",paused:"bg-amber-500/10 text-amber-600 border-amber-200",completed:"bg-blue-500/10 text-blue-600 border-blue-200",exited:"bg-muted text-muted-foreground"};return e.jsx(Ye,{variant:"outline",className:`text-[10px] capitalize ${g[f]||""}`,children:f})};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[e.jsxs("div",{className:"p-5 border-b shrink-0",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4 text-primary"}),"Enrollments — ",n||"Campaign"]}),e.jsx(Gr,{className:"text-xs mt-1",children:"Manage every contact currently in this campaign. Pause to take over, or exit to remove."})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx("div",{className:"p-5",children:o?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(f=>e.jsx(ws,{className:"h-14"},f))}):!a||a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ur,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"No contacts enrolled yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Head to your contacts page and bulk-enroll to start nurturing."})]}):e.jsx("div",{className:"space-y-2",children:a.map(f=>{var g,y,_,w;return e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-lg bg-card",children:[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 text-sm truncate",children:[(g=f.contact)==null?void 0:g.first_name," ",(y=f.contact)==null?void 0:y.last_name]}),m(f.status)]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[((_=f.contact)==null?void 0:_.email)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",f.contact.email]}),e.jsxs("span",{children:["Step ",f.current_step]}),f.next_send_at&&f.status==="active"&&e.jsxs("span",{children:["Next: ",ds(new Date(f.next_send_at),"MMM d, h:mma")]}),f.exit_reason&&e.jsxs("span",{children:["Exit: ",f.exit_reason]})]})]}),f.status==="active"&&e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>c(f.id,"paused"),title:"Pause",children:e.jsx(Ih,{className:"h-3.5 w-3.5"})}),f.status==="paused"&&e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>c(f.id,"active"),title:"Resume",children:e.jsx(sl,{className:"h-3.5 w-3.5"})}),(f.status==="active"||f.status==="paused")&&e.jsx(G,{size:"sm",variant:"ghost",onClick:()=>c(f.id,"exited"),title:"Exit",children:e.jsx(Er,{className:"h-3.5 w-3.5 text-destructive"})}),(f.status==="exited"||f.status==="completed")&&((w=f.contact)==null?void 0:w.id)&&e.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-[11px] gap-1",onClick:()=>u(f.contact.id),disabled:i.isPending,children:[e.jsx(w0,{className:"h-3 w-3"}),"Re-enroll"]})]},f.id)})})})})]})})}function B5s(){var S;const{data:t,isLoading:s}=jSe(),r=k_s(),n=N_s(),a=xit(),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,m]=k.useState(null),[f,g]=k.useState(null),y=(t||[]).filter(M=>!M.is_starter),_=(t||[]).filter(M=>M.is_starter),w=async M=>{try{await r.mutateAsync(M),me.success("Campaign added to your library — customize and activate it!"),l(null)}catch(I){me.error(I.message||"Failed to copy campaign")}},j=async M=>{try{await a.mutateAsync({id:M.id,is_active:!M.is_active}),me.success(M.is_active?"Campaign paused":"Campaign activated")}catch{me.error("Failed to update")}},N=async M=>{if(confirm("Delete this campaign? Active enrollments will be removed."))try{await n.mutateAsync(M),me.success("Campaign deleted")}catch{me.error("Failed to delete")}};return s?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(M=>e.jsx(ws,{className:"h-44 rounded-xl"},M))}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-primary/5 via-background to-background p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(cS,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm mb-1",children:"How Smart Drips work"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mt-2",children:[e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx(Xh,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Stage Drips (automatic)"}),e.jsx("p",{className:"text-muted-foreground",children:"Trigger when a contact moves to a deal stage (Listing, Under Contract, etc)."})]})]}),e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx(Fn,{className:"h-3.5 w-3.5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Campaigns (manual / bulk)"}),e.jsx("p",{className:"text-muted-foreground",children:"You enroll contacts yourself — from this page or the Contacts list."})]})]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-2.5 italic",children:["Tip: A campaign must be ",e.jsx("strong",{children:"Active"})," before its emails will send to enrolled contacts."]})]})]})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(ur,{className:"h-4 w-4 text-primary"}),"My Campaigns"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Custom drip campaigns you've created or copied"})]}),e.jsxs(G,{size:"sm",onClick:()=>{m(null),c(!0)},children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," New Campaign"]})]}),y.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl bg-muted/20",children:[e.jsx(nn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold mb-1",children:"No custom campaigns yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Build one from scratch or clone a starter from the library below."}),e.jsxs(G,{size:"sm",onClick:()=>{m(null),c(!0)},children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Create your first campaign"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(M=>e.jsx($5s,{campaign:M,onPreview:()=>l(M.id),onToggleActive:()=>j(M),onDelete:()=>N(M.id),onEdit:()=>{m(M.id),c(!0)},onViewEnrollments:()=>g(M.id)},M.id))})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(nn,{className:"h-4 w-4 text-amber-500"}),"Starter Library"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Premium, ready-to-go campaigns crafted for real estate. One-click copy."})]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px]",children:[_.length," templates"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:_.map(M=>e.jsx(q5s,{campaign:M,onPreview:()=>l(M.id)},M.id))})]}),e.jsx(U5s,{campaignId:o,open:!!o,onOpenChange:M=>!M&&l(null),onClone:w,isCloning:r.isPending,onEdit:M=>{l(null),m(M),c(!0)}}),e.jsx(vit,{open:i,onOpenChange:c,campaignId:u}),e.jsx(z5s,{open:!!f,onOpenChange:M=>!M&&g(null),campaignId:f,campaignName:(S=y.find(M=>M.id===f))==null?void 0:S.name})]})}function $5s({campaign:t,onPreview:s,onToggleActive:r,onDelete:n,onEdit:a,onViewEnrollments:o}){const i=A_s(t.id).data??0,c=!t.is_active&&i>0;return e.jsxs("div",{className:"group rounded-xl border bg-card overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`h-20 bg-gradient-to-br ${t.cover_color} relative flex items-center justify-center`,children:[e.jsx("span",{className:"text-4xl drop-shadow-sm",children:t.icon}),t.is_active&&e.jsx(Ye,{className:"absolute top-2 right-2 bg-emerald-500 hover:bg-emerald-500 text-white text-[10px]",children:"Active"})]}),e.jsxs("div",{className:"p-3.5",children:[e.jsx("h3",{className:"font-semibold text-sm truncate",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 min-h-[2rem]",children:t.description||"No description"}),e.jsx(Ye,{variant:"outline",className:"text-[9px] mt-2",children:nme[t.category]}),c&&e.jsxs("button",{onClick:r,className:"mt-2 w-full flex items-start gap-1.5 p-2 rounded-md bg-amber-500/10 border border-amber-500/30 text-left hover:bg-amber-500/15 transition-colors",children:[e.jsx(vd,{className:"h-3 w-3 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5"}),e.jsxs("span",{className:"text-[10px] leading-tight text-amber-700 dark:text-amber-300",children:[e.jsxs("strong",{children:[i," contact",i===1?"":"s"," enrolled"]})," but not sending — tap to activate"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 mt-3",children:[e.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:a,children:[e.jsx(Pa,{className:"h-3 w-3 mr-1"})," Edit"]}),e.jsx(G,{size:"sm",variant:t.is_active?"secondary":"default",className:"h-7 text-xs",onClick:r,children:t.is_active?"Pause":"Activate"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",children:[e.jsx("button",{onClick:o,className:"text-primary hover:underline",children:"View enrollments"}),e.jsx("button",{onClick:s,className:"text-muted-foreground hover:underline",children:"Preview"}),e.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-destructive",children:"Delete"})]})]})]})}function q5s({campaign:t,onPreview:s}){return e.jsxs("button",{onClick:s,className:"group rounded-xl border bg-card overflow-hidden hover:shadow-xl hover:scale-[1.02] transition-all text-left",children:[e.jsxs("div",{className:`h-24 bg-gradient-to-br ${t.cover_color} relative flex items-center justify-center`,children:[e.jsx("span",{className:"text-5xl drop-shadow-sm",children:t.icon}),e.jsxs(Ye,{className:"absolute top-2 right-2 bg-white/90 text-foreground hover:bg-white text-[10px]",children:[e.jsx(nn,{className:"h-2.5 w-2.5 mr-0.5"})," Starter"]})]}),e.jsxs("div",{className:"p-3.5",children:[e.jsx("h3",{className:"font-semibold text-sm",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 min-h-[2rem]",children:t.description}),e.jsx(Ye,{variant:"outline",className:"text-[9px] mt-2",children:nme[t.category]})]})]})}function U5s({campaignId:t,open:s,onOpenChange:r,onClone:n,isCloning:a,onEdit:o}){const{data:l}=jSe(),{data:i}=git(t||void 0),[c,u]=k.useState(new Set),m=l==null?void 0:l.find(y=>y.id===t);if(!m)return null;const f=y=>{u(_=>{const w=new Set(_);return w.has(y)?w.delete(y):w.add(y),w})},g=(y,_)=>{if(y.delay_type==="calendar_anchor"){const j=y.anchor_field==="birthday"?"birthday":"home anniversary",N=y.anchor_offset_days||0;return N===0?`On their ${j}`:N<0?`${Math.abs(N)} days before ${j}`:`${N} days after ${j}`}if(_===0&&y.delay_days===0&&y.delay_hours===0)return"Sends immediately";const w=[];return y.delay_days&&w.push(`${y.delay_days}d`),y.delay_hours&&w.push(`${y.delay_hours}h`),_===0?`After ${w.join(" ")}`:`+${w.join(" ")}`};return e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[e.jsx("div",{className:`bg-gradient-to-br ${m.cover_color} p-6 text-white shrink-0`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"text-5xl drop-shadow-sm",children:m.icon}),e.jsxs("div",{className:"flex-1",children:[e.jsx(vs,{className:"text-xl font-bold text-white",children:m.name}),e.jsx(Gr,{className:"text-white/90 mt-1",children:m.description}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Ye,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:nme[m.category]}),e.jsxs(Ye,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:[(i==null?void 0:i.length)||0," step",(i==null?void 0:i.length)!==1?"s":""]})]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsxs("div",{className:"p-6 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"The sequence"}),m.is_starter?e.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"Copy to your library to edit"}):e.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"Tap a step to expand · Edit to customize"})]}),i==null?void 0:i.map((y,_)=>{const w=c.has(y.id);return e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"shrink-0 flex flex-col items-center",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 text-primary flex items-center justify-center text-xs font-semibold",children:_+1}),_f(y.id),className:"flex-1 pb-4 text-left",children:e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/20 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 text-xs text-muted-foreground",children:[y.delay_type==="calendar_anchor"?e.jsx(fn,{className:"h-3 w-3"}):e.jsx(mn,{className:"h-3 w-3"}),e.jsx("span",{children:g(y,_)}),e.jsx("span",{children:"·"}),e.jsx(rr,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:y.channel})]}),e.jsx("p",{className:"font-medium text-sm",children:y.subject}),w?e.jsx("p",{className:"text-xs text-muted-foreground mt-2 whitespace-pre-line",children:y.body}):e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 whitespace-pre-line",children:y.body}),y.body&&y.body.length>160&&e.jsx("span",{className:"text-[10px] text-primary mt-1.5 inline-block",children:w?"Show less":"Show full email"})]})})]},y.id)})]})}),e.jsxs(Rn,{className:"border-t p-4 shrink-0",children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!m.is_starter&&o&&e.jsxs(G,{variant:"secondary",onClick:()=>o(m.id),children:[e.jsx(Pa,{className:"h-3.5 w-3.5 mr-1.5"})," Edit Campaign"]}),m.is_starter&&e.jsxs(G,{onClick:()=>n(m.id),disabled:a,children:[a?e.jsx(ys,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(yi,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy to my campaigns"]})]})]})})}function V5s(){const t=Fa(),s=ar(),{isGmailConnected:r,gmailEmail:n,isLoading:a}=Ff(),{data:o,isLoading:l}=P5s(),{data:i,isLoading:c}=I5s(),u=L5s(),m=D5s(),f=O5s(),g=R5s(),[y,_]=k.useState(null),[w,j]=k.useState(null),N=(o==null?void 0:o.filter(z=>!z.is_starter&&z.owner_user_id===t))||[],S=(o==null?void 0:o.filter(z=>z.is_starter))||[],M=z=>N.filter(V=>V.stage_id===z),I=async z=>{try{await m.mutateAsync({id:z.id,is_enabled:!z.is_enabled}),me.success(z.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},P=async z=>{try{const V=i==null?void 0:i.find(X=>X.id===z);await u.mutateAsync({stage_id:z,title:`${(V==null?void 0:V.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),_(z),me.success("Drip template created")}catch{me.error("Failed to create template")}},O=async z=>{try{await f.mutateAsync(z),me.success("Template deleted")}catch{me.error("Failed to delete")}},q=async z=>{if(!i||i.length===0){me.error("No pipeline stages found");return}const V=i[0].id;try{await g.mutateAsync({templateId:z,stageId:V}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},$=l||c;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(Jh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(Ye,{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(E5s,{})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-xl p-4 mb-4 flex items-start gap-3",children:[e.jsx(cS,{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."]})]})]}),!a&&(r?e.jsxs("div",{className:"bg-emerald-500/5 border border-emerald-500/20 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(rr,{className:"h-4 w-4 text-emerald-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm flex-1",children:[e.jsxs("p",{className:"font-medium text-foreground mb-0.5",children:["Sending from your Gmail",n?` (${n})`:""]}),e.jsx("p",{className:"text-muted-foreground",children:"Drips will send directly from your connected Gmail for the most personal feel and best deliverability."})]})]}):e.jsxs("div",{className:"bg-amber-500/5 border border-amber-500/20 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(cS,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm flex-1",children:[e.jsx("p",{className:"font-medium text-foreground mb-0.5",children:"Drips will send from our shared sender"}),e.jsxs("p",{className:"text-muted-foreground mb-2",children:["You haven't connected Gmail, so drips will send from ",e.jsx("strong",{children:"send.relevelup.com"})," with your name on the From line and your email as Reply-To. Connect Gmail to send directly from your own inbox for better deliverability and a more personal touch."]}),e.jsxs(G,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s("/mission-control/integrations"),children:[e.jsx(rr,{className:"h-3 w-3 mr-1.5"}),"Connect Gmail"]})]})]})),e.jsxs(ga,{defaultValue:"my-drips",children:[e.jsxs(fa,{className:"grid grid-cols-3 w-full max-w-lg mb-6",children:[e.jsx(ss,{value:"my-drips",children:"Stage Drips"}),e.jsxs(ss,{value:"campaigns",children:["Campaigns",e.jsx(Ye,{variant:"outline",className:"ml-1.5 text-[9px] bg-amber-500/10 text-amber-600 border-amber-200 px-1 py-0",children:"New"})]}),e.jsxs(ss,{value:"starters",children:["Stage Starters",S.length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:S.length})]})]}),e.jsx(bs,{value:"campaigns",children:e.jsx(B5s,{})}),e.jsx(bs,{value:"my-drips",children:$?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(z=>e.jsx(ws,{className:"h-16 w-full rounded-xl"},z))}):!i||i.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Jh,{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:[i.filter(z=>!z.is_won_stage&&!z.is_lost_stage).map(z=>{const V=M(z.id),X=y===z.id,Y=V.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>_(X?null:z.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:z.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:z.name}),V.length>0&&e.jsxs(Ye,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[V.length," drip",V.length!==1?"s":"",Y&&" · Active"]}),X?e.jsx(Ji,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),X&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:V.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(G,{variant:"outline",size:"sm",onClick:()=>P(z.id),disabled:u.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[V.map(J=>e.jsx(_9e,{template:J,isEditing:w===J.id,onToggleEdit:()=>j(w===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:Q=>m.mutateAsync({id:J.id,...Q}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>P(z.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},z.id)}),i.filter(z=>z.is_won_stage||z.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"}),i.filter(z=>z.is_won_stage||z.is_lost_stage).map(z=>{const V=M(z.id),X=y===z.id,Y=V.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>_(X?null:z.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:z.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:z.name}),V.length>0&&e.jsxs(Ye,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[V.length," drip",V.length!==1?"s":"",Y&&" · Active"]}),X?e.jsx(Ji,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),X&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:V.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(G,{variant:"outline",size:"sm",onClick:()=>P(z.id),disabled:u.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[V.map(J=>e.jsx(_9e,{template:J,isEditing:w===J.id,onToggleEdit:()=>j(w===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:Q=>m.mutateAsync({id:J.id,...Q}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(G,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>P(z.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},z.id)})]})]})}),e.jsx(bs,{value:"starters",children:S.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(nn,{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:S.map(z=>e.jsx(H5s,{template:z,onCopy:()=>q(z.id),isCopying:g.isPending},z.id))})})]})]})})}function _9e({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=k.useState(t.title),[u,m]=k.useState(t.subject),[f,g]=k.useState(t.body),[y,_]=k.useState(t.video_url||""),[w,j]=k.useState(t.channel),[N,S]=k.useState(t.delay_type),[M,I]=k.useState(t.delay_minutes),[P,O]=k.useState(!1),q=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:y||null,channel:w,delay_type:N,delay_minutes:M}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},$=z=>{g(V=>V+z)};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(Ki,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(rr,{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(ye,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Le,{value:i,onChange:z=>c(z.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(ye,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(z=>e.jsxs("button",{onClick:()=>j(z),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w===z?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[z==="sms"?e.jsx(Ki,{className:"h-3 w-3"}):e.jsx(rr,{className:"h-3 w-3"}),z==="sms"?"SMS":"Email"]},z))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ye,{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(mn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Le,{type:"number",min:1,value:M>=60?Math.round(M/60):M,onChange:z=>{const V=parseInt(z.target.value)||0;I(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(z=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${z.label==="Minutes"&&M<60||z.label==="Hours"&&M>=60&&M<1440||z.label==="Days"&&M>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{z.label==="Minutes"?I(30):z.label==="Hours"?I(60):I(1440)},children:z.label},z.label))})]})]}),w==="email"&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Le,{value:u,onChange:z=>m(z.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(ye,{className:"text-xs font-medium",children:w==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:z=>{z.target.value&&$(z.target.value),z.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),F5s.map(z=>e.jsx("option",{value:z.key,children:z.label},z.key))]})]})]}),e.jsx("textarea",{value:f,onChange:z=>g(z.target.value),placeholder:w==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs font-medium",children:"Attached Video"}),y?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"}),y.length>50?y.slice(0,50)+"...":y]}),e.jsx(G,{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(k3e,{onVideoReady:z=>_(z)}),e.jsx(N3e,{userId:l,onSelect:z=>_(z),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const z=prompt("Paste a YouTube or Loom URL:");z&&_(z)},children:[e.jsx(Uo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(G,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(kr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(G,{size:"sm",className:"text-xs",onClick:q,disabled:P,children:P?"Saving...":"Save Drip"})]})]})]})]})}function H5s({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(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(Ki,{className:"h-3 w-3"}):e.jsx(rr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(Ye,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Ji,{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(mn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(G,{onClick:c=>{c.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const edt=()=>{const t=hc();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 G5s(){return k.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Coe,{children:[e.jsx(xs,{path:"/c/:shareToken",element:e.jsx(Jct,{})}),e.jsx(xs,{path:"*",element:e.jsx(edt,{})})]})}const Zye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function tdt({slugOverride:t}){const s=ao(),r=t||s.slug,[n,a]=k.useState("types"),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,m]=k.useState(null),[f,g]=k.useState(new Date),[y,_]=k.useState({name:"",email:"",phone:"",message:""}),[w,j]=k.useState(!1),{data:N,isLoading:S}=pt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return Q},enabled:!!r}),{data:M}=pt({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(ce)throw ce;return Q},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=pt({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:ce}=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(ce)throw ce;return Q},enabled:!!(N!=null&&N.user_id)}),{data:P=[]}=pt({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:ce}=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(ce)throw ce;return Q},enabled:!!(N!=null&&N.user_id)}),{data:O=[]}=pt({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(ce)throw ce;return Q.map(ne=>ne.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:q=[]}=pt({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const Q=ds(i,"yyyy-MM-dd"),{data:ce,error:ne}=await H.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",Q).eq("status","confirmed");if(ne)throw ne;return ce},enabled:!!(N!=null&&N.user_id)&&!!i}),$=k.useMemo(()=>[...new Set(P.map(Q=>Q.day_of_week))],[P]),z=Q=>{const ce=Um(new Date),ne=Ll(ce,(N==null?void 0:N.max_advance_days)||30),re=Ll(ce,0);return s3(Q,re)||t3(Q,ne)||O.includes(ds(Q,"yyyy-MM-dd"))?!1:$.includes(Q.getDay())},V=k.useMemo(()=>{if(!i||!o||!N)return[];const Q=P.filter(xe=>xe.day_of_week===i.getDay()),ce=o.duration_minutes,ne=N.buffer_minutes||0,re=[],oe=new Date,he=(N.min_notice_hours||2)*60*60*1e3;for(const xe of Q){const[ue,ge]=xe.start_time.split(":").map(Number),[_e,Be]=xe.end_time.split(":").map(Number);let Se=l8(o8(i,ue),ge);const Ee=l8(o8(i,_e),Be);for(;bM(Se,ce)<=Ee;){const Ae=ds(Se,"HH:mm"),Me=ds(bM(Se,ce),"HH:mm");Se.getTime()-oe.getTime()>=he&&(q.some(Oe=>{const qe=Oe.start_time.slice(0,5),ve=Oe.end_time.slice(0,5);return Aeqe})||re.push(Ae)),Se=bM(Se,ce+ne)}}return re},[i,o,P,N,q]),X=k.useMemo(()=>{const Q=f.getFullYear(),ce=f.getMonth(),ne=new Date(Q,ce,1),re=new Date(Q,ce+1,0),oe=ne.getDay(),he=[];for(let xe=0;xe{if(!(!o||!i||!u||!y.name||!N)){j(!0);try{const Q=ds(bM(l8(o8(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ce}=await H.from("bookings").insert({agent_user_id:N.user_id,booking_type_id:o.id,booking_date:ds(i,"yyyy-MM-dd"),start_time:u,end_time:Q,guest_name:y.name,guest_email:y.email||null,guest_phone:y.phone||null,guest_message:y.message||null});if(ce)throw ce;H.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:y.name,guestEmail:y.email||null,guestPhone:y.phone||null,guestMessage:y.message||null,bookingTypeName:o.name,bookingDate:ds(i,"yyyy-MM-dd"),startTime:u,endTime:Q,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(ne=>console.error("Booking notify error:",ne)),a("confirmed")}catch(Q){me.error("Failed to book: "+Q.message)}finally{j(!1)}}},J=Q=>{const[ce,ne]=Q.split(":").map(Number),re=ce>=12?"PM":"AM";return`${ce%12||12}:${ne.toString().padStart(2,"0")} ${re}`};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(Zi,{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(Nn,{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(rr,{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:I.map(Q=>e.jsx("button",{onClick:()=>{l(Q),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:Q.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:Zye[Q.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:Q.name}),Q.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Q.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(mn,{className:"h-3 w-3"}),Q.duration_minutes,"m"]})]})})},Q.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),c(null),m(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Ga,{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:Zye[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(mn,{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:ds(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(tl,{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(Q=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Q},Q)),X.map((Q,ce)=>{if(!Q)return e.jsx("div",{},`pad-${ce}`);const ne=z(Q),re=i&&Tl(Q,i),oe=Tl(Q,new Date);return e.jsx("button",{disabled:!ne,onClick:()=>{c(Q),m(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${re?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ne?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${oe&&!re?"ring-1 ring-[#406E71]/40":""}`,children:Q.getDate()},Q.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fd,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ds(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(mn,{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(Q=>{const ce=u===Q;return e.jsx("button",{onClick:()=>m(Q),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${ce?"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:J(Q)},Q)})}),u&&e.jsx(G,{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(Ga,{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:Zye[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(Fd,{className:"h-3.5 w-3.5 text-[#406E71]"}),ds(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3.5 w-3.5 text-[#406E71]"}),J(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(Le,{value:y.name,onChange:Q=>_({...y,name:Q.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Le,{type:"email",value:y.email,onChange:Q=>_({...y,email:Q.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Nn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Le,{type:"tel",value:y.phone,onChange:Q=>_({...y,phone:Q.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Tr,{value:y.message,onChange:Q=>_({...y,message:Q.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(G,{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:Y,disabled:!y.name||w,children:w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(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&&ds(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&J(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(Nn,{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(rr,{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(Fd,{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 W5s(){const s=hc().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(tdt,{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 K5s(){const s=hc().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(MQe,{slugOverride:s})}function sdt({slugOverride:t}){const{slug:s}=ao(),r=t||s,[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(0),[u,m]=k.useState(!1),{data:f,isLoading:g}=pt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:q,error:$}=await H.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if($)throw $;return q},enabled:!!r}),{data:y=[]}=pt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:q,error:$}=await H.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if($)throw $;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 _=Tt({mutationFn:async()=>{const q=y.find(Q=>Q.field_type==="text"&&Q.label.toLowerCase().includes("name")),$=y.find(Q=>Q.field_type==="email"),z=y.find(Q=>Q.field_type==="phone"),V=q?String(o[q.label]||""):null,X=$?String(o[$.label]||""):null,Y=z?String(o[z.label]||""):null,{error:J}=await H.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:X,contact_phone:Y,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(J)throw J;H.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:X,contact_phone:Y,answers:o}}).catch(Q=>console.error("Landing page lead notification error:",Q))},onSuccess:()=>a(!0)}),w=q=>{q.preventDefault(),!(y.filter(z=>z.is_required&&!o[z.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 j=f.primary_color||"#406E71",N=f.accent_color||"#2a4c64",S=f,M=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",P=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, ${j}, ${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:j}}),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:j},children:[e.jsx(vi,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(Nn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(rr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const q=$=>{const z=parseFloat($.replace(/[^0-9.]/g,""));return isNaN(z)?$:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(z)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&P.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>m(!1),children:[e.jsx("button",{onClick:()=>m(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Er,{className:"h-8 w-8"})}),e.jsx("button",{onClick:$=>{$.stopPropagation(),c(z=>z===0?P.length-1:z-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(tl,{className:"h-6 w-6"})}),e.jsx("img",{src:P[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:$=>$.stopPropagation()}),e.jsx("button",{onClick:$=>{$.stopPropagation(),c(z=>z===P.length-1?0:z+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," / ",P.length]})]}),P.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":j},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),P.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),m(!0)},children:[e.jsx("img",{src:P[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(tw,{className:"h-4 w-4"})," View"]})]}):P.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:P.slice(0,2).map(($,z)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{c(z),m(!0)},children:e.jsx("img",{src:$,alt:`Property ${z+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},z))}):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),m(!0)},children:e.jsx("img",{src:P[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),P.slice(1,5).map(($,z)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{c(z+1),m(!0)},children:[e.jsx("img",{src:$,alt:`Property ${z+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),z===3&&P.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",P.length-5," more"]})]},z))]}),P.length>2&&e.jsxs("button",{onClick:()=>{c(0),m(!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(tw,{className:"h-4 w-4"})," View all ",P.length," photos"]})]}),P.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${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:j},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(aa,{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(Th,{className:"h-5 w-5",style:{color:j}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(au,{className:"h-5 w-5",style:{color:j}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Ix,{className:"h-5 w-5",style:{color:j}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:j},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Nn,{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(rr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-3",children:[y.map($=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-xs font-medium",children:[$.label,$.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),w9e($,o,l)]},$.id)),e.jsx(G,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},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, ${j}, ${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(vi,{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(Nn,{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(rr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[y.map(q=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-sm font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),w9e(q,o,l)]},q.id)),e.jsx(G,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},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 w9e(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(Le,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Tr,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(Rs,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Ls,{className:"mt-1",children:e.jsx($s,{placeholder:"Select..."})}),e.jsx(Ds,{children:o.map(l=>e.jsx(ft,{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(Mo,{checked:i.includes(l),onCheckedChange:c=>{const u=c?[...i,l]:i.filter(m=>m!==l);r(m=>({...m,[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(Le,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function Z5s(){const s=hc().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(sdt,{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 Ome=[{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}],mEs={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",property_types:"Property Types Gallery",advantages:"Advantages / Why Choose Us",lifestyle_gallery:"Lifestyle Gallery",market_pulse:"Market Pulse",concierge_services:"Concierge Services",land_use_guide:"Land Use Guide",land_valuation_cta:"Land Valuation CTA",acreage_showcase:"Acreage Showcase"},pEs={hero:"Full-screen background image with headline, subtitle, and search bar",featured_listings:"Grid of highlighted properties from the MLS",featured_areas:"Spotlight regions or neighborhoods that link to property search",about:"Agent photo, bio, and credentials section",testimonials:"Client reviews carousel with quotes",cta_banner:"Call-to-action block to drive contact and search engagement",new_listings:"Horizontal carousel of newest listings, filterable by city",open_houses:"Horizontal carousel of open house listings, filterable by city",my_listings:"Showcase the agent's own active listings in a carousel",city_pages:"Grid of your city landing pages with photos and links",property_types:"Visual gallery of property categories (Ranch, Farm, Land, etc.)",advantages:"Feature cards highlighting your expertise and unique value",lifestyle_gallery:"Cinematic photo grid showcasing luxury living — pools, views, interiors",market_pulse:"Sleek market stats dashboard with avg price, days on market, inventory",concierge_services:"White-glove services showcase — staging, design, moving coordination",land_use_guide:"Interactive land use cards — Agriculture, Hunting, Equestrian, Recreational",land_valuation_cta:`"What's Your Land Worth?" — bold call-to-action for landowners`,acreage_showcase:"Large visual cards emphasizing lot size with aerial imagery"},j9e={basic:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner"],luxury:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","lifestyle_gallery","market_pulse","concierge_services"],"land-ranch":["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","property_types","advantages","land_use_guide","land_valuation_cta","acreage_showcase"]};function fEs(t){return j9e[t]||j9e.basic}function Y5s(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:Ome,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 Q5s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function X5s(){const t=Q5s(),{data:s,isLoading:r,error:n}=pt({queryKey:["lead-site",t],queryFn:async()=>{var m;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&&((m=f.teams)!=null&&m.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=Y5s(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 r6(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 rdt=k.createContext(null);function V3(){const t=k.useContext(rdt);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function J5s({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,y)=>{const _=(y==null?void 0:y.user)??null;if(n(_),_){const{data:w}=await H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",_.id).eq("lead_site_id",t.id).maybeSingle();w&&o({...w,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:y})=>{y&&o({...y,email:g.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const c=k.useCallback(async f=>{const g=f.email.toLowerCase().trim(),y=f.phone.replace(/\D/g,""),{data:_,error:w}=await H.auth.signUp({email:g,password:y,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(w){if(w.message.includes("already registered")){await u(g,y);return}throw w}if(_.user){const{error:j}=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()});j&&console.warn("Consumer profile insert error:",j);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),r6(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 y=g.replace(/\D/g,""),{error:_}=await H.auth.signInWithPassword({email:f.toLowerCase().trim(),password:y});if(_)throw _},[]),m=k.useCallback(async()=>{await H.auth.signOut(),n(null),o(null)},[]);return e.jsx(rdt.Provider,{value:{user:r,profile:a,isLoading:l,signUp:c,signIn:u,signOut:m},children:s})}function UR({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a}){var O;const{signUp:o,signIn:l}=V3(),[i,c]=k.useState(!1),[u,m]=k.useState(""),[f,g]=k.useState(""),[y,_]=k.useState(""),[w,j]=k.useState(!1),[N,S]=k.useState(""),M=s==="required",I=((O=r.agent)==null?void 0:O.full_name)||"the agent",P=async q=>{var z;if(q.preventDefault(),S(""),!f.trim()||!y.trim()){S("Email and phone number are required.");return}if(!i&&!u.trim()){S("Name is required.");return}if(y.replace(/\D/g,"").length<7){S("Please enter a valid phone number.");return}j(!0);try{i?await l(f,y):await o({name:u,email:f,phone:y}),n()}catch(V){(z=V==null?void 0:V.message)!=null&&z.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{j(!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(js,{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 ${I}.`})]}),e.jsxs("form",{onSubmit:P,className:"space-y-3 mt-2",children:[!i&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:u,onChange:q=>m(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:y,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:w,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:w?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 VR({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(Pl,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(a)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(o)})]})}function Rme({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(Pl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function ndt({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(Pl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function eMs({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(Pl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function tMs({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(Pl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(c)})})}const N9e="ls_visitor_geo",sMs=1e3*60*60;function rMs(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 nMs(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 aMs(){try{const t=localStorage.getItem(N9e);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,aMs().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=rMs(l),c=nMs(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,m=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:(m==null?void 0:m.city)||null,visitor_region:(m==null?void 0:m.region)||null,visitor_country:(m==null?void 0:m.country)||null,visitor_lat:(m==null?void 0:m.lat)||null,visitor_lng:(m==null?void 0:m.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}const iMs=3e4;function I3e(t,s){const r=hc(),n=k.useRef(null),a=k.useRef(null),o=k.useRef(0),l=r.pathname,i=oMs(l),c=lMs(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 m=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,f=async()=>{const{data:g,error:y}=await H.from("lead_site_active_visitors").upsert({lead_site_id:t.id,auth_user_id:s,visitor_fingerprint:m,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();!y&&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,iMs),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;const m=()=>{n.current&&H.from("lead_site_active_visitors").delete().eq("id",n.current).then(()=>{})};return window.addEventListener("beforeunload",m),()=>window.removeEventListener("beforeunload",m)},[t==null?void 0:t.id,s])}function oMs(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":"other"}function lMs(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 cMs({children:t,siteConfig:s}){var xe,ue,ge,_e,Be,Se,Ee,Ae,Me;const r=hc(),n=ar(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[m,f]=k.useState([]),[g,y]=k.useState([]),[_,w]=k.useState(null),j=k.useRef(null),N=k.useRef(null),{user:S,profile:M,signOut:I}=V3();P3e(s,S==null?void 0:S.id),I3e(s,S==null?void 0:S.id);const P=((xe=s.agent)==null?void 0:xe.full_name)||"Agent",O=s.siteTitle||`${P} Real Estate`,q=r.pathname==="/search",$=r.pathname==="/",z=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{(async()=>{const{data:Oe}=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(Oe||[])})()},[s.id]),k.useEffect(()=>{(async()=>{const{data:Oe}=await H.from("lead_site_menu_items").select("*").eq("site_id",s.id).eq("is_visible",!0).order("sort_order",{ascending:!0});y(Oe||[])})()},[s.id]),k.useEffect(()=>{const ke=Oe=>{j.current&&!j.current.contains(Oe.target)&&u(!1),N.current&&!N.current.contains(Oe.target)&&w(null)};return document.addEventListener("mousedown",ke),()=>document.removeEventListener("mousedown",ke)},[]);const V=g.length>0,Y=V?[]:[{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"}],J=g.filter(ke=>!ke.parent_id),Q=ke=>g.filter(Oe=>Oe.parent_id===ke),ce=$?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",ne=s.siteTitle||`${P} - Real Estate`,re=s.siteTagline||`Browse homes and listings with ${P}`,oe=s.ogImageUrl||((ue=s.agent)==null?void 0:ue.avatar_url)||"",he=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${q?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(VR,{siteConfig:s,pagePath:r.pathname}),e.jsxs(Pl,{children:[e.jsx("title",{children:ne}),e.jsx("meta",{name:"description",content:re}),e.jsx("meta",{property:"og:title",content:ne}),e.jsx("meta",{property:"og:description",content:re}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:he+r.pathname}),oe&&e.jsx("meta",{property:"og:image",content:oe}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ne}),e.jsx("meta",{name:"twitter:description",content:re}),oe&&e.jsx("meta",{name:"twitter:image",content:oe}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${he}${r.pathname}`}),s.subdomainSlug==="matthogg"&&e.jsx("script",{src:"https://analytics.ahrefs.com/analytics.js","data-key":"kyFjzruyvE0yTdMokzgCBw",async:!0})]}),e.jsxs("header",{className:`${$?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${ce}`,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(la,{to:"/",className:"flex items-center gap-3",children:[((ge=s.agent)==null?void 0:ge.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:P,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:O})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[Y.map(ke=>e.jsx(la,{to:ke.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ke.to?$?"bg-white/15 text-white":"bg-gray-100 text-gray-900":$?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:ke.label},ke.to)),V&&J.map(ke=>{if(ke.item_type==="dropdown"){const Oe=Q(ke.id);return e.jsxs("div",{ref:N,className:"relative",children:[e.jsxs("button",{onClick:()=>w(_===ke.id?null:ke.id),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${$?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[ke.label," ",e.jsx(Ji,{className:`h-3.5 w-3.5 transition-transform ${_===ke.id?"rotate-180":""}`})]}),_===ke.id&&Oe.length>0&&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:Oe.map(qe=>e.jsx(k9e,{item:qe,onClick:()=>w(null),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 block"},qe.id))})]},ke.id)}return e.jsx(k9e,{item:ke,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${$?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`},ke.id)}),m.length>0&&e.jsxs("div",{ref:j,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-")?$?"bg-white/15 text-white":"bg-gray-100 text-gray-900":$?"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(Ji,{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:m.map(ke=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ke.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:ke.city_name},ke.city_slug))})]}),S?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(la,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${$?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Ja,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(la,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${$?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Zi,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((_e=M==null?void 0:M.name)==null?void 0:_e.split(" ")[0])||"Account"})]})]}):z?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${$?"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 ${$?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(Er,{className:"h-5 w-5"}):e.jsx(gS,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${$?"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:[Y.map(ke=>e.jsx(la,{to:ke.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ke.to?$?"bg-white/15 text-white":"bg-gray-100 text-gray-900":$?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ke.label},ke.to)),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${$?"text-white/40":"text-gray-400"}`,children:"Cities"}),m.map(ke=>e.jsx(la,{to:`/homes-for-sale-in-${ke.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ke.city_slug}`?$?"bg-white/15 text-white":"bg-gray-100 text-gray-900":$?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ke.city_name},ke.city_slug))]}),S?e.jsxs(e.Fragment,{children:[e.jsx(la,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${$?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"My Account"}),e.jsx("button",{onClick:async()=>{await I(),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${$?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):z?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 ${$?"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}),!q&&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:[((Be=s.agent)==null?void 0:Be.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:P,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:P}),e.jsx("p",{className:"text-sm text-gray-500",children:((Se=s.agent)==null?void 0:Se.title)||"Real Estate Professional"})]})]}),((Ee=s.agent)==null?void 0:Ee.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(Nn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((Ae=s.agent)==null?void 0:Ae.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(rr,{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:Y.map(ke=>e.jsx("li",{children:e.jsx(la,{to:ke.to,className:"hover:text-white transition-colors",children:ke.label})},ke.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(la,{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:[P," · ",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()," ",P,". Powered by LevelUp."]})]})]})]})}),!q&&((Me=s.agent)==null?void 0:Me.avatar_url)&&e.jsx(dMs,{agent:s.agent}),l&&e.jsx(UR,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function dMs({agent:t}){var a;const[s,r]=k.useState(!1),n=ar();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(Nn,{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(rr,{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(Er,{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}function k9e({item:t,className:s,onClick:r}){const n=t.target_url||"#";return t.item_type==="external"||t.open_in_new_tab?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:s,onClick:r,children:t.label}):e.jsx(la,{to:n,className:s,onClick:r,children:t.label})}function uMs({children:t,siteConfig:s}){var Q,ce,ne,re,oe,he,xe;const r=hc(),n=ar(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[m,f]=k.useState([]),[g,y]=k.useState(!1),_=k.useRef(null),{user:w,profile:j,signOut:N}=V3();P3e(s,w==null?void 0:w.id),I3e(s,w==null?void 0:w.id);const S=((Q=s.agent)==null?void 0:Q.full_name)||"Agent",M=s.siteTitle||`${S} Real Estate`,I=r.pathname==="/search",P=r.pathname==="/",O=s.leadRegistrationMode!=="disabled",q="#c9a96e";k.useEffect(()=>{const ue=()=>y(window.scrollY>80);return window.addEventListener("scroll",ue,{passive:!0}),()=>window.removeEventListener("scroll",ue)},[]),k.useEffect(()=>{(async()=>{const{data:ge}=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(ge||[])})()},[s.id]),k.useEffect(()=>{const ue=ge=>{_.current&&!_.current.contains(ge.target)&&u(!1)};return document.addEventListener("mousedown",ue),()=>document.removeEventListener("mousedown",ue)},[]);const $=[{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"}],z=s.siteTitle||`${S} - Real Estate`,V=s.siteTagline||`Browse homes and listings with ${S}`,X=s.ogImageUrl||((ce=s.agent)==null?void 0:ce.avatar_url)||"",Y=`https://${s.subdomainSlug||""}.thelocalmove.com`,J=P?g?"bg-[#0d0b0a]/95 backdrop-blur-lg border-b border-white/5":"bg-transparent":"bg-[#0d0b0a] border-b border-white/5";return e.jsxs("div",{className:`flex flex-col ${I?"h-screen overflow-hidden":"min-h-screen"} bg-[#0d0b0a]`,children:[e.jsx(VR,{siteConfig:s,pagePath:r.pathname}),e.jsxs(Pl,{children:[e.jsx("title",{children:z}),e.jsx("meta",{name:"description",content:V}),e.jsx("meta",{property:"og:title",content:z}),e.jsx("meta",{property:"og:description",content:V}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:Y+r.pathname}),X&&e.jsx("meta",{property:"og:image",content:X}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:z}),e.jsx("meta",{name:"twitter:description",content:V}),X&&e.jsx("meta",{name:"twitter:image",content:X}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${Y}${r.pathname}`}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap",rel:"stylesheet"})]}),e.jsxs("header",{className:`${P?"fixed":"sticky"} top-0 left-0 right-0 z-50 transition-all duration-500 ${J}`,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.jsx(la,{to:"/",className:"flex items-center gap-3",children:e.jsx("span",{className:"text-white text-xl tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:M})}),e.jsxs("nav",{className:"hidden lg:flex items-center gap-1",children:[$.map(ue=>e.jsx(la,{to:ue.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===ue.to?"text-white":"text-white/40 hover:text-white"}`,children:ue.label},ue.to)),m.length>0&&e.jsxs("div",{ref:_,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!c),className:`flex items-center gap-1 px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname.startsWith("/homes-for-sale-in-")?"text-white":"text-white/40 hover:text-white"}`,children:["Cities ",e.jsx(Ji,{className:`h-3 w-3 transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-[#1a1715] border border-white/10 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:m.map(ue=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ue.city_slug}`),u(!1)},className:"w-full text-left px-5 py-2.5 text-xs tracking-wider text-white/50 hover:text-white hover:bg-white/5 uppercase transition-colors",children:ue.city_name},ue.city_slug))})]}),w?e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsxs(la,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Ja,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Saved"})]}),e.jsxs(la,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Zi,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:((ne=j==null?void 0:j.name)==null?void 0:ne.split(" ")[0])||"Account"})]})]}):O?e.jsx("button",{onClick:()=>i(!0),className:"ml-3 px-5 py-2 text-xs tracking-[0.2em] uppercase border border-white/20 text-white/60 hover:bg-white hover:text-black transition-all duration-500",children:"Sign In"}):null]}),e.jsxs("button",{onClick:()=>o(!a),className:"lg:hidden p-2 text-white/60 hover:text-white",children:[e.jsx("div",{className:"flex flex-col items-center gap-0.5",children:a?e.jsx(Er,{className:"h-5 w-5"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-px bg-current"}),e.jsx("div",{className:"w-4 h-px bg-current mt-1.5"}),e.jsx("div",{className:"w-6 h-px bg-current mt-1.5"})]})}),e.jsx("span",{className:"text-[8px] tracking-[0.3em] uppercase mt-1 block",children:"MENU"})]})]})}),a&&e.jsx("div",{className:"lg:hidden border-t border-white/5 bg-[#0d0b0a]/98 backdrop-blur-lg",children:e.jsxs("div",{className:"px-6 py-4 space-y-1",children:[$.map(ue=>e.jsx(la,{to:ue.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===ue.to?"text-white":"text-white/40 hover:text-white"}`,children:ue.label},ue.to)),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-4 pb-2 text-[10px] tracking-[0.3em] uppercase",style:{color:q},children:"Cities"}),m.map(ue=>e.jsx(la,{to:`/homes-for-sale-in-${ue.city_slug}`,onClick:()=>o(!1),className:"block px-3 py-2.5 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:ue.city_name},ue.city_slug))]}),w?e.jsxs(e.Fragment,{children:[e.jsx(la,{to:"/account",onClick:()=>o(!1),className:"block px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"My Account"}),e.jsx("button",{onClick:async()=>{await N(),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign Out"})]}):O?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!I&&e.jsx("footer",{className:"bg-[#0a0908] text-white/30 border-t border-white/5",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-20",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-16",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-xl tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:S}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.15em] uppercase mb-6",children:((re=s.agent)==null?void 0:re.title)||"Real Estate Professional"}),((oe=s.agent)==null?void 0:oe.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors mb-3",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]}),((he=s.agent)==null?void 0:he.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors",children:[e.jsx(rr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:q},children:"Quick Links"}),e.jsx("ul",{className:"space-y-3",children:$.map(ue=>e.jsx("li",{children:e.jsx(la,{to:ue.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:ue.label})},ue.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:q},children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-white/20 leading-relaxed mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Ready to experience luxury real estate? Let's connect."}),e.jsx(la,{to:"/contact",className:"inline-block px-8 py-3 text-xs tracking-[0.3em] uppercase border border-white/15 text-white/50 hover:bg-white hover:text-black transition-all duration-500",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-16 pt-8 border-t border-white/5",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-10 w-auto object-contain opacity-40"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-[10px] text-white/15 tracking-wider uppercase mb-3",children:[e.jsxs("span",{children:[S," · ",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-6 w-auto flex-shrink-0 mt-0.5 opacity-30"}),e.jsx("p",{className:"text-[10px] text-white/15 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px] text-white/15 tracking-wider uppercase",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-4 w-4",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()," ",S,". Powered by LevelUp."]})]})]})]})}),!I&&((xe=s.agent)==null?void 0:xe.avatar_url)&&e.jsx(hMs,{agent:s.agent,accentColor:q}),l&&e.jsx(UR,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function hMs({agent:t,accentColor:s}){var o;const[r,n]=k.useState(!1),a=ar();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:r?e.jsxs("div",{className:"bg-[#1a1715] border border-white/10 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-4",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:t.full_name}),e.jsx("p",{className:"text-white/30 text-[10px] tracking-[0.1em] uppercase",children:t.title||"Real Estate Professional"})]})]}),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.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"})," ",t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(rr,{className:"h-3.5 w-3.5"})," Email Me"]}),e.jsx("button",{onClick:()=>{n(!1),a("/contact")},className:"w-full px-3 py-2.5 text-xs tracking-[0.2em] uppercase text-black hover:opacity-90 transition-colors",style:{backgroundColor:s},children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>n(!1),className:"absolute top-3 right-3 p-1 text-white/20 hover:text-white/50",children:e.jsx(Er,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-3 bg-[#1a1715] border border-white/10 pl-1.5 pr-5 py-1.5 hover:border-white/20 transition-all",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-[11px] text-white leading-none",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(o=t.full_name)==null?void 0:o.split(" ")[0]}),e.jsx("p",{className:"text-[9px] tracking-[0.15em] uppercase mt-1",style:{color:s},children:"Let's connect →"})]})]})}):null}const II="#2c1810",Gy="#b8860b";function mMs({children:t,siteConfig:s}){var $,z,V;const r=hc();ar();const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,m]=k.useState([]),[f,g]=k.useState(!1),y=k.useRef(null),{user:_,profile:w,signOut:j}=V3();P3e(s,_==null?void 0:_.id),I3e(s,_==null?void 0:_.id);const N=(($=s.agent)==null?void 0:$.full_name)||"Agent",S=s.siteTitle||`${N} Land & Ranch`,M=r.pathname==="/",I=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{const X=()=>g(window.scrollY>80);return window.addEventListener("scroll",X,{passive:!0}),()=>window.removeEventListener("scroll",X)},[]),k.useEffect(()=>{(async()=>{const{data:Y}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order");Y&&m(Y)})()},[s.id]),k.useEffect(()=>{const X=Y=>{y.current&&!y.current.contains(Y.target)&&c(!1)};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[]);const P=[{label:"Home",path:"/"},{label:"Search Properties",path:"/search"},{label:"About",path:"/about"},{label:"Contact",path:"/contact"}],O=f||!M?"bg-white/95 backdrop-blur-md shadow-sm":"bg-transparent",q=f||!M?II:"#ffffff";return e.jsxs("div",{className:"min-h-screen",style:{fontFamily:"'Lora', Georgia, serif"},children:[e.jsxs(Pl,{children:[e.jsx("title",{children:S}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=Lora:wght@400;500;600&display=swap",rel:"stylesheet"})]}),e.jsx(VR,{siteConfig:s}),e.jsxs("header",{className:`fixed top-0 left-0 right-0 z-50 transition-all duration-300 ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6",children:e.jsxs("div",{className:"flex items-center justify-between h-16 md:h-20",children:[e.jsxs(la,{to:"/",className:"flex items-center gap-2.5",children:[e.jsx(d1,{className:"w-7 h-7",style:{color:Gy}}),e.jsx("span",{className:"text-lg font-bold tracking-wide",style:{color:q,fontFamily:"'Playfair Display', Georgia, serif"},children:S})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[P.map(X=>e.jsx(la,{to:X.path,className:"px-4 py-2 text-sm font-medium tracking-wide uppercase transition-colors hover:opacity-80",style:{color:r.pathname===X.path?Gy:q},children:X.label},X.path)),u.length>0&&e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{onClick:()=>c(!i),className:"px-4 py-2 text-sm font-medium tracking-wide uppercase flex items-center gap-1 transition-colors hover:opacity-80",style:{color:q},children:["Areas ",e.jsx(Ji,{className:`w-3.5 h-3.5 transition-transform ${i?"rotate-180":""}`})]}),i&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 animate-in fade-in-0 slide-in-from-top-2",children:u.map(X=>e.jsx(la,{to:`/homes-for-sale-in-${X.city_slug}`,className:"block px-4 py-2.5 text-sm hover:bg-gray-50 transition-colors",style:{color:II},onClick:()=>c(!1),children:X.city_name},X.city_slug))})]}),_?e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs(la,{to:"/account",className:"px-4 py-2 text-sm font-medium rounded-full border-2 transition-all hover:scale-105",style:{borderColor:Gy,color:q},children:[e.jsx(Zi,{className:"w-4 h-4 inline mr-1.5"}),(w==null?void 0:w.name)||"Account"]})}):I?e.jsx("button",{onClick:()=>l(!0),className:"ml-3 px-5 py-2.5 text-sm font-semibold text-white rounded-full hover:shadow-lg transition-all hover:scale-105",style:{backgroundColor:Gy},children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>a(!n),className:"md:hidden p-2",style:{color:q},children:n?e.jsx(Er,{className:"w-6 h-6"}):e.jsx(gS,{className:"w-6 h-6"})})]})}),n&&e.jsx("div",{className:"md:hidden bg-white border-t border-gray-100 shadow-xl animate-in slide-in-from-top-2",children:e.jsxs("div",{className:"px-4 py-4 space-y-1",children:[P.map(X=>e.jsx(la,{to:X.path,className:"block px-4 py-3 text-base font-medium rounded-lg hover:bg-gray-50 transition-colors",style:{color:r.pathname===X.path?Gy:II},onClick:()=>a(!1),children:X.label},X.path)),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-2 text-xs font-semibold tracking-wider uppercase text-gray-400",children:"Areas"}),u.map(X=>e.jsx(la,{to:`/homes-for-sale-in-${X.city_slug}`,className:"block px-4 py-2.5 text-sm rounded-lg hover:bg-gray-50",style:{color:II},onClick:()=>a(!1),children:X.city_name},X.city_slug))]}),!_&&I&&e.jsx("button",{onClick:()=>{l(!0),a(!1)},className:"w-full mt-3 px-5 py-3 text-white font-semibold rounded-full",style:{backgroundColor:Gy},children:"Sign In"})]})})]}),e.jsx("main",{children:t}),e.jsx("footer",{className:"py-16 px-4",style:{backgroundColor:II},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(d1,{className:"w-6 h-6",style:{color:Gy}}),e.jsx("span",{className:"text-lg font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:S})]}),e.jsx("p",{className:"text-white/60 text-sm leading-relaxed",children:"Your trusted specialist in land, ranch, and rural properties. Expert guidance for every acre."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("div",{className:"space-y-2",children:P.map(X=>e.jsx(la,{to:X.path,className:"block text-white/60 hover:text-white text-sm transition-colors",children:X.label},X.path))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Contact"}),e.jsxs("div",{className:"space-y-3",children:[((z=s.agent)==null?void 0:z.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(Nn,{className:"w-4 h-4",style:{color:Gy}}),s.agent.phone]}),((V=s.agent)==null?void 0:V.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(rr,{className:"w-4 h-4",style:{color:Gy}}),s.agent.email]})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("p",{className:"text-white/40 text-xs",children:["© ",new Date().getFullYear()," ",S,". All rights reserved."]}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:Gy}})]})]})}),o&&e.jsx(UR,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const pMs={city:{icon:aa,label:"City"},zip:{icon:Y_,label:"ZIP Code"},county:{icon:y0,label:"County"}};function Fme({suggestions:t,cities:s,value:r,onChange:n,onSelect:a,placeholder:o,className:l,inputClassName:i}){const[c,u]=k.useState(!1),m=k.useRef(null),f=t.length>0?t:(s||[]).map(j=>({label:j,type:"city"})),g=r.trim()?f.filter(j=>j.label.toLowerCase().includes(r.toLowerCase())).slice(0,10):f.slice(0,10),y=g.reduce((j,N)=>(j[N.type]||(j[N.type]=[]),j[N.type].push(N),j),{}),_=c&&g.length>0;k.useEffect(()=>{const j=N=>{m.current&&!m.current.contains(N.target)&&u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const w=["city","zip","county"];return e.jsxs("div",{ref:m,className:`relative ${l||""}`,children:[e.jsx("input",{type:"text",value:r,onChange:j=>{n(j.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:w.map(j=>{const N=y[j];if(!N||N.length===0)return null;const S=pMs[j],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(I=>e.jsxs("button",{type:"button",onMouseDown:P=>{P.preventDefault(),a(I.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:I.label})]},`${j}-${I.label}`))]},j)})})]})}function L3e({siteId:t,accentColor:s}){const r=ar(),{data:n}=pt({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(aa,{className:"h-4 w-4"}),"View Properties",e.jsx(ba,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})})]})]},o.id))})]})})}function C1({siteConfig:t,accentColor:s,sectionTitle:r,cities:n,count:a=12,mode:o,luxuryMode:l=!1}){const i=ar(),[c,u]=k.useState([]),[m,f]=k.useState(!0),g=k.useRef(null),[y,_]=k.useState(!1),[w,j]=k.useState(!1);k.useEffect(()=>{(async()=>{try{const O="https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",q={leadSiteId:t.id,pageSize:a},$=async V=>{var J;const X=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify(V),signal:AbortSignal.timeout(15e3)});return X.ok?((J=(await X.json()).listings)==null?void 0:J.slice(0,a))||[]:[]};if(n){const V=n.split(",").map(X=>X.trim()).filter(Boolean);V.length>0&&(q.query=V[0],q.filterCities=V)}o==="open_houses"&&(q.openHousesOnly=!0),o==="my_listings"&&(q.agentListings=!0,q.agentId=t.agentId),o==="new_listings"&&(q.sortBy="newest");let z=await $(q);if(z.length===0&&n&&o!=="my_listings"){const V={...q};delete V.query,delete V.filterCities,z=await $(V)}u(z)}catch{}finally{f(!1)}})()},[t.id,n,a,o,t.agentId]);const N=()=>{const P=g.current;P&&(_(P.scrollLeft>10),j(P.scrollLeft{const P=g.current;if(P)return N(),P.addEventListener("scroll",N,{passive:!0}),window.addEventListener("resize",N),()=>{P.removeEventListener("scroll",N),window.removeEventListener("resize",N)}},[c]);const S=P=>{const O=g.current;if(!O)return;const q=340;O.scrollBy({left:P==="left"?-q*2:q*2,behavior:"smooth"})},M={new_listings:"New on the Market",open_houses:"Open Houses",my_listings:"My Active Listings"},I={new_listings:"The latest properties just listed",open_houses:"Tour these homes in person",my_listings:"Properties I'm currently representing"};return m?e.jsx("section",{className:`py-16 md:py-20 overflow-hidden ${l?"bg-[#0d0b0a]":""}`,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 rounded mx-auto mb-3 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-8 w-72 rounded mx-auto mb-2 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-4 w-56 rounded mx-auto animate-pulse ${l?"bg-white/5":"bg-gray-200"}`})]}),e.jsx("div",{className:"flex gap-5",children:[1,2,3,4].map(P=>e.jsxs("div",{className:`min-w-[320px] rounded-2xl overflow-hidden ${l?"bg-white/5":"bg-gray-100"}`,children:[e.jsx("div",{className:`h-56 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:`h-5 rounded w-24 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-4 rounded w-40 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`})]})]},P))})]})}):c.length?e.jsx("section",{className:`py-16 md:py-20 overflow-hidden ${l?"bg-[#0d0b0a]":""}`,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 ${l?"tracking-[0.4em]":""}`,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 tracking-tight ${l?"text-white":"text-gray-900 font-bold"}`,style:l?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:r||M[o]}),e.jsx(gs.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:`mt-1.5 ${l?"text-white/40":"text-gray-500"}`,children:I[o]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>S("left"),disabled:!y,className:`p-3 rounded-full border transition-all disabled:opacity-30 disabled:cursor-not-allowed ${l?"border-white/10 text-white/50 hover:border-white/30":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"}`,children:e.jsx(tl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>S("right"),disabled:!w,className:`p-3 rounded-full border transition-all disabled:opacity-30 disabled:cursor-not-allowed ${l?"border-white/10 text-white/50 hover:border-white/30":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"}`,children:e.jsx(da,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:g,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[c.map((P,O)=>{var q,$,z,V;return e.jsx(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:O*.05},onClick:()=>i(`/listing/${P.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:`overflow-hidden h-full flex flex-col ${l?"bg-[#161312] hover:bg-[#1a1715] transition-all duration-500":"bg-white rounded-2xl 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"}`,children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((q=P.photos)==null?void 0:q[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:P.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":P.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:["$",($=P.price)==null?void 0:$.toLocaleString()]})}),((z=P.photos)==null?void 0:z.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:[P.photos.length," photos"]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:`font-semibold text-[15px] leading-snug mb-1 truncate ${l?"text-white/80":"text-gray-900"}`,children:P.address}),e.jsxs("p",{className:`text-sm mb-3 truncate ${l?"text-white/30":"text-gray-500"}`,children:[P.city,", ",P.state," ",P.zip]}),e.jsxs("div",{className:`flex items-center gap-4 mt-auto pt-3 border-t ${l?"border-white/5":"border-gray-100"}`,children:[e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(Th,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:P.bedrooms})]}),e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(au,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:P.bathrooms})]}),e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(xS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(V=P.sqft)==null?void 0:V.toLocaleString()," sqft"]})]})]})]})]})},P.mlsNumber)}),e.jsx(gs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>i("/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(ba,{className:"h-6 w-6",style:{color:s}})}),e.jsx("p",{className:`text-sm font-semibold transition-colors ${l?"text-white/50 group-hover:text-white":"text-gray-700 group-hover:text-gray-900"}`,children:"View All"})]})})]}),e.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l pointer-events-none md:hidden ${l?"from-[#0d0b0a]":"from-white"} to-transparent`})]})]})}):null}function D3e({siteId:t,accentColor:s,sectionTitle:r}){const n=ar(),[a,o]=k.useState([]),[l,i]=k.useState(!0);if(k.useEffect(()=>{(async()=>{const{data:m}=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(m||[]),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,m)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:m*.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[m%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(ba,{className:"h-5 w-5 text-white"})})]})]},u.city_slug))})]})})}function fMs({siteConfig:t,themeConfig:s}){var m;const r=ar(),[n,a]=k.useState(""),o=((m=t.agent)==null?void 0:m.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ome,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 y=f.config||{};switch(f.type){case"hero":return e.jsx(gMs,{agentName:o,tagline:y.headline||t.siteTagline,subtitle:y.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:y.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(yMs,{siteConfig:t,accentColor:c,sectionTitle:y.sectionTitle,count:y.count},g);case"featured_areas":return e.jsx(L3e,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(vMs,{siteConfig:t,accentColor:c,config:y},g);case"testimonials":return e.jsx(bMs,{testimonials:y.testimonials||(s==null?void 0:s.testimonials)||[],brandColor:i,sectionTitle:y.sectionTitle},g);case"cta_banner":return e.jsx(_Ms,{agentName:o,accentColor:c,brandColor:i,config:y},g);case"new_listings":return e.jsx(C1,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:y.sectionTitle,cities:y.cities,count:y.count},g);case"open_houses":return e.jsx(C1,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:y.sectionTitle,cities:y.cities,count:y.count},g);case"my_listings":return e.jsx(C1,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:y.sectionTitle,count:y.count},g);case"city_pages":return e.jsx(D3e,{siteId:t.id,accentColor:c,sectionTitle:y.sectionTitle},g);default:return null}})})}function xMs(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 gMs({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:m}){const f=ar(),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(sn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-white/50 z-10"}),(()=>{const y=xMs(m);return y.length>0?e.jsx(Fme,{suggestions:y,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((y,_)=>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:y},y))})]})]})}function yMs({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=ar(),[o,l]=k.useState([]),[i,c]=k.useState(!0);return k.useEffect(()=>{(async()=>{var m;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 y=await g.json();l(((m=y.listings)==null?void 0:m.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 m,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:((m=u.photos)==null?void 0:m[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(ba,{className:"h-4 w-4"})]})})]})}):null}function vMs({siteConfig:t,accentColor:s,config:r}){const n=ar(),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 bMs({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(g1,{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(tl,{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 _Ms({agentName:t,accentColor:s,brandColor:r,config:n}){const a=ar();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 wMs="/assets/luxury-hero-mobile-DKoFc_7O.jpg";function jMs({siteConfig:t,themeConfig:s}){var m;const r=ar(),[n,a]=k.useState(""),o=((m=t.agent)==null?void 0:m.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ome,i=(s==null?void 0:s.brandColor)||"#1a1110",c=(s==null?void 0:s.accentColor)||"#c9a96e",u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{className:"bg-[#0d0b0a]",children:l.map((f,g)=>{if(!f.enabled)return null;const y=f.config||{};switch(f.type){case"hero":return e.jsx(NMs,{agentName:o,tagline:y.headline||t.siteTagline,subtitle:y.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:y.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(kMs,{siteConfig:t,accentColor:c,sectionTitle:y.sectionTitle,count:y.count},g);case"featured_areas":return e.jsx(SMs,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(CMs,{siteConfig:t,accentColor:c,brandColor:i,config:y},g);case"testimonials":return e.jsx(MMs,{testimonials:y.testimonials||(s==null?void 0:s.testimonials)||[],accentColor:c,sectionTitle:y.sectionTitle},g);case"cta_banner":return e.jsx(TMs,{agentName:o,accentColor:c,brandColor:i,config:y},g);case"new_listings":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"new_listings",luxuryMode:!0,sectionTitle:y.sectionTitle,cities:y.cities,count:y.count})},g);case"open_houses":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"open_houses",luxuryMode:!0,sectionTitle:y.sectionTitle,cities:y.cities,count:y.count})},g);case"my_listings":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"my_listings",luxuryMode:!0,sectionTitle:y.sectionTitle,count:y.count})},g);case"city_pages":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(D3e,{siteId:t.id,accentColor:c,sectionTitle:y.sectionTitle})},g);case"lifestyle_gallery":return e.jsx(AMs,{accentColor:c,config:y},g);case"market_pulse":return e.jsx(EMs,{accentColor:c,config:y},g);case"concierge_services":return e.jsx(IMs,{accentColor:c,config:y},g);default:return null}})})}function NMs({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:m}){var N,S;const f=ar(),g=n||"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=1920&q=80",y="https://id-preview--b4ed24ae-0b44-4f4d-8676-c620f649ed8a.lovable.app/__l5e/assets-v1/e1224ec9-d0e0-4ab9-ae12-caff5849bf4d/luxury-hero-video.mp4",_=(N=m==null?void 0:m.homepageModules)==null?void 0:N.find(M=>M.type==="hero"),j=((S=_==null?void 0:_.config)==null?void 0:S.heroVideoUrl)||y;return e.jsxs("section",{className:"relative h-screen flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 hidden md:block",children:[e.jsx("video",{autoPlay:!0,muted:!0,loop:!0,playsInline:!0,preload:"metadata",crossOrigin:"anonymous",poster:g,className:"w-full h-full object-cover scale-110",children:e.jsx("source",{src:j,type:"video/mp4"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/50 via-black/30 to-black/70"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/40 to-transparent"})]}),e.jsxs("div",{className:"absolute inset-0 md:hidden",children:[e.jsx("img",{src:wMs,alt:"Luxury real estate",className:"w-full h-full object-cover",width:1080,height:1920}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/50 via-black/30 to-black/70"})]}),e.jsxs("div",{className:"relative z-10 max-w-5xl mx-auto px-6 text-center",children:[e.jsxs(gs.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:1,ease:[.16,1,.3,1]},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-8",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:o}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:o},children:t}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:o}})]}),e.jsx("h1",{className:"text-5xl sm:text-6xl md:text-7xl lg:text-8xl text-white leading-[0.95] tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s||"A Luxury Experience"}),e.jsx("p",{className:"text-lg md:text-xl text-white/60 tracking-[0.2em] uppercase font-light mb-12",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:r||"At Every Price Point"})]}),e.jsx(gs.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.4,ease:[.16,1,.3,1]},className:"flex flex-wrap gap-4 justify-center mb-12",children:[{label:"PROPERTY SEARCH",action:()=>f("/search")},{label:"BUY A HOME",action:()=>f("/search")},{label:"VALUE MY HOME",action:()=>f("/sell")}].map(M=>e.jsx("button",{onClick:M.action,className:"px-8 py-3.5 text-xs tracking-[0.3em] text-white border border-white/30 hover:bg-white hover:text-black transition-all duration-500",children:M.label},M.label))}),e.jsx(gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.6},className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-0 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("span",{className:"text-white/30 text-[10px] tracking-[0.4em] uppercase",children:"Scroll"}),e.jsx("div",{className:"w-px h-8 bg-gradient-to-b from-white/30 to-transparent animate-pulse"})]})})]})]})}function kMs({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=ar(),[o,l]=k.useState([]),[i,c]=k.useState(!0);return k.useEffect(()=>{(async()=>{var m;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({leadSiteId:t.id,pageSize:n||6,page:1})});if(g.ok){const y=await g.json();l(((m=y.listings)==null?void 0:m.slice(0,6))||[])}}catch{}finally{c(!1)}})()},[t.id]),i?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsx("div",{className:"text-center mb-16",children:e.jsx("div",{className:"h-8 bg-white/5 rounded w-64 mx-auto mb-3 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/5 rounded overflow-hidden",children:[e.jsx("div",{className:"h-72 bg-white/5 animate-pulse"}),e.jsx("div",{className:"p-5 space-y-3",children:e.jsx("div",{className:"h-5 bg-white/5 rounded w-24 animate-pulse"})})]},u))})]})}):o.length?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Properties"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},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,m)=>{var f,g,y;return e.jsxs(gs.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:m*.1},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group cursor-pointer",children:[e.jsxs("div",{className:"relative overflow-hidden aspect-[4/3]",children:[e.jsx("img",{src:((f=u.photos)==null?void 0:f[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-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5",children:[e.jsxs("p",{className:"text-2xl font-bold text-white mb-1",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["$",(g=u.price)==null?void 0:g.toLocaleString()]}),e.jsx("p",{className:"text-white/70 text-sm truncate",children:u.address}),e.jsxs("p",{className:"text-white/50 text-xs",children:[u.city,", ",u.state]})]}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:s}})]}),e.jsx("div",{className:"bg-[#161312] px-5 py-4",children:e.jsxs("div",{className:"flex items-center gap-6 text-xs text-white/40 tracking-wider uppercase",children:[e.jsxs("span",{children:[u.bedrooms," Beds"]}),e.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:s}}),e.jsxs("span",{children:[u.bathrooms," Baths"]}),e.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:s}}),e.jsxs("span",{children:[(y=u.sqft)==null?void 0:y.toLocaleString()," Sqft"]})]})})]},u.mlsNumber)})}),e.jsx("div",{className:"text-center mt-14",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-3 px-10 py-4 text-xs tracking-[0.3em] uppercase border border-white/20 text-white/70 hover:bg-white hover:text-black transition-all duration-500",children:["View All Properties ",e.jsx(ba,{className:"h-3.5 w-3.5"})]})})]})}):null}function SMs({siteId:t,accentColor:s}){return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(L3e,{siteId:t,accentColor:s})})}function CMs({siteConfig:t,accentColor:s,brandColor:r,config:n}){const a=ar(),o=t.agent;return o?e.jsx("section",{className:"py-0 bg-[#0d0b0a]",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 min-h-[80vh]",children:[o.avatar_url&&e.jsxs(gs.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{duration:.8},className:"relative overflow-hidden",children:[e.jsx("img",{src:o.avatar_url,alt:o.full_name,className:"w-full h-full object-cover min-h-[500px] lg:min-h-full"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent to-[#0d0b0a]/30 lg:block hidden"})]}),e.jsx(gs.div,{initial:{opacity:0,x:40},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8,delay:.2},className:"flex items-center px-8 lg:px-16 py-20",children:e.jsxs("div",{children:[e.jsx("div",{className:"w-16 h-0.5 mb-8",style:{backgroundColor:s}}),e.jsx("p",{className:"text-xs tracking-[0.4em] uppercase mb-4",style:{color:s},children:(n==null?void 0:n.sectionTitle)||"About"}),e.jsx("h2",{className:"text-4xl md:text-5xl text-white tracking-tight mb-3 leading-[1.1]",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.headline)||o.full_name}),e.jsx("p",{className:"text-white/40 font-light tracking-wider text-sm mb-8 uppercase",children:(n==null?void 0:n.customTitle)||o.title||"Real Estate Professional"}),e.jsx("p",{className:"text-white/60 leading-relaxed text-lg mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(()=>{const l=(n==null?void 0:n.customBio)||o.bio;return l?l.substring(0,500)+(l.length>500?"...":""):"Dedicated to providing an exceptional luxury real estate experience with deep local market expertise and unwavering commitment to client success."})()}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx("button",{onClick:()=>a("/contact"),className:"px-8 py-3.5 text-xs tracking-[0.3em] uppercase text-black transition-all duration-500 hover:opacity-90",style:{backgroundColor:s},children:"Get in Touch"}),e.jsx("button",{onClick:()=>a("/about"),className:"px-8 py-3.5 text-xs tracking-[0.3em] uppercase text-white/70 border border-white/20 hover:bg-white hover:text-black transition-all duration-500",children:"Read More"})]})]})})]})}):null}function MMs({testimonials:t,accentColor: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.jsxs("section",{className:"py-28 bg-[#0d0b0a] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),e.jsxs("div",{className:"max-w-4xl mx-auto px-6 text-center relative",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Testimonials"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight mb-16",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:r||"Success Stories"}),e.jsx("div",{className:"text-6xl leading-none mb-8",style:{color:s,fontFamily:"'Playfair Display', Georgia, serif"},children:'"'}),e.jsxs(gs.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5},children:[e.jsx("blockquote",{className:"text-xl md:text-2xl text-white/80 leading-relaxed mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:o[n].quote}),e.jsx("div",{className:"w-12 h-px mx-auto mb-6",style:{backgroundColor:s}}),e.jsx("p",{className:"text-white text-sm tracking-[0.2em] uppercase font-medium",children:o[n].name}),o[n].role&&e.jsx("p",{className:"text-white/30 text-xs tracking-[0.15em] uppercase mt-1",children:o[n].role})]},n),o.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-6 mt-14",children:[e.jsx("button",{onClick:()=>a((n-1+o.length)%o.length),className:"p-3 border border-white/10 hover:border-white/30 transition-colors",children:e.jsx(tl,{className:"h-4 w-4 text-white/50"})}),e.jsx("div",{className:"flex gap-3",children:o.map((l,i)=>e.jsx("button",{onClick:()=>a(i),className:"w-2 h-2 transition-all duration-300",style:{backgroundColor:i===n?s:"rgba(255,255,255,0.15)",width:i===n?"2rem":"0.5rem"}},i))}),e.jsx("button",{onClick:()=>a((n+1)%o.length),className:"p-3 border border-white/10 hover:border-white/30 transition-colors",children:e.jsx(da,{className:"h-4 w-4 text-white/50"})})]})]})]}):null}function TMs({agentName:t,accentColor:s,brandColor:r,config:n}){const a=ar();return e.jsx("section",{className:"py-28 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Work With Us"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.headline)||"Let's Get Started"}),e.jsx("p",{className:"text-white/40 text-lg max-w-2xl mx-auto",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(n==null?void 0:n.subtitle)||"We promise to guide you through a successful and enjoyable real estate experience."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-px bg-white/5",children:[{icon:xn,title:"Buy",desc:"Find your dream property with personalized search and expert guidance.",action:"/search"},{icon:ml,title:"Sell",desc:"Maximize your home's value with strategic marketing and pricing.",action:"/sell"},{icon:Bo,title:"Home Value",desc:"Discover what your property is worth in today's market.",action:"/contact"}].map((o,l)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:l*.15},onClick:()=>a(o.action),className:"bg-[#0d0b0a] p-12 text-center cursor-pointer group hover:bg-[#161312] transition-colors duration-500",children:[e.jsx(o.icon,{className:"h-8 w-8 mx-auto mb-6 text-white/20 group-hover:text-white/40 transition-colors",style:{color:s}}),e.jsx("h3",{className:"text-2xl text-white tracking-tight mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o.title}),e.jsx("p",{className:"text-white/40 text-sm leading-relaxed mb-6",children:o.desc}),e.jsx("div",{className:"w-8 h-px mx-auto opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:s}})]},o.title))})]})})}function AMs({accentColor:t,config:s}){const r=Array.from({length:6}).map((n,a)=>({url:s[`image_${a}`],caption:s[`caption_${a}`]})).filter(n=>n.url);return r.length||r.push({url:"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=800&q=75",caption:"Luxury Estates"},{url:"https://images.unsplash.com/photo-1540518614846-7eded433c457?w=800&q=75",caption:"Elegant Interiors"},{url:"https://images.unsplash.com/photo-1613490493576-7fde63acd811?w=800&q=75",caption:"Pool & Spa"},{url:"https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?w=800&q=75",caption:"Wine Country"},{url:"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=800&q=75",caption:"Gourmet Kitchen"},{url:"https://images.unsplash.com/photo-1512917774080-9991f1c4c750?w=800&q=75",caption:"Panoramic Views"}),e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Experience"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"The Luxury Lifestyle"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:r.map((n,a)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:a*.1},className:`relative group overflow-hidden ${a===0||a===3?"row-span-2 aspect-[3/4]":"aspect-square"}`,children:[e.jsx("img",{src:n.url,alt:n.caption||"",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-t from-black/60 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),n.caption&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4 translate-y-full group-hover:translate-y-0 transition-transform duration-500",children:e.jsx("p",{className:"text-white text-sm tracking-[0.2em] uppercase",children:n.caption})}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:t}})]},a))})]})})}function EMs({accentColor:t,config:s}){const r=[{label:"Median Home Price",value:"$485,000",change:"+4.2%",icon:ml},{label:"Average Days on Market",value:"28",change:"-12%",icon:Bo},{label:"Active Listings",value:"142",change:"+8",icon:xn},{label:"Sold This Month",value:"37",change:"+15%",icon:co}],a=(s.style||"dark")==="dark";return e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Insights"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"Market Pulse"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle}),s.marketArea&&e.jsx("p",{className:"text-white/30 mt-2 text-xs tracking-[0.3em] uppercase",children:s.marketArea})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:r.map((o,l)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:l*.1},className:"bg-[#161312] border border-white/5 p-8 text-center group hover:border-white/10 transition-colors duration-500",children:[e.jsx(o.icon,{className:"h-6 w-6 mx-auto mb-4 text-white/20",style:{color:t}}),e.jsx("p",{className:"text-3xl md:text-4xl font-bold text-white mb-2",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o.value}),e.jsx("p",{className:"text-white/40 text-xs tracking-[0.2em] uppercase mb-3",children:o.label}),e.jsx("span",{className:"text-xs px-3 py-1 rounded-full",style:{backgroundColor:`${t}20`,color:t},children:o.change})]},o.label))}),s.showChart!==!1&&e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:.4},className:"mt-8 bg-[#161312] border border-white/5 p-8",children:[e.jsx("p",{className:"text-white/30 text-xs tracking-[0.3em] uppercase mb-6",children:"12-Month Price Trend"}),e.jsx("div",{className:"flex items-end gap-2 h-32",children:[65,58,72,80,68,75,85,78,90,88,95,92].map((o,l)=>e.jsx("div",{className:"flex-1 rounded-t transition-all duration-500 hover:opacity-80",style:{height:`${o}%`,backgroundColor:l===11?t:`${t}40`}},l))}),e.jsx("div",{className:"flex justify-between mt-3 text-white/20 text-[10px] tracking-wider uppercase",children:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(o=>e.jsx("span",{children:o},o))})]})]})})}const PMs={default:sh,home:xn,camera:gf,truck:aT,search:sn,palette:$l,video:An};function IMs({accentColor:t,config:s}){const r=[{title:"Home Staging",desc:"Professional staging to showcase your property at its absolute best",icon:"home"},{title:"Interior Design",desc:"Connect with top designers for pre-sale or post-purchase renovations",icon:"palette"},{title:"Moving Coordination",desc:"Seamless relocation support from packing to settling in",icon:"truck"},{title:"Pre-Inspection",desc:"Comprehensive property inspections before listing or buying",icon:"search"},{title:"Photography",desc:"Cinematic photography and videography for your listing",icon:"camera"},{title:"Virtual Tours",desc:"3D walkthroughs and immersive virtual experiences",icon:"video"}],n=Array.from({length:6}).map((a,o)=>{var l,i,c;return{title:s[`service_title_${o}`]||((l=r[o])==null?void 0:l.title)||"",desc:s[`service_desc_${o}`]||((i=r[o])==null?void 0:i.desc)||"",icon:s[`service_icon_${o}`]||((c=r[o])==null?void 0:c.icon)||"default"}}).filter(a=>a.title);return n.length?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Excellence"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"Concierge Services"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map((a,o)=>{const l=PMs[a.icon]||sh;return e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:o*.1},className:"bg-[#161312] border border-white/5 p-10 group hover:border-white/10 transition-all duration-500",children:[e.jsx(l,{className:"h-8 w-8 mb-6 text-white/20 group-hover:text-white/40 transition-colors",style:{color:t}}),e.jsx("h3",{className:"text-xl text-white tracking-tight mb-3",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.title}),e.jsx("p",{className:"text-white/40 text-sm leading-relaxed",children:a.desc}),e.jsx("div",{className:"w-8 h-px mt-6 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:t}})]},o)})})]})}):null}const adt="/assets/land-ranch-hero-DPocQo93.jpg",LMs="/assets/land-ranch-type-ranch-BheMsKzQ.jpg",DMs="/assets/land-ranch-type-farm-cZzpYUqq.jpg",OMs="/assets/land-ranch-type-land-BCRXswKZ.jpg",RMs="/assets/land-ranch-type-equestrian-D0B3dJ3D.jpg",FMs="/assets/land-ranch-type-vineyard-CFy8-2Ud.jpg",H1="#2c1810",zMs="#b8860b",d_="#faf6f1",idt="#f5efe6";function BMs({siteConfig:t,themeConfig:s}){var m;const r=ar(),[n,a]=k.useState(""),o=((m=t.agent)==null?void 0:m.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ome,i=(s==null?void 0:s.brandColor)||H1,c=(s==null?void 0:s.accentColor)||zMs,u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{style:{backgroundColor:d_},children:l.map((f,g)=>{if(!f.enabled)return null;const y=f.config||{};switch(f.type){case"hero":return e.jsx(qMs,{agentName:o,tagline:y.headline||t.siteTagline,subtitle:y.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:y.searchPlaceholder,themeConfig:s},g);case"property_types":return e.jsx(VMs,{accentColor:c},g);case"featured_listings":return e.jsx(HMs,{siteConfig:t,accentColor:c,sectionTitle:y.sectionTitle,count:y.count},g);case"advantages":return e.jsx(WMs,{agentName:o,accentColor:c},g);case"featured_areas":return e.jsx("div",{className:"py-4",style:{backgroundColor:d_},children:e.jsx(L3e,{siteId:t.id,accentColor:c})},g);case"about":return e.jsx(KMs,{siteConfig:t,accentColor:c,brandColor:i,config:y},g);case"testimonials":return e.jsx(ZMs,{testimonials:y.testimonials||(s==null?void 0:s.testimonials)||[],accentColor:c,sectionTitle:y.sectionTitle},g);case"cta_banner":return e.jsx(YMs,{agentName:o,accentColor:c},g);case"new_listings":return e.jsx("div",{className:"py-4",style:{backgroundColor:d_},children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:y.sectionTitle,cities:y.cities,count:y.count})},g);case"open_houses":return e.jsx("div",{className:"py-4",style:{backgroundColor:d_},children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:y.sectionTitle,cities:y.cities,count:y.count})},g);case"my_listings":return e.jsx("div",{className:"py-4",style:{backgroundColor:d_},children:e.jsx(C1,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:y.sectionTitle,count:y.count})},g);case"city_pages":return e.jsx("div",{className:"py-4",style:{backgroundColor:d_},children:e.jsx(D3e,{siteId:t.id,accentColor:c,sectionTitle:y.sectionTitle})},g);case"land_use_guide":return e.jsx(XMs,{accentColor:c,config:y},g);case"land_valuation_cta":return e.jsx(JMs,{agentName:o,accentColor:c,config:y},g);case"acreage_showcase":return e.jsx(eTs,{siteConfig:t,accentColor:c,config:y},g);default:return null}})})}function $Ms(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 qMs({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:m}){const f=ar(),g=n||adt;return e.jsxs("section",{className:"relative h-screen flex items-center justify-center overflow-hidden",children:[e.jsx(gs.div,{className:"absolute inset-0",initial:{scale:1.1},animate:{scale:1},transition:{duration:20,ease:"linear"},children:e.jsx("img",{src:g,alt:"Ranch landscape",className:"w-full h-full object-cover",width:1920,height:1080})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/40 via-black/20 to-black/70"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1",style:{backgroundColor:o}}),e.jsxs("div",{className:"relative z-10 text-center px-4 max-w-4xl mx-auto",children:[e.jsxs(gs.div,{initial:{opacity:0,scaleX:0},animate:{opacity:1,scaleX:1},transition:{delay:.3,duration:.8},className:"flex items-center justify-center gap-4 mb-8",children:[e.jsx("div",{className:"h-px w-16",style:{backgroundColor:o}}),e.jsx(d1,{className:"w-6 h-6",style:{color:o}}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:o}})]}),e.jsx(gs.h1,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{delay:.5,duration:.8},className:"text-5xl md:text-7xl font-bold text-white mb-6 tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif",textShadow:"0 4px 20px rgba(0,0,0,0.4)"},children:s||"Where Land Meets Legacy"}),e.jsx(gs.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.7,duration:.8},className:"text-lg md:text-xl text-white/90 mb-10 max-w-2xl mx-auto leading-relaxed",style:{fontFamily:"'Lora', Georgia, serif"},children:r||"Discover extraordinary ranch, farm, and land properties. Connect with a specialist who understands the lifestyle behind every acre."}),e.jsx(gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.9,duration:.6},className:"max-w-xl mx-auto",children:e.jsxs("form",{onSubmit:c,className:"relative",children:[e.jsx(Fme,{value:l,onChange:i,placeholder:u||"Search by city, county, or zip code...",suggestions:$Ms(m),onSelect:y=>{f(`/search?q=${encodeURIComponent(y)}`)},className:"w-full",inputClassName:"w-full h-14 pl-14 pr-6 rounded-full bg-white/95 backdrop-blur-sm text-gray-900 text-lg shadow-2xl border-2 border-transparent focus:border-amber-600/50 focus:outline-none transition-all placeholder:text-gray-400"}),e.jsx(sn,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"})]})}),e.jsx(gs.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.5},className:"absolute bottom-12 left-1/2 -translate-x-1/2",children:e.jsx(gs.div,{animate:{y:[0,8,0]},transition:{repeat:1/0,duration:2},className:"w-10 h-10 rounded-full border-2 border-white/50 flex items-center justify-center cursor-pointer",onClick:()=>window.scrollBy({top:window.innerHeight,behavior:"smooth"}),children:e.jsx(Ji,{className:"w-5 h-5 text-white/80"})})})]})]})}const UMs=[{label:"Ranch",image:LMs,searchParam:"ranch"},{label:"Farm",image:DMs,searchParam:"farm"},{label:"Land",image:OMs,searchParam:"land"},{label:"Equestrian",image:RMs,searchParam:"horse"},{label:"Vineyard",image:FMs,searchParam:"vineyard"}];function VMs({accentColor:t}){const s=k.useRef(null),r=E3(s,{once:!0,margin:"-100px"}),n=ar();return e.jsx("section",{ref:s,className:"py-20 px-4",style:{backgroundColor:idt},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:r?{opacity:1,y:0}:{},transition:{duration:.6},className:"text-center mb-14",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:t}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:t},children:"Explore"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:t}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",style:{color:H1,fontFamily:"'Playfair Display', Georgia, serif"},children:"Property Types"}),e.jsx("p",{className:"text-gray-600 max-w-2xl mx-auto",style:{fontFamily:"'Lora', Georgia, serif"},children:"Discover extraordinary properties across various categories that match your lifestyle and investment goals."})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:UMs.map((a,o)=>e.jsxs(gs.div,{initial:{opacity:0,y:30},animate:r?{opacity:1,y:0}:{},transition:{delay:o*.1,duration:.5},onClick:()=>n(`/search?q=${a.searchParam}`),className:"group cursor-pointer relative aspect-[3/4] rounded-2xl overflow-hidden shadow-lg hover:shadow-2xl transition-all duration-500",children:[e.jsx("img",{src:a.image,alt:a.label,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy",width:800,height:1024}),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-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.label}),e.jsx("div",{className:"h-0.5 w-0 group-hover:w-full transition-all duration-500 mt-2 rounded-full",style:{backgroundColor:t}})]})]},a.label))})]})})}function HMs({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=ar(),o=k.useRef(null),l=E3(o,{once:!0,margin:"-100px"}),[i,c]=k.useState([]);return k.useEffect(()=>{(async()=>{try{const{data:m}=await H.functions.invoke("fetch-mls-listings",{body:{siteId:t.id,mode:"featured",count:n||6}});m!=null&&m.listings&&c(m.listings)}catch{}})()},[t.id,n]),i.length?e.jsx("section",{ref:o,className:"py-20 px-4",style:{backgroundColor:d_},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:l?{opacity:1,y:0}:{},className:"text-center mb-12",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Featured"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:H1,fontFamily:"'Playfair Display', Georgia, serif"},children:r||"Featured Properties"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:i.slice(0,n||6).map((u,m)=>{var f,g;return e.jsxs(gs.div,{initial:{opacity:0,y:30},animate:l?{opacity:1,y:0}:{},transition:{delay:m*.1},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group cursor-pointer bg-white rounded-2xl overflow-hidden shadow-md hover:shadow-xl transition-all duration-300",children:[e.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[e.jsx("img",{src:((f=u.photos)==null?void 0:f[0])||adt,alt:u.address,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",loading:"lazy"}),u.lotSize&&e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-white text-xs font-semibold backdrop-blur-sm",style:{backgroundColor:`${s}dd`},children:u.lotSize})]}),e.jsxs("div",{className:"p-5",children:[e.jsx("div",{className:"flex items-start justify-between mb-2",children:e.jsx("h3",{className:"text-lg font-bold line-clamp-1",style:{color:H1,fontFamily:"'Playfair Display', Georgia, serif"},children:u.address})}),e.jsxs("p",{className:"text-gray-500 text-sm flex items-center gap-1 mb-3",children:[e.jsx(aa,{className:"w-3.5 h-3.5"}),u.city,u.state?`, ${u.state}`:""]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xl font-bold",style:{color:s},children:["$",(g=u.price)==null?void 0:g.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-400 flex items-center gap-1 group-hover:gap-2 transition-all",children:["View Details ",e.jsx(ba,{className:"w-3.5 h-3.5"})]})]})]})]},u.mlsNumber)})}),e.jsx(gs.div,{initial:{opacity:0},animate:l?{opacity:1}:{},transition:{delay:.5},className:"text-center mt-10",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-2 px-8 py-3.5 rounded-full text-white font-semibold tracking-wide hover:shadow-lg transition-all duration-300 hover:scale-105",style:{backgroundColor:s},children:["View All Properties ",e.jsx(ba,{className:"w-4 h-4"})]})})]})}):null}const GMs=[{icon:aa,title:"Local Expertise",desc:"Deep knowledge of local land values, zoning regulations, and rural market dynamics."},{icon:ur,title:"Personal Touch",desc:"One-on-one guidance through every step of buying or selling specialized properties."},{icon:d1,title:"Smarter Technology",desc:"Innovative tools providing enhanced visibility and exposure for your property."},{icon:ou,title:"Trusted Network",desc:"Access to a curated network of qualified buyers, lenders, and industry professionals."}];function WMs({agentName:t,accentColor:s}){const r=k.useRef(null),n=E3(r,{once:!0,margin:"-100px"});return e.jsx("section",{ref:r,className:"py-20 px-4",style:{backgroundColor:H1},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:n?{opacity:1,y:0}:{},className:"text-center mb-14",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Why Choose Us"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["The ",t," Advantage"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:GMs.map((a,o)=>{const l=a.icon;return e.jsxs(gs.div,{initial:{opacity:0,y:30},animate:n?{opacity:1,y:0}:{},transition:{delay:o*.15},className:"group p-6 rounded-2xl border border-white/10 hover:border-white/25 bg-white/5 backdrop-blur-sm transition-all duration-300 hover:bg-white/10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${s}22`},children:e.jsx(l,{className:"w-7 h-7",style:{color:s}})}),e.jsx("h3",{className:"text-lg font-bold text-white mb-2 tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.title}),e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",style:{fontFamily:"'Lora', Georgia, serif"},children:a.desc})]},a.title)})})]})})}function KMs({siteConfig:t,accentColor:s,brandColor:r,config:n}){var u,m,f;const a=k.useRef(null),o=E3(a,{once:!0,margin:"-100px"}),l=((u=t.agent)==null?void 0:u.full_name)||"Your Agent",i=(m=t.agent)==null?void 0:m.avatar_url,c=((f=t.agent)==null?void 0:f.bio)||"";return e.jsx("section",{ref:a,className:"py-20 px-4",style:{backgroundColor:idt},children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-12 items-center",children:[i&&e.jsxs(gs.div,{initial:{opacity:0,x:-30},animate:o?{opacity:1,x:0}:{},transition:{duration:.7},className:"relative",children:[e.jsx("div",{className:"absolute -inset-3 rounded-2xl border-2 opacity-30",style:{borderColor:s}}),e.jsx("img",{src:i,alt:l,className:"w-full aspect-[3/4] object-cover rounded-2xl shadow-xl",loading:"lazy"})]}),e.jsxs(gs.div,{initial:{opacity:0,x:30},animate:o?{opacity:1,x:0}:{},transition:{duration:.7,delay:.2},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Your Specialist"})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",style:{color:H1,fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.sectionTitle)||`Meet ${l}`}),e.jsx("p",{className:"text-gray-600 leading-relaxed mb-8 text-base",style:{fontFamily:"'Lora', Georgia, serif"},children:c||`With deep expertise in rural and specialty properties, ${l} guides clients through every step of acquiring or selling their dream land, ranch, or farm property.`}),e.jsxs("button",{onClick:()=>window.location.href="/about",className:"inline-flex items-center gap-2 px-6 py-3 rounded-full text-white font-semibold tracking-wide hover:shadow-lg transition-all duration-300",style:{backgroundColor:s},children:["Learn More ",e.jsx(ba,{className:"w-4 h-4"})]})]})]})})})}function ZMs({testimonials:t,accentColor:s,sectionTitle:r}){const n=k.useRef(null),a=E3(n,{once:!0,margin:"-100px"}),[o,l]=k.useState(0);return t.length?e.jsx("section",{ref:n,className:"py-20 px-4",style:{backgroundColor:d_},children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:a?{opacity:1,y:0}:{},className:"mb-12",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Testimonials"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:H1,fontFamily:"'Playfair Display', Georgia, serif"},children:r||"What Our Clients Say"})]}),e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:a?{opacity:1,y:0}:{},transition:{delay:.2},className:"relative",children:[e.jsx(g1,{className:"w-12 h-12 mx-auto mb-6 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-xl md:text-2xl italic leading-relaxed mb-8 text-gray-700",style:{fontFamily:"'Lora', Georgia, serif"},children:['"',t[o].quote,'"']}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("div",{className:"h-px w-8",style:{backgroundColor:s}}),e.jsx("span",{className:"font-semibold",style:{color:H1},children:t[o].name}),t[o].role&&e.jsxs("span",{className:"text-gray-400 text-sm",children:["— ",t[o].role]}),e.jsx("div",{className:"h-px w-8",style:{backgroundColor:s}})]}),t.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-8",children:[e.jsx("button",{onClick:()=>l(i=>(i-1+t.length)%t.length),className:"w-10 h-10 rounded-full border-2 flex items-center justify-center hover:bg-white transition-colors",style:{borderColor:s,color:s},children:e.jsx(tl,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex gap-2",children:t.map((i,c)=>e.jsx("button",{onClick:()=>l(c),className:"w-2.5 h-2.5 rounded-full transition-all duration-300",style:{backgroundColor:c===o?s:"#d4c5b0",transform:c===o?"scale(1.3)":"scale(1)"}},c))}),e.jsx("button",{onClick:()=>l(i=>(i+1)%t.length),className:"w-10 h-10 rounded-full border-2 flex items-center justify-center hover:bg-white transition-colors",style:{borderColor:s,color:s},children:e.jsx(da,{className:"w-5 h-5"})})]})]})]})}):null}function YMs({agentName:t,accentColor:s}){const r=k.useRef(null),n=E3(r,{once:!0,margin:"-100px"});return e.jsxs("section",{ref:r,className:"relative py-24 px-4 overflow-hidden",style:{backgroundColor:H1},children:[e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),e.jsxs(gs.div,{ref:r,initial:{opacity:0,y:20},animate:n?{opacity:1,y:0}:{},className:"relative z-10 max-w-3xl mx-auto text-center",children:[e.jsx(d1,{className:"w-10 h-10 mx-auto mb-6",style:{color:s}}),e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["Ready to Find Your",e.jsx("br",{}),"Dream Property?"]}),e.jsx("p",{className:"text-white/80 text-lg mb-10 max-w-xl mx-auto",style:{fontFamily:"'Lora', Georgia, serif"},children:"Whether you're searching for a working ranch, farmland, or a quiet piece of country to call home — let's make it happen."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/search",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-white font-semibold tracking-wide hover:shadow-xl transition-all duration-300 hover:scale-105",style:{backgroundColor:s},children:["Search Properties ",e.jsx(ba,{className:"w-4 h-4"})]}),e.jsxs("a",{href:"/contact",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full border-2 text-white font-semibold tracking-wide hover:bg-white/10 transition-all duration-300",style:{borderColor:s},children:["Contact ",t.split(" ")[0]]})]})]})]})}const QMs="#f5f0eb";function XMs({accentColor:t,config:s}){const r=ar(),n=[{name:"Agriculture",desc:"Fertile farmland for crops, orchards, and agricultural operations",image:"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=600&q=75",link:"/search?type=farm"},{name:"Hunting & Recreation",desc:"Private retreats for hunting, fishing, and outdoor recreation",image:"https://images.unsplash.com/photo-1511497584788-876760111969?w=600&q=75",link:"/search"},{name:"Equestrian",desc:"Horse-ready properties with pastures, barns, and riding facilities",image:"https://images.unsplash.com/photo-1553284965-83fd3e82fa5a?w=600&q=75",link:"/search"},{name:"Homesteading",desc:"Self-sufficient living with space for gardens and livestock",image:"https://images.unsplash.com/photo-1500076656116-558758c991c1?w=600&q=75",link:"/search"},{name:"Development",desc:"Prime parcels for residential or commercial development",image:"https://images.unsplash.com/photo-1501854140801-50d01698950b?w=600&q=75",link:"/search"},{name:"Timber",desc:"Managed timberland with sustainable harvesting potential",image:"https://images.unsplash.com/photo-1448375240586-882707db888b?w=600&q=75",link:"/search"}],a=Array.from({length:6}).map((o,l)=>{var i,c,u,m;return{name:s[`category_name_${l}`]||((i=n[l])==null?void 0:i.name)||"",desc:s[`category_desc_${l}`]||((c=n[l])==null?void 0:c.desc)||"",image:s[`category_image_${l}`]||((u=n[l])==null?void 0:u.image)||"",link:s[`category_link_${l}`]||((m=n[l])==null?void 0:m.link)||"/search"}}).filter(o=>o.name);return a.length?e.jsx("section",{className:"py-20",style:{backgroundColor:QMs},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("p",{className:"text-xs tracking-[0.4em] uppercase mb-3 font-semibold",style:{color:t},children:[e.jsx(S0,{className:"inline h-4 w-4 mr-2"}),"Explore By Use"]}),e.jsx("h2",{className:"text-3xl md:text-5xl tracking-tight",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif",color:"#2c1810"},children:s.sectionTitle||"Find Your Perfect Property"}),s.subtitle&&e.jsx("p",{className:"text-[#5c4a3a] mt-3 text-lg",children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5",children:a.map((o,l)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:l*.1},onClick:()=>r(o.link),className:"relative group cursor-pointer overflow-hidden rounded-xl aspect-[4/3]",children:[e.jsx("img",{src:o.image,alt:o.name,className:"w-full h-full object-cover group-hover:scale-110 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-6",children:[e.jsx("h3",{className:"text-xl font-bold text-white mb-1",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:o.name}),e.jsx("p",{className:"text-white/70 text-sm",children:o.desc})]}),e.jsx("div",{className:"absolute top-4 right-4 w-10 h-10 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{backgroundColor:t},children:e.jsx(ba,{className:"h-4 w-4 text-white"})})]},l))})]})}):null}function JMs({agentName:t,accentColor:s,config:r}){const n=ar(),a=r.bgImage||"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1920&q=75";return e.jsxs("section",{className:"relative py-28 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:a,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-[#2c1810]/80"})]}),e.jsx("div",{className:"relative z-10 max-w-3xl mx-auto px-6 text-center",children:e.jsxs(gs.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.7},children:[e.jsx(ml,{className:"h-12 w-12 mx-auto mb-6",style:{color:s}}),e.jsx("h2",{className:"text-4xl md:text-6xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:r.headline||"What's Your Land Worth?"}),e.jsx("p",{className:"text-white/70 text-lg md:text-xl leading-relaxed mb-10 max-w-xl mx-auto",children:r.subtitle||`Get a free, no-obligation land valuation from ${t} — a local expert who knows the market inside and out.`}),e.jsx("button",{onClick:()=>n(r.buttonLink||"/contact"),className:"px-10 py-4 text-sm font-bold tracking-[0.2em] uppercase text-white rounded-lg transition-all duration-300 hover:opacity-90 hover:scale-105",style:{backgroundColor:s},children:r.buttonText||"Get My Free Valuation"})]})})]})}function eTs({siteConfig:t,accentColor:s,config:r}){const n=ar(),[a,o]=k.useState([]),[l,i]=k.useState(!0);return k.useEffect(()=>{(async()=>{var u;try{const f=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,pageSize:r.count||6,page:1,minAcres:r.minAcres?Number(r.minAcres):5})});if(f.ok){const g=await f.json();o(((u=g.listings)==null?void 0:u.slice(0,r.count||6))||[])}}catch{}finally{i(!1)}})()},[t.id,r.count,r.minAcres]),l?e.jsx("section",{className:"py-20",style:{backgroundColor:"#f5f0eb"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsx("div",{className:"h-8 bg-[#2c1810]/10 rounded w-64 mx-auto mb-12 animate-pulse"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[1,2,3,4].map(c=>e.jsx("div",{className:"h-72 bg-[#2c1810]/5 rounded-xl animate-pulse"},c))})]})}):a.length?e.jsx("section",{className:"py-20",style:{backgroundColor:"#f5f0eb"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("p",{className:"text-xs tracking-[0.4em] uppercase mb-3 font-semibold",style:{color:s},children:[e.jsx(DL,{className:"inline h-4 w-4 mr-2"}),"Expansive Properties"]}),e.jsx("h2",{className:"text-3xl md:text-5xl tracking-tight",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif",color:"#2c1810"},children:r.sectionTitle||"Featured Acreage"}),r.subtitle&&e.jsx("p",{className:"text-[#5c4a3a] mt-3 text-lg",children:r.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:a.map((c,u)=>{var m,f;return e.jsxs(gs.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:u*.1},onClick:()=>n(`/listing/${c.mlsNumber}`),className:"group cursor-pointer rounded-xl overflow-hidden bg-white shadow-md hover:shadow-xl transition-shadow duration-300",children:[e.jsxs("div",{className:"relative aspect-[16/9] overflow-hidden",children:[e.jsx("img",{src:((m=c.photos)==null?void 0:m[0])||"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=800&q=75",alt:c.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),c.acres&&e.jsxs("div",{className:"absolute top-4 left-4 px-3 py-1.5 rounded-full text-xs font-bold text-white",style:{backgroundColor:s},children:[c.acres," Acres"]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",style:{color:"#2c1810",fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:["$",(f=c.price)==null?void 0:f.toLocaleString()]}),r.showPricePerAcre!==!1&&c.acres&&c.price&&e.jsxs("p",{className:"text-sm",style:{color:s},children:["$",Math.round(c.price/c.acres).toLocaleString(),"/acre"]})]}),e.jsx(ba,{className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity text-[#5c4a3a]"})]}),e.jsx("p",{className:"text-[#5c4a3a] text-sm",children:c.address}),e.jsxs("p",{className:"text-[#8a7a6a] text-xs",children:[c.city,", ",c.state]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-xs text-[#8a7a6a]",children:[c.bedrooms>0&&e.jsxs("span",{children:[c.bedrooms," Beds"]}),c.bathrooms>0&&e.jsxs("span",{children:[c.bathrooms," Baths"]}),c.sqft&&e.jsxs("span",{children:[c.sqft.toLocaleString()," Sqft"]})]})]})]},c.mlsNumber)})})]})}):null}const tTs=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${t}`,k9=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},sTs=t=>[t.address,t.city,t.state,t.zip].filter(Boolean).join(", ");function O3e({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),[m,f]=k.useState({});k.useEffect(()=>{(async()=>{const{data:w}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&u(w.value)})()},[]),k.useEffect(()=>{if(!(!n.current||!c||a.current))return Io.accessToken=c,a.current=new Io.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",zoom:4,center:[-98.5795,39.8283]}),a.current.addControl(new Io.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[c]);const g=k.useMemo(()=>t.map(_=>{var N,S;const w=k9(_.latitude)??((N=m[_.mlsNumber])==null?void 0:N.lat)??null,j=k9(_.longitude)??((S=m[_.mlsNumber])==null?void 0:S.lng)??null;return w===null||j===null?null:{listing:_,latitude:w,longitude:j}}).filter(_=>_!==null),[t,m]);k.useEffect(()=>{if(!c||t.length===0)return;const _=t.filter(N=>!(k9(N.latitude)!==null&&k9(N.longitude)!==null)&&!i.current.has(N.mlsNumber));if(_.length===0)return;let w=!1;return(async()=>{const N=await Promise.all(_.map(async M=>{var P,O;const I=sTs(M);if(!I)return{mlsNumber:M.mlsNumber,coords:null};try{const q=await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(I)}.json?access_token=${encodeURIComponent(c)}&limit=1&country=US&types=address,place,postcode`);if(!q.ok)return{mlsNumber:M.mlsNumber,coords:null};const $=await q.json(),[z,V]=((O=(P=$==null?void 0:$.features)==null?void 0:P[0])==null?void 0:O.center)??[];return!Number.isFinite(V)||!Number.isFinite(z)?{mlsNumber:M.mlsNumber,coords:null}:{mlsNumber:M.mlsNumber,coords:{lat:V,lng:z}}}catch{return{mlsNumber:M.mlsNumber,coords:null}}}));if(w)return;const S={};N.forEach(({mlsNumber:M,coords:I})=>{i.current.set(M,I),I&&(S[M]=I)}),Object.keys(S).length>0&&f(M=>({...M,...S}))})(),()=>{w=!0}},[t,c]);const y=k.useCallback(_=>{var N;const w=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_.price),j=(N=_.photos)!=null&&N[0]?``:`
`;return`
${j}
${w}
${_.address}
${_.bedrooms} bd ${_.bathrooms} ba ${_.sqft>0?`${_.sqft.toLocaleString()} sqft`:""}
`},[]);return k.useEffect(()=>{if(!a.current||!c||(o.current.forEach(w=>w.remove()),o.current.clear(),g.length===0))return;const _=new Io.LngLatBounds;g.forEach(({listing:w,latitude:j,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",w.mlsNumber),M.innerHTML=`${tTs(w.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!==w.mlsNumber&&(M.style.background="white",M.style.color="#1e3a5f",M.style.transform="scale(1)")}),S.appendChild(M);const I=new Io.Marker({element:S,anchor:"bottom"}).setLngLat([N,j]).addTo(a.current);S.addEventListener("click",P=>{var q;P.stopPropagation(),(q=l.current)==null||q.remove();const O=new Io.Popup({offset:25,closeButton:!0,maxWidth:"240px",className:"lead-site-map-popup"}).setLngLat([N,j]).setHTML(y(w)).addTo(a.current);setTimeout(()=>{const $=O.getElement(),z=$==null?void 0:$.querySelector("[data-mls]");z&&(z.addEventListener("click",()=>{s(w.mlsNumber)}),z.style.cursor="pointer")},50),l.current=O}),o.current.set(w.mlsNumber,I),_.extend([N,j])});try{_.isEmpty()||a.current.fitBounds(_,{padding:60,maxZoom:14})}catch{}},[g,c,y,s]),k.useEffect(()=>{o.current.forEach((_,w)=>{const j=_.getElement().querySelector(".lead-site-map-pill");j&&(w===r?(j.style.background="#2563eb",j.style.color="white",j.style.transform="scale(1.15)",j.style.zIndex="10"):(j.style.background="white",j.style.color="#1e3a5f",j.style.transform="scale(1)",j.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(rTs,{className:"h-10 w-10 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Map not configured"})]})})}function rTs({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 nTs=50;function aTs({siteConfig:t}){var ue;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(ge=>({label:ge,type:"city"})),...(s.searchZipCodes||[]).map(ge=>({label:ge,type:"zip"})),...(s.searchCounties||[]).map(ge=>({label:ge,type:"county"}))],n=ar(),[a,o]=Ul(),[l,i]=k.useState(!1),[c,u]=k.useState("list"),[m,f]=k.useState(null),g=a.get("q")||"",y=a.get("county")||"",_=a.get("minPrice")||"",w=a.get("maxPrice")||"",j=a.get("beds")||"",N=a.get("baths")||"",S=a.get("propertyType")||"",M=a.get("minSqft")||"",I=a.get("maxSqft")||"",[P,O]=k.useState(g),[q,$]=k.useState(!0),{data:z,isLoading:V,fetchNextPage:X,hasNextPage:Y,isFetchingNextPage:J}=W2e({queryKey:["lead-site-search",t.id,g,y,_,w,j,N,S,M,I,q],queryFn:async({pageParam:ge=1})=>{const{data:_e,error:Be}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:g||void 0,county:y||void 0,minPrice:_?parseInt(_):void 0,maxPrice:w?parseInt(w):void 0,minBeds:j?parseInt(j):void 0,minBaths:N?parseInt(N):void 0,propertyType:S||void 0,minSqft:M?parseInt(M):void 0,maxSqft:I?parseInt(I):void 0,limit:nTs,page:ge}});if(Be)throw Be;return _e},getNextPageParam:(ge,_e)=>{if(_e.reduce((Se,Ee)=>Se+Ee.listings.length,0)ge.listings))??[],ce=((ue=z==null?void 0:z.pages[0])==null?void 0:ue.total)??0,ne=k.useCallback(ge=>{ge.preventDefault();const _e=new URLSearchParams;P&&_e.set("q",P),y&&_e.set("county",y),_&&_e.set("minPrice",_),w&&_e.set("maxPrice",w),j&&_e.set("beds",j),N&&_e.set("baths",N),S&&_e.set("propertyType",S),M&&_e.set("minSqft",M),I&&_e.set("maxSqft",I),o(_e),$(!0)},[P,y,_,w,j,N,S,M,I,o]),re=k.useCallback((ge,_e)=>{const Be=new URLSearchParams(a);_e?Be.set(ge,_e):Be.delete(ge),o(Be),$(!0)},[a,o]),oe=ge=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ge),he=k.useCallback(ge=>{n(`/listing/${ge}`)},[n]),xe=Q.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:ne,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{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(Fme,{suggestions:r,value:P,onChange:O,onSelect:ge=>{O(ge);const _e=new URLSearchParams(a);_e.set("q",ge),o(_e),$(!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:P,onChange:ge=>O(ge.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(v1,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:y,onChange:ge=>re("county",ge.target.value),placeholder:"County",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[140px]"}),e.jsxs("select",{value:j,onChange:ge=>re("beds",ge.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:ge=>re("baths",ge.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:ge=>re("propertyType",ge.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:ge=>re("minPrice",ge.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:w,onChange:ge=>re("maxPrice",ge.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:ge=>re("minSqft",ge.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:I,onChange:ge=>re("maxSqft",ge.target.value),placeholder:"Max sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"})]}),xe&&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(nh,{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(y0,{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..."})]})}):xe?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"," · ",ce," listing",ce!==1?"s":""," found"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Showing ",Q.length," of ",ce]})]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:Q.map(ge=>{var _e;return e.jsxs("button",{onClick:()=>n(`/listing/${ge.mlsNumber}`),onMouseEnter:()=>f(ge.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 ${m===ge.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=ge.photos)!=null&&_e[0]?e.jsx("img",{src:ge.photos[0],alt:ge.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:Be=>{const Se=Be.target;Se.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:e.jsx(aa,{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:ge.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:oe(ge.price)}),e.jsxs("p",{className:"text-xs text-white/90 mt-0.5 truncate drop-shadow-sm",children:[ge.address,", ",ge.city,", ",ge.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(Th,{className:"h-3.5 w-3.5"})," ",ge.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(au,{className:"h-3.5 w-3.5"})," ",ge.bathrooms," ba"]}),ge.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ix,{className:"h-3.5 w-3.5"})," ",ge.sqft.toLocaleString()," sqft"]})]})]},ge.mlsNumber)})}),Y&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>X(),disabled:J,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:J?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More Listings (${Q.length} of ${ce})`})})]}),e.jsx("div",{className:` lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"} `,children:e.jsx(O3e,{listings:Q,onListingClick:he,hoveredMlsNumber:m})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Er,{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(sn,{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 iTs=50;function oTs({siteConfig:t}){var Ee;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(Ae=>({label:Ae,type:"city"})),...(s.searchZipCodes||[]).map(Ae=>({label:Ae,type:"zip"})),...(s.searchCounties||[]).map(Ae=>({label:Ae,type:"county"}))],n=ar(),[a,o]=Ul(),[l,i]=k.useState(!1),[c,u]=k.useState("list"),[m,f]=k.useState(null),g="#c9a96e",y=a.get("q")||"",_=a.get("county")||"",w=a.get("minPrice")||"",j=a.get("maxPrice")||"",N=a.get("beds")||"",S=a.get("baths")||"",M=a.get("propertyType")||"",I=a.get("minSqft")||"",P=a.get("maxSqft")||"",[O,q]=k.useState(y),[$,z]=k.useState(!0),V=!!(_||w||j||N||S||M||I||P),{data:X,isLoading:Y,fetchNextPage:J,hasNextPage:Q,isFetchingNextPage:ce}=W2e({queryKey:["lead-site-search",t.id,y,_,w,j,N,S,M,I,P,$],queryFn:async({pageParam:Ae=1})=>{const Me={leadSiteId:t.id,query:y||void 0,county:_||void 0,minPrice:w?parseInt(w):void 0,maxPrice:j?parseInt(j):void 0,minBeds:N?parseInt(N):void 0,minBaths:S?parseInt(S):void 0,propertyType:M||void 0,minSqft:I?parseInt(I):void 0,maxSqft:P?parseInt(P):void 0,limit:iTs,page:Ae},ke=async qe=>{const{data:ve,error:dt}=await H.functions.invoke("lead-site-search",{body:qe});if(dt)throw dt;return ve},Oe=await ke(Me);if(y&&!V&&Oe.listings.length===0){const qe={...Me,query:void 0};return{...await ke(qe),fallbackQuery:y}}return Oe},getNextPageParam:(Ae,Me)=>{if(Me.reduce((Oe,qe)=>Oe+qe.listings.length,0)Ae.listings))??[],re=((Ee=X==null?void 0:X.pages[0])==null?void 0:Ee.total)??0,oe=X!=null&&X.pages[0]&&"fallbackQuery"in X.pages[0]?X.pages[0].fallbackQuery:void 0,he=k.useCallback(Ae=>{Ae.preventDefault();const Me=new URLSearchParams;O&&Me.set("q",O),_&&Me.set("county",_),w&&Me.set("minPrice",w),j&&Me.set("maxPrice",j),N&&Me.set("beds",N),S&&Me.set("baths",S),M&&Me.set("propertyType",M),I&&Me.set("minSqft",I),P&&Me.set("maxSqft",P),o(Me),z(!0)},[O,_,w,j,N,S,M,I,P,o]),xe=k.useCallback((Ae,Me)=>{const ke=new URLSearchParams(a);Me?ke.set(Ae,Me):ke.delete(Ae),o(ke),z(!0)},[a,o]),ue=Ae=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ae),ge=k.useCallback(Ae=>{n(`/listing/${Ae}`)},[n]),_e=ne.length>0,Be="bg-transparent border border-white/15 text-white px-3 py-2.5 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/30",Se="bg-[#161312] border border-white/15 text-white/70 px-3 py-2.5 text-sm focus:outline-none focus:border-white/40 transition-colors";return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 bg-[#0d0b0a]",children:[e.jsx("div",{className:"bg-[#0d0b0a] border-b border-white/10 z-40 shrink-0",children:e.jsxs("div",{className:"px-4 sm:px-6 py-3",children:[e.jsxs("form",{onSubmit:he,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/30 z-10"}),r.length>0?e.jsx(Fme,{suggestions:r,value:O,onChange:q,onSelect:Ae=>{q(Ae);const Me=new URLSearchParams(a);Me.set("q",Ae),o(Me),z(!0)},placeholder:"City, zip, county, or address...",inputClassName:`w-full pl-10 pr-4 ${Be}`}):e.jsx("input",{type:"text",value:O,onChange:Ae=>q(Ae.target.value),placeholder:"City, zip, county, or address...",className:`w-full pl-10 pr-4 ${Be}`})]}),e.jsx("button",{type:"submit",className:"px-5 py-2.5 text-xs tracking-[0.2em] uppercase text-black font-medium transition-all hover:opacity-90",style:{backgroundColor:g},children:"Search"}),e.jsx("button",{type:"button",onClick:()=>i(!l),className:`px-3 py-2.5 border text-sm transition-colors ${l?"border-white/30 text-white":"border-white/15 text-white/40 hover:text-white/70"}`,children:e.jsx(v1,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:_,onChange:Ae=>xe("county",Ae.target.value),placeholder:"County",className:`min-w-[140px] ${Be}`}),e.jsxs("select",{value:N,onChange:Ae=>xe("beds",Ae.target.value),className:Se,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:S,onChange:Ae=>xe("baths",Ae.target.value),className:Se,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:M,onChange:Ae=>xe("propertyType",Ae.target.value),className:`min-w-[160px] ${Se}`,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.jsxs("select",{value:w,onChange:Ae=>xe("minPrice",Ae.target.value),className:Se,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:Ae=>xe("maxPrice",Ae.target.value),className:Se,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:I,onChange:Ae=>xe("minSqft",Ae.target.value),placeholder:"Min sqft",className:`w-[120px] ${Be}`}),e.jsx("input",{type:"number",value:P,onChange:Ae=>xe("maxSqft",Ae.target.value),placeholder:"Max sqft",className:`w-[120px] ${Be}`})]}),_e&&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 transition-colors ${c==="list"?"text-black":"text-white/40 border border-white/15"}`,style:c==="list"?{backgroundColor:g}:{},children:[e.jsx(nh,{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 transition-colors ${c==="map"?"text-black":"text-white/40 border border-white/15"}`,style:c==="map"?{backgroundColor:g}:{},children:[e.jsx(y0,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:$?Y?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-2 border-white/20 mx-auto mb-4",style:{borderTopColor:g}}),e.jsx("p",{className:"text-white/30",children:"Searching listings..."})]})}):_e?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:`w-full lg:w-[65%] overflow-y-auto border-r border-white/5 bg-[#0d0b0a] shrink-0 ${c==="map"?"hidden lg:block":"block"}`,children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-white/70",children:[oe?"All Active Listings":y?`${y} Real Estate`:"All Listings"," · ",re," listing",re!==1?"s":""]}),e.jsxs("p",{className:"text-xs text-white/30",children:["Showing ",ne.length," of ",re]})]}),oe&&e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 text-xs text-white/45",children:["No exact matches for “",oe,"” in this demo feed, so showing all available listings instead."]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:ne.map(Ae=>{var Me;return e.jsxs("button",{onClick:()=>n(`/listing/${Ae.mlsNumber}`),onMouseEnter:()=>f(Ae.mlsNumber),onMouseLeave:()=>f(null),className:`w-full bg-[#161312] border overflow-hidden hover:border-white/20 transition-all text-left group flex flex-col ${m===Ae.mlsNumber?"border-white/30":"border-white/5"}`,children:[e.jsxs("div",{className:"relative w-full aspect-[4/3] bg-[#1a1715] overflow-hidden",children:[(Me=Ae.photos)!=null&&Me[0]?e.jsx("img",{src:Ae.photos[0],alt:Ae.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",onError:ke=>{ke.target.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/10",children:e.jsx(aa,{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 text-[10px] tracking-wider uppercase text-white/80",style:{backgroundColor:`${g}cc`},children:Ae.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",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:ue(Ae.price)}),e.jsxs("p",{className:"text-xs text-white/70 mt-0.5 truncate",children:[Ae.address,", ",Ae.city,", ",Ae.state]})]})]}),e.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-4 text-xs text-white/30 tracking-wider uppercase border-t border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Th,{className:"h-3.5 w-3.5"})," ",Ae.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(au,{className:"h-3.5 w-3.5"})," ",Ae.bathrooms," ba"]}),Ae.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ix,{className:"h-3.5 w-3.5"})," ",Ae.sqft.toLocaleString()," sqft"]})]})]},Ae.mlsNumber)})}),Q&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>J(),disabled:ce,className:"px-6 py-3 text-xs tracking-[0.2em] uppercase border border-white/20 text-white/60 hover:bg-white hover:text-black transition-all duration-500 disabled:opacity-50 flex items-center gap-2",children:ce?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More (${ne.length} of ${re})`})})]}),e.jsx("div",{className:`lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"}`,children:e.jsx(O3e,{listings:ne,onListingClick:ge,hoveredMlsNumber:m})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Er,{className:"h-12 w-12 text-white/10 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"No Results"}),e.jsx("p",{className:"text-white/30 mt-2",children:"Try a different search 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(sn,{className:"h-12 w-12 text-white/10 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Search for Properties"}),e.jsx("p",{className:"text-white/30 mt-2",children:"Enter a city, zip code, or address to begin."})]})})})]})}const Yye="ls_visitor_";function odt(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",m=(t==null?void 0:t.registrationTriggerCount)??1,f=k.useRef(r);f.current=r,k.useEffect(()=>{if(!c)return;const j=parseInt(localStorage.getItem(`${Yye}views_${c}`)||"0",10);n(j),f.current=j},[c]);const g=k.useCallback((j,N,S)=>{if(!c||u==="disabled")return;const I=f.current+1;n(I),f.current=I,localStorage.setItem(`${Yye}views_${c}`,String(I)),H.from("lead_site_property_views").insert({lead_site_id:c,mls_number:j,auth_user_id:N||null,visitor_fingerprint:localStorage.getItem(`${Yye}fp_${c}`)||null,property_address:(S==null?void 0:S.propertyAddress)||null,photo_url:(S==null?void 0:S.photoUrl)||null}).then(),!s&&!l&&I>m&&o(!0)},[c,u,s,l,m]);k.useEffect(()=>{s&&a&&o(!1)},[s,a]);const y=k.useCallback(()=>{o(!1),i(!0)},[]),_=k.useCallback(()=>{o(!1)},[]),w=u==="required"&&!s&&r>m;return{viewCount:r,showRegistration:a,isGated:w,mode:u,recordView:g,dismissRegistration:y,completeRegistration:_,setShowRegistration:o}}function ldt({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(wL,{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(Er,{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(tl,{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 cdt({listing:t}){var n,a;const s=[];t.lotSize&&s.push({label:"Lot Size",value:t.lotSize,icon:e.jsx(S0,{className:"h-4 w-4"})}),t.garageSpaces&&s.push({label:"Garage",value:`${t.garageSpaces} spaces`,icon:e.jsx(qM,{className:"h-4 w-4"})}),t.stories&&s.push({label:"Stories",value:`${t.stories}`,icon:e.jsx(ZM,{className:"h-4 w-4"})}),t.heating&&s.push({label:"Heating",value:t.heating,icon:e.jsx(ZL,{className:"h-4 w-4"})}),t.cooling&&s.push({label:"Cooling",value:t.cooling,icon:e.jsx(l0,{className:"h-4 w-4"})}),t.fireplace&&s.push({label:"Fireplace",value:"Yes",icon:e.jsx(rh,{className:"h-4 w-4"})}),t.pool&&s.push({label:"Pool",value:t.pool,icon:e.jsx(s8,{className:"h-4 w-4"})}),t.basement&&s.push({label:"Basement",value:t.basement,icon:e.jsx(ZM,{className:"h-4 w-4"})}),t.parking&&s.push({label:"Parking",value:t.parking,icon:e.jsx(qM,{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(ml,{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 ddt({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;Io.accessToken="pk.eyJ1IjoibGV2ZWx1cHJlIiwiYSI6ImNtOGZwMGNrYzBjNjIyanF5c2RwNTFhOXMifQ.sTe5rOhf_2nkqgr8Z_0e4Q";const l=new Io.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",center:[o.lng,o.lat],zoom:14,interactive:!0});return l.addControl(new Io.NavigationControl({showCompass:!1}),"top-right"),new Io.Marker({color:"#2563eb"}).setLngLat([o.lng,o.lat]).setPopup(new Io.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 udt({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,y=o*12;return g===0?f/y:f*g*Math.pow(1+g,y)/(Math.pow(1+g,y)-1)},[t,s,n,o]),c=t*(s/100),u=t-c,m=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(rS,{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:m(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,"% (",m(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:m(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:m(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:m(i*o*12+c)})]})]})]})]})}function hdt({siteConfig:t,currentListing:s}){const r=ar(),{data:n}=pt({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(Th,{className:"h-3.5 w-3.5"})," ",o.bedrooms]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(au,{className:"h-3.5 w-3.5"})," ",o.bathrooms]}),o.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ix,{className:"h-3.5 w-3.5"})," ",o.sqft.toLocaleString()]})]})]})]},o.mlsNumber)})})]})}function lTs({siteConfig:t}){var I,P,O;const{mlsNumber:s}=ao(),r=ar(),[n,a]=k.useState(!1),[o,l]=k.useState({name:"",email:"",phone:"",message:""}),[i,c]=k.useState(!1),{user:u}=V3(),m=odt(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 y=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:w,error:j}=pt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const q=new AbortController,$=window.setTimeout(()=>q.abort(),15e3);try{const z=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 z.json().catch(()=>null);if(!z.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($)}},enabled:!!s});k.useEffect(()=>{var q;s&&t&&_&&m.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}}),r6(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 w?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(ndt,{listing:_,siteConfig:t}),e.jsx(Rme,{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(Ga,{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(nd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:y,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(Ja,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(ldt,{photos:_.photos||[]}),e.jsxs("div",{className:m.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(aa,{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(Th,{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(au,{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(Ix,{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(fn,{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(xn,{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(rn,{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(cdt,{listing:_}),_.latitude&&_.longitude&&e.jsx(ddt,{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:[((I=t.agent)==null?void 0:I.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:(P=t.agent)==null?void 0:P.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($=>({...$,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($=>({...$,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($=>({...$,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($=>({...$,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(udt,{listPrice:_.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(hdt,{siteConfig:t,currentListing:_})})]}),e.jsx(UR,{open:m.showRegistration,mode:m.mode,siteConfig:t,onComplete:m.completeRegistration,onSkip:m.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:j?"Error loading listing":"Listing not found"}),j&&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 cTs({siteConfig:t}){var P,O,q;const{mlsNumber:s}=ao(),r=ar(),[n,a]=k.useState(!1),[o,l]=k.useState({name:"",email:"",phone:"",message:""}),[i,c]=k.useState(!1),{user:u}=V3(),m=odt(t,!!u),[f,g]=k.useState(!1),y="#c9a96e";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:$})=>g(!!$))},[u,s,t.id]);const _=async()=>{var $;!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:w?`${w.address}, ${w.city}, ${w.state}`:null,photo_url:(($=w==null?void 0:w.photos)==null?void 0:$[0])||null}),g(!0),me.success("Saved to favorites")))},{data:w,isLoading:j,error:N}=pt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const $=new AbortController,z=window.setTimeout(()=>$.abort(),15e3);try{const V=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:$.signal}),X=await V.json().catch(()=>null);if(!V.ok)throw new Error((X==null?void 0:X.error)||"Failed to load listing");return X}finally{window.clearTimeout(z)}},enabled:!!s});k.useEffect(()=>{var $;s&&t&&w&&m.recordView(s,u==null?void 0:u.id,{propertyAddress:w.address?`${w.address}, ${w.city}, ${w.state}`:void 0,photoUrl:(($=w.photos)==null?void 0:$[0])||void 0})},[s,t==null?void 0:t.id,w==null?void 0:w.address]);const S=async $=>{$.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}}),r6(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.")}finally{c(!1)}},M=async()=>{const $=window.location.href;if(navigator.share)try{await navigator.share({title:(w==null?void 0:w.address)||"Property",url:$})}catch{}else await navigator.clipboard.writeText($),me.success("Link copied")},I=$=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format($);return j?e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center bg-[#0d0b0a]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-white/20",style:{borderTopColor:y}})}):w?e.jsx("div",{className:"bg-[#0d0b0a] min-h-screen",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 relative",children:[e.jsx(ndt,{listing:w,siteConfig:t}),e.jsx(Rme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${w.address}, ${w.city}`,path:`/listing/${w.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-white/40 hover:text-white text-sm transition-colors",children:[e.jsx(Ga,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:M,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-white/40 border border-white/10 hover:border-white/30 transition-colors",children:[e.jsx(nd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:_,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm border transition-colors ${f?"text-red-400 border-red-400/30":"text-white/40 border-white/10 hover:border-white/30"}`,children:[e.jsx(Ja,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(ldt,{photos:w.photos||[]}),e.jsxs("div",{className:m.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-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:I(w.price)}),e.jsxs("p",{className:"text-white/50 mt-1 flex items-center gap-1",children:[e.jsx(aa,{className:"h-4 w-4"}),w.address,", ",w.city,", ",w.state," ",w.zip]})]}),e.jsx("span",{className:"px-3 py-1 text-xs tracking-wider uppercase shrink-0",style:{backgroundColor:`${y}20`,color:y},children:w.status})]}),e.jsxs("p",{className:"text-xs text-white/20",children:["MLS# ",w.mlsNumber]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-6 py-4 border-y border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Th,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.bedrooms}),e.jsx("span",{className:"text-white/40 text-sm",children:"beds"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(au,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.bathrooms}),e.jsx("span",{className:"text-white/40 text-sm",children:"baths"})]}),w.sqft>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ix,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.sqft.toLocaleString()}),e.jsx("span",{className:"text-white/40 text-sm",children:"sqft"})]}),w.yearBuilt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.yearBuilt}),e.jsx("span",{className:"text-white/40 text-sm",children:"built"})]}),w.propertyType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-white/20"}),e.jsx("span",{className:"text-sm text-white/50",children:w.propertyType})]})]}),w.virtualTourUrl&&e.jsxs("a",{href:w.virtualTourUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 border border-white/15 text-sm text-white/60 hover:text-white hover:border-white/30 transition-colors",children:[e.jsx(rn,{className:"h-4 w-4"})," Virtual Tour"]}),w.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-white mb-3 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"About This Property"}),e.jsx("p",{className:"text-white/50 text-sm leading-relaxed whitespace-pre-line",children:w.description})]}),e.jsx(cdt,{listing:w}),w.latitude&&w.longitude&&Number.isFinite(w.latitude)&&Number.isFinite(w.longitude)&&e.jsx(ddt,{latitude:w.latitude,longitude:w.longitude,address:`${w.address}, ${w.city}`})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border border-white/10 p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[((P=t.agent)==null?void 0:P.avatar_url)&&e.jsx("img",{src:t.agent.avatar_url,alt:"",className:"w-12 h-12 object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(O=t.agent)==null?void 0:O.full_name}),e.jsx("p",{className:"text-xs text-white/30 tracking-wider uppercase",children:((q=t.agent)==null?void 0:q.title)||"Agent"})]})]}),n?e.jsxs("form",{onSubmit:S,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:$=>l(z=>({...z,name:$.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email",value:o.email,onChange:$=>l(z=>({...z,email:$.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("input",{type:"tel",placeholder:"Phone",value:o.phone,onChange:$=>l(z=>({...z,phone:$.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("textarea",{placeholder:"Message",value:o.message,onChange:$=>l(z=>({...z,message:$.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20 h-20 resize-none"}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-black disabled:opacity-50 transition-all hover:opacity-90",style:{backgroundColor:y},children:i?"Sending...":"Send Message"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-black transition-all hover:opacity-90",style:{backgroundColor:y},children:"Ask About This Property"}),e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-white/60 border border-white/15 hover:bg-white hover:text-black transition-all duration-500",children:"Schedule a Showing"})]})]}),w.price>0&&e.jsx(udt,{listPrice:w.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(hdt,{siteConfig:t,currentListing:w})})]}),e.jsx(UR,{open:m.showRegistration,mode:m.mode,siteConfig:t,onComplete:m.completeRegistration,onSkip:m.dismissRegistration})]})}):e.jsx("div",{className:"bg-[#0d0b0a] min-h-[60vh] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:N?"Error loading listing":"Listing not found"}),e.jsx("button",{onClick:()=>r("/search"),className:"mt-4 text-sm hover:text-white transition-colors",style:{color:y},children:"Back to search"})]})})}function dTs({siteConfig:t}){const s=ar(),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 uTs({siteConfig:t}){const s=ar(),r=t.agent,n="#c9a96e";return e.jsxs("div",{className:"bg-[#0d0b0a] min-h-screen",children:[e.jsxs("section",{className:"relative h-[50vh] flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[r!=null&&r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"",className:"w-full h-full object-cover opacity-30"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-[#1a1715] to-[#0d0b0a]"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#0d0b0a]/60 via-transparent to-[#0d0b0a]"})]}),e.jsx("div",{className:"relative z-10 text-center px-6",children:e.jsxs(gs.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:n},children:"About"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}})]}),e.jsx("h1",{className:"text-4xl md:text-6xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(r==null?void 0:r.full_name)||"About Me"}),e.jsx("p",{className:"text-white/40 mt-4 text-lg tracking-wider uppercase",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(r==null?void 0:r.title)||"Real Estate Professional"})]})})]}),e.jsx("section",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-20",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-start",children:[(r==null?void 0:r.avatar_url)&&e.jsx(gs.div,{initial:{opacity:0,x:-30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8},children:e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:r.avatar_url,alt:r.full_name,className:"w-full aspect-[3/4] object-cover"}),e.jsx("div",{className:"absolute -bottom-4 -right-4 w-full h-full border border-white/10 -z-10"})]})}),e.jsxs(gs.div,{initial:{opacity:0,x:30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8,delay:.2},children:[e.jsx("div",{className:"w-16 h-0.5 mb-8",style:{backgroundColor:n}}),e.jsx("h2",{className:"text-3xl md:text-4xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"My Story"}),r!=null&&r.bio?e.jsx("p",{className:"text-white/60 leading-relaxed text-lg whitespace-pre-line",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:r.bio}):e.jsx("p",{className:"text-white/60 leading-relaxed text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Dedicated to delivering an exceptional real estate experience with deep local market expertise and an unwavering commitment to client success."}),e.jsx("div",{className:"grid grid-cols-2 gap-6 mt-12",children:[{icon:xn,label:"Homes Sold",value:"500+"},{icon:mn,label:"Years Experience",value:"15+"},{icon:ur,label:"Happy Clients",value:"1000+"},{icon:rc,label:"Awards",value:"25+"}].map((a,o)=>e.jsxs("div",{className:"border border-white/10 p-6 text-center",children:[e.jsx(a.icon,{className:"h-5 w-5 mx-auto mb-3",style:{color:n}}),e.jsx("p",{className:"text-2xl text-white font-light",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.value}),e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mt-2",children:a.label})]},o))}),e.jsxs("div",{className:"mt-12 space-y-4",children:[(r==null?void 0:r.phone)&&e.jsxs("a",{href:`tel:${r.phone}`,className:"flex items-center gap-3 text-white/40 hover:text-white transition-colors",children:[e.jsx(Nn,{className:"h-4 w-4",style:{color:n}}),e.jsx("span",{className:"text-sm tracking-wider",children:r.phone})]}),(r==null?void 0:r.email)&&e.jsxs("a",{href:`mailto:${r.email}`,className:"flex items-center gap-3 text-white/40 hover:text-white transition-colors",children:[e.jsx(rr,{className:"h-4 w-4",style:{color:n}}),e.jsx("span",{className:"text-sm tracking-wider",children:r.email})]})]})]})]})}),e.jsx("section",{className:"py-24 border-t border-white/5",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Ready to Get Started?"}),e.jsx("p",{className:"text-white/40 text-lg mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Whether you're buying or selling, I'm here to help you every step of the way."}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>s("/contact"),className:"px-10 py-4 text-xs tracking-[0.3em] uppercase text-black transition-all duration-500 hover:opacity-90",style:{backgroundColor:n},children:"Contact Me"}),e.jsx("button",{onClick:()=>s("/search"),className:"px-10 py-4 text-xs tracking-[0.3em] uppercase text-white/70 border border-white/20 hover:bg-white hover:text-black transition-all duration-500",children:"Browse Listings"})]})]})})]})}function hTs({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"}),r6(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(rr,{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(Nn,{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 mTs({siteConfig:t}){const[s,r]=k.useState({name:"",email:"",phone:"",message:""}),[n,a]=k.useState(!1),o=t.agent,l="#c9a96e",i=async c=>{c.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"}),r6(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)}};return e.jsxs("div",{className:"bg-[#0d0b0a] min-h-screen",children:[e.jsx("section",{className:"pt-32 pb-16 px-6 text-center",children:e.jsxs(gs.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:l}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:l},children:"Contact"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:l}})]}),e.jsx("h1",{className:"text-4xl md:text-6xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Get In Touch"}),e.jsx("p",{className:"text-white/40 mt-4 text-lg max-w-xl mx-auto",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Ready to start your real estate journey? Let's connect."})]})}),e.jsx("div",{className:"max-w-6xl mx-auto px-6 lg:px-8 pb-24",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16",children:[e.jsxs(gs.div,{initial:{opacity:0,x:-20},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:[e.jsxs("div",{className:"flex items-center gap-5 mb-10",children:[(o==null?void 0:o.avatar_url)&&e.jsx("img",{src:o.avatar_url,alt:"",className:"w-20 h-20 object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-xl",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o==null?void 0:o.full_name}),e.jsx("p",{className:"text-white/30 text-xs tracking-[0.2em] uppercase mt-1",children:(o==null?void 0:o.title)||"Real Estate Professional"})]})]}),e.jsxs("div",{className:"space-y-6",children:[(o==null?void 0:o.email)&&e.jsxs("a",{href:`mailto:${o.email}`,className:"flex items-center gap-4 group",children:[e.jsx("div",{className:"w-12 h-12 border border-white/10 flex items-center justify-center group-hover:border-white/30 transition-colors",children:e.jsx(rr,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mb-1",children:"Email"}),e.jsx("p",{className:"text-white/70 hover:text-white transition-colors",children:o.email})]})]}),(o==null?void 0:o.phone)&&e.jsxs("a",{href:`tel:${o.phone}`,className:"flex items-center gap-4 group",children:[e.jsx("div",{className:"w-12 h-12 border border-white/10 flex items-center justify-center group-hover:border-white/30 transition-colors",children:e.jsx(Nn,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mb-1",children:"Phone"}),e.jsx("p",{className:"text-white/70 hover:text-white transition-colors",children:o.phone})]})]})]}),e.jsxs("div",{className:"mt-16 border-l-2 pl-6",style:{borderColor:l},children:[e.jsx("p",{className:"text-white/40 text-lg leading-relaxed",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:'"Every client deserves a luxury experience — regardless of price point."'}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.2em] uppercase mt-4",children:o==null?void 0:o.full_name})]})]}),e.jsx(gs.div,{initial:{opacity:0,x:20},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6,delay:.1},children:e.jsxs("form",{onSubmit:i,className:"border border-white/10 p-8 lg:p-10 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:c=>r(u=>({...u,name:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"Your full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Email *"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:c=>r(u=>({...u,email:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"your@email.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Phone"}),e.jsx("input",{type:"tel",value:s.phone,onChange:c=>r(u=>({...u,phone:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Message *"}),e.jsx("textarea",{required:!0,value:s.message,onChange:c=>r(u=>({...u,message:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15 h-32 resize-none",placeholder:"Tell me about your real estate needs..."})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-4 text-xs tracking-[0.3em] uppercase text-black disabled:opacity-50 transition-all duration-500 hover:opacity-90",style:{backgroundColor:l},children:n?"Sending...":"Send Message"})]})})]})})]})}function pTs({siteConfig:t}){const s=ar(),{user:r,profile:n,signOut:a}=V3(),[o,l]=k.useState("saved"),[i,c]=k.useState([]),[u,m]=k.useState([]),[f,g]=k.useState({name:"",phone:"",email:""}),[y,_]=k.useState(!1);k.useEffect(()=>{if(!r){s("/");return}w(),n&&g({name:n.name,phone:n.phone||"",email:n.email})},[r,n]);const w=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:I}=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),P=new Set,O=(I||[]).filter(q=>P.has(q.mls_number)?!1:(P.add(q.mls_number),!0));m(O)},j=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(I=>I.filter(P=>P.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:Ja,count:i.length},{key:"viewed",label:"Recently Viewed",icon:mn,count:u.length},{key:"profile",label:"My Profile",icon:Zi}];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(fS,{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 I=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(I,{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(Ja,{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:()=>j(M.mls_number),className:"p-2 text-gray-400 hover:text-red-500 ml-2",children:e.jsx(kr,{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(mn,{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(I=>({...I,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(I=>({...I,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:y,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:y?"Saving...":"Save Changes"})]})})]})}function S9e({siteConfig:t,isLuxury:s=!1}){var y;const r=s,n="#c9a96e",a=ar(),{slug:o}=ao(),[l,i]=k.useState("all"),{data:c,isLoading:u}=pt({queryKey:["public-blog-posts",t.id,l],queryFn:async()=>{let _=H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("published_at",{ascending:!1});l!=="all"&&(_=_.eq("post_type",l));const{data:w,error:j}=await _;if(j)throw j;return w},enabled:!o}),{data:m,isLoading:f}=pt({queryKey:["public-blog-post",t.id,o],queryFn:async()=>{const{data:_,error:w}=await H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("slug",o).eq("is_published",!0).maybeSingle();if(w)throw w;return _},enabled:!!o});if(o)return f?e.jsx("div",{className:`min-h-screen flex items-center justify-center ${r?"bg-[#0d0b0a]":""}`,children:e.jsx("div",{className:`h-6 w-6 animate-spin rounded-full border-2 border-t-transparent ${r?"border-white":"border-gray-900"}`})}):m?e.jsxs("div",{className:`min-h-screen ${r?"bg-[#0d0b0a]":"bg-white"}`,children:[e.jsx(tMs,{title:m.title,description:m.excerpt||m.title,publishedAt:m.published_at||m.created_at,imageUrl:m.cover_image_url,slug:m.slug,siteConfig:t}),e.jsx(Rme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Blog",path:"/blog"},{name:m.title,path:`/blog/${m.slug}`}]}),m.cover_image_url&&e.jsxs("div",{className:"h-72 md:h-96 w-full relative",children:[e.jsx("img",{src:m.cover_image_url,alt:m.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:()=>a("/blog"),className:`flex items-center gap-1.5 text-sm mb-6 transition-colors ${r?"text-white/40 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(Ga,{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 ${m.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:m.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),m.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(aa,{className:"h-3 w-3"})," ",m.neighborhood]})]}),e.jsx("h1",{className:`text-3xl md:text-4xl font-bold mb-4 ${r?"text-white":"text-gray-900"}`,style:r?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:m.title}),m.published_at&&e.jsx("p",{className:`text-sm mb-8 ${r?"text-white/30":"text-gray-400"}`,children:new Date(m.published_at).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),e.jsx("div",{className:`prose prose-lg max-w-none ${r?"prose-invert prose-headings:text-white prose-p:text-white/70 prose-a:text-[#c9a96e]":"prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600"}`,dangerouslySetInnerHTML:{__html:m.content}})]})]}):e.jsx("div",{className:`min-h-screen flex items-center justify-center ${r?"bg-[#0d0b0a]":"bg-gray-50"}`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:`text-2xl font-bold mb-2 ${r?"text-white":"text-gray-900"}`,children:"Post Not Found"}),e.jsx("button",{onClick:()=>a("/blog"),className:"text-blue-600 hover:underline",children:"← Back to blog"})]})});const g=((y=t.agent)==null?void 0:y.full_name)||"Your Agent";return e.jsxs("div",{className:`min-h-screen ${r?"bg-[#0d0b0a]":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-white py-20 px-6 ${r?"bg-[#0d0b0a] border-b border-white/5":"bg-gradient-to-br from-gray-900 to-gray-800"}`,children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[r&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:n},children:"Blog"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",style:r?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Local Insights"}),e.jsxs("p",{className:`text-lg max-w-2xl mx-auto ${r?"text-white/40":"text-gray-300"}`,children:["Neighborhood guides, market insights, and local expertise from ",g,"."]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 -mt-6 mb-8",children:e.jsx("div",{className:`rounded-2xl shadow-lg p-2 flex gap-1 ${r?"bg-[#161312] border border-white/10":"bg-white"}`,children:[{value:"all",label:"All Posts"},{value:"blog_post",label:"Blog"},{value:"neighborhood_guide",label:"Neighborhoods"}].map(_=>e.jsx("button",{onClick:()=>i(_.value),className:`flex-1 py-2.5 px-4 rounded-xl text-sm font-medium transition-all ${l===_.value?r?"bg-white/10 text-white shadow-md":"bg-gray-900 text-white shadow-md":r?"text-white/40 hover:bg-white/5":"text-gray-600 hover:bg-gray-100"}`,children:_.label},_.value))})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 pb-20",children:u?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"})}):c!=null&&c.length?e.jsx("div",{className:"grid gap-6",children:c.map((_,w)=>e.jsx(gs.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:w*.05},onClick:()=>a(`/blog/${_.slug}`),className:`rounded-2xl overflow-hidden transition-all cursor-pointer group border ${r?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-xl border-gray-100"}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[_.cover_image_url&&e.jsx("div",{className:"sm:w-64 h-48 sm:h-auto flex-shrink-0",children:e.jsx("img",{src:_.cover_image_url,alt:_.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 ${_.post_type==="neighborhood_guide"?r?"bg-emerald-900/30 text-emerald-400":"bg-emerald-50 text-emerald-700":r?"bg-blue-900/30 text-blue-400":"bg-blue-50 text-blue-700"}`,children:_.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),_.neighborhood&&e.jsxs("span",{className:`text-xs flex items-center gap-1 ${r?"text-white/40":"text-gray-500"}`,children:[e.jsx(aa,{className:"h-3 w-3"})," ",_.neighborhood]})]}),e.jsx("h2",{className:`text-xl font-bold transition-colors mb-2 ${r?"text-white group-hover:text-[#c9a96e]":"text-gray-900 group-hover:text-blue-600"}`,children:_.title}),_.excerpt&&e.jsx("p",{className:`text-sm line-clamp-2 mb-3 ${r?"text-white/50":"text-gray-600"}`,children:_.excerpt}),_.published_at&&e.jsx("p",{className:`text-xs ${r?"text-white/30":"text-gray-400"}`,children:new Date(_.published_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})},_.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 fTs({siteConfig:t,isLuxury:s=!1}){var i;const r=((i=t.agent)==null?void 0:i.full_name)||"Your Agent",n=s,a="#c9a96e",{data:o}=pt({queryKey:["public-lead-site-events",t.id],queryFn:async()=>{const{data:c,error:u}=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(u)throw u;return c}}),{data:l}=pt({queryKey:["public-lead-site-businesses",t.id],queryFn:async()=>{const{data:c,error:u}=await H.from("lead_site_businesses").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0});if(u)throw u;return c}});return e.jsxs("div",{className:`min-h-screen ${n?"bg-[#0d0b0a]":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-white py-20 px-6 ${n?"bg-[#0d0b0a] border-b border-white/5":"bg-gradient-to-br from-gray-900 to-gray-800"}`,children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[n&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:a}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:a},children:"Community"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:a}})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",style:n?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Community"}),e.jsxs("p",{className:`text-lg max-w-2xl mx-auto ${n?"text-white/40":"text-gray-300"}`,children:["Local events, favorite spots, and everything that makes this area special — curated by ",r,"."]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-16 space-y-20",children:[o&&o.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 flex items-center justify-center ${n?"bg-white/5":"bg-blue-100"}`,children:e.jsx(fn,{className:`h-5 w-5 ${n?"text-[#c9a96e]":"text-blue-600"}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:`text-2xl font-bold ${n?"text-white":"text-gray-900"}`,children:"Upcoming Events"}),e.jsx("p",{className:`text-sm ${n?"text-white/40":"text-gray-500"}`,children:"What's happening in the community"})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:o.map((c,u)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:u*.05},className:`rounded-2xl overflow-hidden transition-all border group ${n?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-lg border-gray-100"}`,children:[c.image_url&&e.jsx("div",{className:"h-40 overflow-hidden",children:e.jsx("img",{src:c.image_url,alt:c.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 flex flex-col items-center justify-center ${n?"bg-white/5":"bg-blue-50"}`,children:[e.jsx("span",{className:`text-[10px] font-bold uppercase leading-none ${n?"text-[#c9a96e]":"text-blue-600"}`,children:ds(new Date(c.event_date),"MMM")}),e.jsx("span",{className:`text-xl font-bold leading-none mt-0.5 ${n?"text-[#c9a96e]":"text-blue-600"}`,children:ds(new Date(c.event_date),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:`font-bold text-lg mb-1 ${n?"text-white":"text-gray-900"}`,children:c.title}),c.description&&e.jsx("p",{className:`text-sm line-clamp-2 mb-2 ${n?"text-white/50":"text-gray-600"}`,children:c.description}),e.jsxs("div",{className:`flex flex-wrap items-center gap-3 text-xs ${n?"text-white/40":"text-gray-500"}`,children:[c.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(aa,{className:"h-3 w-3"})," ",c.location]}),e.jsx("span",{children:ds(new Date(c.event_date),"h:mm a")})]}),c.external_url&&e.jsxs("a",{href:c.external_url,target:"_blank",rel:"noopener",className:`inline-flex items-center gap-1 text-xs mt-3 font-medium ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:["Learn More ",e.jsx(rn,{className:"h-3 w-3"})]})]})]})})]},c.id))})]}),l&&l.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 flex items-center justify-center ${n?"bg-white/5":"bg-amber-100"}`,children:e.jsx(sT,{className:`h-5 w-5 ${n?"text-[#c9a96e]":"text-amber-600"}`})}),e.jsxs("div",{children:[e.jsxs("h2",{className:`text-2xl font-bold ${n?"text-white":"text-gray-900"}`,children:[r,"'s Local Picks"]}),e.jsx("p",{className:`text-sm ${n?"text-white/40":"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:l.map((c,u)=>e.jsxs(gs.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:u*.05},className:`rounded-2xl overflow-hidden transition-all border group ${n?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-lg border-gray-100"}`,children:[c.image_url?e.jsx("div",{className:"h-36 overflow-hidden",children:e.jsx("img",{src:c.image_url,alt:c.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}):e.jsx("div",{className:`h-24 flex items-center justify-center ${n?"bg-white/5":"bg-gradient-to-br from-amber-50 to-orange-50"}`,children:e.jsx(sT,{className:`h-8 w-8 ${n?"text-white/20":"text-amber-300"}`})}),e.jsxs("div",{className:"p-4",children:[c.category&&e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider mb-1 block ${n?"text-[#c9a96e]":"text-amber-600"}`,children:c.category}),e.jsx("h3",{className:`font-bold mb-1 ${n?"text-white":"text-gray-900"}`,children:c.name}),c.description&&e.jsx("p",{className:`text-sm line-clamp-2 mb-3 ${n?"text-white/50":"text-gray-600"}`,children:c.description}),e.jsx("div",{className:`flex flex-wrap items-center gap-3 text-xs ${n?"text-white/40":"text-gray-500"}`,children:c.address&&e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(aa,{className:"h-3 w-3 flex-shrink-0"})," ",c.address]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[c.phone&&e.jsxs("a",{href:`tel:${c.phone}`,className:`text-xs flex items-center gap-1 ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(Nn,{className:"h-3 w-3"})," Call"]}),c.website_url&&e.jsxs("a",{href:c.website_url,target:"_blank",rel:"noopener",className:`text-xs flex items-center gap-1 ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(Nd,{className:"h-3 w-3"})," Website"]})]})]})]},c.id))})]}),(!o||o.length===0)&&(!l||l.length===0)&&e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:`text-lg ${n?"text-white/30":"text-gray-400"}`,children:"Community content coming soon!"})})]})]})}function xTs({siteConfig:t,themeConfig:s,isLuxury:r=!1}){var J,Q,ce,ne;const n=ar(),[a]=Ul(),o=((J=t.agent)==null?void 0:J.full_name)||"Your Agent",l=o.split(" ")[0],i=r?"#c9a96e":(s==null?void 0:s.accentColor)||((Q=t.themeConfig)==null?void 0:Q.accentColor)||"#3b82f6",c=r,[u,m]=k.useState({name:"",email:"",phone:"",address:"",timeline:"",message:""}),[f,g]=k.useState(!1),[y,_]=k.useState(!1),[w,j]=k.useState(null),[N,S]=k.useState(!0),[M,I]=k.useState("");k.useEffect(()=>{(async()=>{const oe=a.get("city");if(oe){I(oe);return}const{data:he}=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);he!=null&&he[0]&&I(he[0].city_name)})()},[t.id,a]),k.useEffect(()=>{if(!M){S(!1);return}(async()=>{S(!0);try{const{data:oe,error:he}=await H.functions.invoke("lead-site-seller-stats",{body:{leadSiteId:t.id,city:M}});!he&&oe&&j(oe)}catch(oe){console.warn("Failed to load seller stats:",oe)}finally{S(!1)}})()},[t.id,M]);const P=async re=>{re.preventDefault(),g(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:u.name,email:u.email,phone:u.phone||null,message:u.message||null,source_page:"/sell",lead_type:"seller",metadata:{address:u.address,timeline:u.timeline}}),r6(t.id,{name:u.name,email:u.email,phone:u.phone||null,message:`Seller Lead — ${u.address||"Address not provided"} Timeline: ${u.timeline||"Not specified"} ${u.message||""}`,lead_type:"seller",source_page:"/sell"}),_(!0),me.success("Your request has been submitted!")}catch{me.error("Something went wrong. Please try again.")}finally{g(!1)}},O=re=>re>=1e6?`$${(re/1e6).toFixed(1)}M`:`$${Math.round(re/1e3)}K`,q=`https://${t.subdomainSlug}.thelocalmove.com`,$=`Sell Your Home | ${o}`,z=`Thinking of selling your home? Get a free market analysis from ${o}. See recent sales, market trends, and what your home could be worth.`,V=(w==null?void 0:w.marketCondition)==="seller"?"It's a Seller's Market":(w==null?void 0:w.marketCondition)==="buyer"?"It's a Buyer's Market":"The Market Is Balanced",X=(w==null?void 0:w.marketCondition)==="seller"?"Demand exceeds supply. Sellers have the advantage with faster sales and stronger offers.":(w==null?void 0:w.marketCondition)==="buyer"?"More inventory than buyers. Pricing strategy and presentation are critical.":"Supply and demand are relatively even. Well-priced homes sell quickly.",Y=[{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 ${c?"bg-[#0d0b0a]":"bg-white"}`,children:[e.jsxs(Pl,{children:[e.jsx("title",{children:$}),e.jsx("meta",{name:"description",content:z}),e.jsx("meta",{property:"og:title",content:$}),e.jsx("meta",{property:"og:description",content:z}),e.jsx("link",{rel:"canonical",href:`${q}/sell`})]}),e.jsx(VR,{siteConfig:t,pagePath:"/sell"}),e.jsxs("section",{className:`relative ${c?"bg-[#0d0b0a]":"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%, ${i}44, transparent 60%), radial-gradient(ellipse at 70% 60%, ${i}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:`${i}20`,color:i},children:[e.jsx(Bo,{className:"h-4 w-4"}),(w==null?void 0:w.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 ",style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:["What's Your Home ",e.jsx("span",{style:{color:i},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 ",l,". 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:i}})," No obligation"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:i}})," Real MLS data"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:i}})," Expert guidance"]})]})]}),e.jsx("div",{className:`${c?"bg-[#161312] border border-white/10":"bg-white"} rounded-2xl p-8 shadow-2xl ${c?"text-white":"text-gray-900"}`,children:y?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:`${i}15`},children:e.jsx(sa,{className:"h-8 w-8",style:{color:i}})}),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:[l," will review your information and send you a personalized market analysis within 24 hours."]}),e.jsxs("button",{onClick:()=>n("/search"),className:"text-sm font-medium flex items-center gap-1 mx-auto",style:{color:i},children:["Browse current listings ",e.jsx(ba,{className:"h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:`text-xl font-bold mb-1 ${c?"text-white":""}`,children:"Get Your Free Home Valuation"}),e.jsxs("p",{className:`text-sm mb-6 ${c?"text-white/50":"text-gray-500"}`,children:[l," will send you a personalized market analysis."]}),e.jsx("form",{onSubmit:P,className:"space-y-3.5",children:(()=>{const re=`w-full px-4 py-3 border rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent ${c?"bg-white/5 border-white/10 text-white placeholder:text-white/30":"bg-gray-50 border-gray-200"}`,oe={"--tw-ring-color":i};return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your property address *",value:u.address,onChange:he=>m(xe=>({...xe,address:he.target.value})),className:re,style:oe}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Full name *",value:u.name,onChange:he=>m(xe=>({...xe,name:he.target.value})),className:re,style:oe}),e.jsx("input",{type:"tel",placeholder:"Phone",value:u.phone,onChange:he=>m(xe=>({...xe,phone:he.target.value})),className:re,style:oe})]}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address *",value:u.email,onChange:he=>m(xe=>({...xe,email:he.target.value})),className:re,style:oe}),e.jsxs("select",{value:u.timeline,onChange:he=>m(xe=>({...xe,timeline:he.target.value})),className:`${re} ${c?"text-white/70":"text-gray-700"}`,style:oe,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:u.message,onChange:he=>m(xe=>({...xe,message:he.target.value})),className:`${re} h-20 resize-none`,style:oe}),e.jsx("button",{type:"submit",disabled:f,className:"w-full py-3.5 text-white font-semibold rounded-xl transition-all hover:opacity-90 disabled:opacity-50 text-sm",style:{backgroundColor:i},children:f?"Submitting...":"Get My Free Valuation"}),e.jsxs("p",{className:`text-[11px] text-center ${c?"text-white/30":"text-gray-400"}`,children:["By submitting, you agree to be contacted by ",l," about your property."]})]})})()})]})})]})})]}),w&&!N&&e.jsx("section",{className:`py-20 ${c?"bg-[#111] border-t border-white/5":"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 ${c?"bg-green-900/30 text-green-400":"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 tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:[M," Market Snapshot"]}),e.jsx("p",{className:`mt-3 max-w-2xl mx-auto ${c?"text-white/40":"text-gray-500"}`,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 ${c?"bg-white/5 border border-white/10":""}`,style:c?{}:{backgroundColor:w.marketCondition==="seller"?"#f0fdf4":w.marketCondition==="buyer"?"#fef2f2":"#eff6ff"},children:[e.jsx("h3",{className:"text-xl font-bold mb-1",style:{color:c?i:w.marketCondition==="seller"?"#15803d":w.marketCondition==="buyer"?"#b91c1c":"#1d4ed8"},children:V}),e.jsx("p",{className:`text-sm max-w-xl mx-auto ${c?"text-white/50":"text-gray-600"}`,children:X}),e.jsxs("p",{className:`text-xs mt-2 ${c?"text-white/30":"text-gray-400"}`,children:[w.monthsOfInventory," months of inventory · ",w.activeCount," active · ",w.soldCount," sold (6 mo)"]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[{icon:ml,label:"Median Sold Price",value:w.medianSoldPrice>0?O(w.medianSoldPrice):"—",color:"#10b981"},{icon:mn,label:"Avg Days on Market",value:w.avgDaysOnMarket>0?`${w.avgDaysOnMarket} days`:"—",color:"#f59e0b"},{icon:_S,label:"Sale-to-List Ratio",value:w.listToSaleRatio>0?`${w.listToSaleRatio}%`:"—",color:"#8b5cf6"},{icon:co,label:"Avg Price / Sq Ft",value:w.avgPricePerSqft>0?`$${w.avgPricePerSqft}`:"—",color:"#3b82f6"}].map(re=>e.jsxs("div",{className:`rounded-xl border p-5 text-center ${c?"bg-[#161312] border-white/10":"bg-white border-gray-100 shadow-sm"}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mx-auto mb-3",style:{backgroundColor:`${re.color}12`},children:e.jsx(re.icon,{className:"h-5 w-5",style:{color:re.color}})}),e.jsx("p",{className:`text-2xl md:text-3xl font-bold ${c?"text-white":"text-gray-900"}`,children:re.value}),e.jsx("p",{className:`text-xs mt-1 ${c?"text-white/40":"text-gray-500"}`,children:re.label})]},re.label))})]})}),(w==null?void 0:w.recentlySold)&&w.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 tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"What Sellers Are Getting"}),e.jsxs("p",{className:`mt-3 ${c?"text-white/40":"text-gray-500"}`,children:["Recently sold homes in ",M," — real prices, real results."]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:w.recentlySold.map((re,oe)=>{var he,xe,ue;return e.jsxs("div",{className:`rounded-xl border overflow-hidden transition-shadow ${c?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white border-gray-100 shadow-sm hover:shadow-md"}`,children:[e.jsxs("div",{className:`aspect-[16/10] relative ${c?"bg-white/5":"bg-gray-100"}`,children:[(he=re.photos)!=null&&he[0]?e.jsx("img",{src:re.photos[0],alt:re.address,className:"w-full h-full object-cover"}):e.jsx("div",{className:`w-full h-full flex items-center justify-center ${c?"text-white/20":"text-gray-300"}`,children:e.jsx(xn,{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 ${c?"text-white":"text-gray-900"}`,children:["$",(xe=re.soldPrice)==null?void 0:xe.toLocaleString()]}),re.listPrice>0&&re.soldPrice>0&&e.jsxs("span",{className:`text-xs font-semibold ${re.soldPrice>=re.listPrice?"text-green-600":"text-red-500"}`,children:[re.soldPrice>=re.listPrice?"+":"",((re.soldPrice-re.listPrice)/re.listPrice*100).toFixed(1),"%"]})]}),e.jsxs("p",{className:`text-sm mb-2 flex items-center gap-1 ${c?"text-white/50":"text-gray-600"}`,children:[e.jsx(aa,{className:`h-3.5 w-3.5 flex-shrink-0 ${c?"text-white/30":"text-gray-400"}`}),re.address,", ",re.city]}),e.jsxs("div",{className:`flex items-center gap-3 text-xs ${c?"text-white/40":"text-gray-500"}`,children:[e.jsxs("span",{children:[re.bedrooms," bed"]}),e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[re.bathrooms," bath"]}),e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[(ue=re.sqft)==null?void 0:ue.toLocaleString()," sqft"]}),re.daysOnMarket>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[re.daysOnMarket," DOM"]})]})]})]})]},re.mlsNumber||oe)})})]})}),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 ",l," 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:Y.map((re,oe)=>e.jsxs("div",{className:"relative flex gap-6 pb-10 last:pb-0",children:[oee.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:`${i}12`},children:e.jsx(re.icon,{className:"h-5 w-5",style:{color:i}})}),e.jsxs("div",{children:[e.jsx("h3",{className:`font-semibold mb-0.5 ${c?"text-white":"text-gray-900"}`,children:re.title}),e.jsx("p",{className:`text-sm leading-relaxed ${c?"text-white/50":"text-gray-500"}`,children:re.desc})]})]},re.title))})]}),e.jsx("div",{className:"flex justify-center",children:(ce=t.agent)!=null&&ce.avatar_url?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.agent.avatar_url,alt:o,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 rounded-xl shadow-lg p-4 border ${c?"bg-[#161312] border-white/10":"bg-white border-gray-100"}`,children:[e.jsx("p",{className:`text-xs mb-0.5 ${c?"text-white/40":"text-gray-500"}`,children:"Your local expert"}),e.jsx("p",{className:`font-bold ${c?"text-white":"text-gray-900"}`,children:o}),e.jsx("p",{className:`text-xs ${c?"text-white/40":"text-gray-500"}`,children:((ne=t.agent)==null?void 0:ne.title)||"REALTOR®"})]})]}):e.jsx("div",{className:`w-72 h-72 rounded-2xl flex items-center justify-center ${c?"bg-white/5":"bg-gray-100"}`,children:e.jsx(xn,{className:`h-16 w-16 ${c?"text-white/20":"text-gray-300"}`})})})]})})}),e.jsx("section",{className:`py-20 ${c?"bg-[#111] border-t border-white/5":"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-center mb-10 tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Frequently Asked Questions"}),e.jsx(gTs,{agentName:l,city:M,accentColor:i,isLuxury:c})]})}),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 ",l," 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:i},children:"Get My Free Valuation"}),e.jsxs("button",{onClick:()=>n("/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 ",l]})]})]})})]})}function gTs({agentName:t,city:s,accentColor:r,isLuxury:n=!1}){const[a,o]=k.useState(null),l=s||"your area",i=n,c=[{q:`How do I know what my home is worth in ${l}?`,a:`${t} provides a complimentary Comparative Market Analysis (CMA) using current MLS data — recent sales, active listings, and market trends in ${l}. 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 ${l}, 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 ${l}?`,a:`While spring and summer tend to see more buyer activity, ${l}'s market has its own patterns. ${t} can show you seasonal trends from MLS data to help you choose the optimal listing window.`}],u={"@context":"https://schema.org","@type":"FAQPage",mainEntity:c.map(m=>({"@type":"Question",name:m.q,acceptedAnswer:{"@type":"Answer",text:m.a}}))};return e.jsxs(e.Fragment,{children:[e.jsx(Pl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(u)})}),e.jsx("div",{className:"space-y-3",children:c.map((m,f)=>e.jsxs("div",{className:`rounded-xl border overflow-hidden ${i?"bg-[#161312] border-white/10":"bg-white border-gray-200"}`,children:[e.jsxs("button",{onClick:()=>o(a===f?null:f),className:"w-full flex items-center justify-between px-6 py-4 text-left",children:[e.jsx("span",{className:`font-medium text-sm pr-4 ${i?"text-white":"text-gray-900"}`,children:m.q}),e.jsx(da,{className:`h-4 w-4 flex-shrink-0 transition-transform ${a===f?"rotate-90":""} ${i?"text-white/30":"text-gray-400"}`})]}),a===f&&e.jsx("div",{className:`px-6 pb-5 text-sm leading-relaxed border-t pt-4 ${i?"text-white/50 border-white/5":"text-gray-600 border-gray-100"}`,children:m.a})]},f))})]})}function yTs(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 vTs({city:t,state:s="",agentName:r,accentColor:n="#3b82f6"}){const a=yTs(t,s,r),[o,l]=k.useState(null);return e.jsxs("section",{className:"py-16 bg-gray-50",children:[e.jsx(eMs,{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(Sp,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}):e.jsx(Ji,{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 bTs({cityName:t,citySlug:s,agentName:r,total:n,medianPrice:a,avgDom:o,accentColor:l,heroImageUrl:i}){const c=ar();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(la,{to:"/",className:"hover:text-white transition-colors",children:"Home"}),e.jsx("span",{children:"›"}),e.jsx(la,{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(sn,{className:"h-5 w-5"}),"Search All ",t," Listings"]})]})]})}function _Ts({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 wTs({listings:t,cityName:s,accentColor:r}){const n=ar(),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 m=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:()=>m("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(tl,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>m("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 y,_,w;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:((y=f.photos)==null?void 0:y[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(Th,{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(au,{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(xS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(w=f.sqft)==null?void 0:w.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(ba,{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 jTs({listings:t,cityName:s,accentColor:r}){const n=ar(),[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(O3e,{listings:t,onListingClick:i=>n(`/listing/${i}`),hoveredMlsNumber:a})})]})})}function NTs({cityName:t,total:s,medianPrice:r,avgDom:n,pricePerSqft:a,accentColor:o}){if(s===0&&!r)return null;const l=[{icon:xn,label:"Active Listings",value:s>0?s.toLocaleString():"—",sublabel:"Currently on market"},{icon:ml,label:"Median Price",value:r?`$${(r/1e3).toFixed(0)}K`:"—",sublabel:"Active listings"},{icon:mn,label:"Avg Days on Market",value:n?Math.round(n).toString():"—",sublabel:"Time to sell"},{icon:Bo,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 kTs({cityName:t,agentName:s,accentColor:r}){const n=ar();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 STs({siteConfig:t,citySlugOverride:s}){var M;const r=ao(),n=s||r.citySlug;ar();const[a,o]=k.useState([]),[l,i]=k.useState(!0),[c,u]=k.useState(0),[m,f]=k.useState(null),g=k.useMemo(()=>(n||"").split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),[n]),y=((M=t.agent)==null?void 0:M.full_name)||"Your Agent",_=t.accentColor||"#3b82f6",w=`https://${t.subdomainSlug}.thelocalmove.com`,j=`Homes for Sale in ${g} | ${y}`,N=`Browse ${g} homes for sale with ${y}. View listings, pricing, photos, and neighborhood info. Your trusted local real estate expert.`;k.useEffect(()=>{n&&(async()=>{const{data:P}=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();P&&f({description:P.description,highlights:Array.isArray(P.highlights)?P.highlights:[],hero_image_url:P.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 I=a.map(V=>V.price).filter(V=>!!V&&V>0).sort((V,X)=>V-X),P=I.length>0?I[Math.floor(I.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,X)=>V+X,0)/O.length:null,$=a.filter(V=>V.price&&V.sqft&&V.sqft>0),z=$.length>0?$.reduce((V,X)=>V+X.price/X.sqft,0)/$.length:null;return{medianPrice:P,avgDom:q,pricePerSqft:z}},[a]);return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(VR,{siteConfig:t,pagePath:`/homes-for-sale-in-${n}`}),e.jsx(Rme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${g} Homes`,path:`/homes-for-sale-in-${n}`}]}),e.jsxs(Pl,{children:[e.jsx("title",{children:j}),e.jsx("meta",{name:"description",content:N}),e.jsx("link",{rel:"canonical",href:`${w}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:title",content:j}),e.jsx("meta",{property:"og:description",content:N}),e.jsx("meta",{property:"og:url",content:`${w}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:site_name",content:t.siteTitle||y}),((m==null?void 0:m.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{property:"og:image",content:(m==null?void 0:m.hero_image_url)||t.ogImageUrl||""}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:j}),e.jsx("meta",{name:"twitter:description",content:N}),((m==null?void 0:m.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{name:"twitter:image",content:(m==null?void 0:m.hero_image_url)||t.ogImageUrl||""})]}),e.jsx(bTs,{cityName:g,citySlug:n||"",agentName:y,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,accentColor:_,heroImageUrl:(m==null?void 0:m.hero_image_url)||void 0}),e.jsx(_Ts,{cityName:g,description:(m==null?void 0:m.description)||null,highlights:(m==null?void 0:m.highlights)||[],agentName:y,accentColor:_}),e.jsx(NTs,{cityName:g,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,pricePerSqft:S.pricePerSqft,accentColor:_}),!l&&e.jsx(wTs,{listings:a.slice(0,12),cityName:g,accentColor:_}),!l&&a.length>0&&e.jsx(jTs,{listings:a,cityName:g,accentColor:_}),e.jsx(vTs,{city:g,agentName:y,accentColor:_}),e.jsx(kTs,{cityName:g,agentName:y,accentColor:_})]})}function CTs({blocks:t}){return e.jsx("div",{className:"w-full",children:t.map(s=>e.jsx(MTs,{block:s},s.id))})}function MTs({block:t}){const s=t.config;switch(t.type){case"hero-banner":return e.jsxs("section",{className:"relative flex items-center justify-center min-h-[400px] bg-gray-900 text-white overflow-hidden",style:{backgroundImage:s.backgroundImageUrl?`url(${s.backgroundImageUrl})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},children:[e.jsx("div",{className:"absolute inset-0 bg-black",style:{opacity:(s.overlayOpacity??50)/100}}),e.jsxs("div",{className:`relative z-10 px-6 py-16 max-w-3xl w-full ${s.alignment==="left"?"text-left":s.alignment==="right"?"text-right":"text-center mx-auto"}`,children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:s.headline}),s.subtitle&&e.jsx("p",{className:"text-lg md:text-xl text-white/80 mb-6",children:s.subtitle}),s.showButton&&s.buttonText&&e.jsx(la,{to:s.buttonLink||"/contact",className:"inline-block px-6 py-3 bg-white text-gray-900 font-semibold rounded-lg hover:bg-gray-100 transition-colors",children:s.buttonText})]})]});case"rich-text":return e.jsx("section",{className:"max-w-3xl mx-auto px-6 py-12",children:e.jsx("div",{className:"prose prose-gray max-w-none",dangerouslySetInnerHTML:{__html:s.content||""}})});case"image-text":{const r=s.imagePosition!=="right";return e.jsx("section",{className:"max-w-6xl mx-auto px-6 py-16",children:e.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-2 gap-10 items-center ${r?"":"md:[direction:rtl] *:md:[direction:ltr]"}`,children:[e.jsx("div",{className:"rounded-2xl overflow-hidden aspect-[4/3] bg-gray-100",children:s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400 text-sm",children:"No image"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-4",children:s.headline}),e.jsx("p",{className:"text-gray-600 leading-relaxed mb-6",children:s.text}),s.showButton&&s.buttonText&&e.jsx(la,{to:s.buttonLink||"#",className:"inline-block px-5 py-2.5 bg-gray-900 text-white rounded-lg font-medium hover:bg-gray-800 transition-colors",children:s.buttonText})]})]})})}case"cta-button":return e.jsx("section",{className:"bg-gray-50 px-6 py-16",children:e.jsxs("div",{className:`max-w-2xl mx-auto text-${s.alignment||"center"}`,children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-3",children:s.headline}),s.subtitle&&e.jsx("p",{className:"text-gray-500 text-lg mb-6",children:s.subtitle}),e.jsx(la,{to:s.buttonLink||"/contact",className:`inline-block px-8 py-3 rounded-lg font-semibold text-lg transition-colors ${s.style==="outline"?"border-2 border-gray-900 text-gray-900 hover:bg-gray-900 hover:text-white":"bg-gray-900 text-white hover:bg-gray-800"}`,children:s.buttonText})]})});case"testimonials":return e.jsx("section",{className:"px-6 py-16 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10",children:s.headline}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:(s.items||[]).map((r,n)=>e.jsxs("div",{className:"bg-gray-50 rounded-2xl p-6 border border-gray-100",children:[e.jsx("div",{className:"flex gap-0.5 mb-3",children:Array.from({length:r.rating||5}).map((a,o)=>e.jsx(ea,{className:"h-4 w-4 fill-amber-400 text-amber-400"},o))}),e.jsxs("p",{className:"text-gray-700 text-sm leading-relaxed mb-4",children:['"',r.text,'"']}),e.jsxs("p",{className:"text-sm font-semibold text-gray-900",children:["— ",r.name]})]},n))})]})});case"faq-accordion":return e.jsxs("section",{className:"px-6 py-16 max-w-3xl mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10",children:s.headline}),e.jsx("div",{className:"space-y-3",children:(s.items||[]).map((r,n)=>e.jsx(TTs,{question:r.question,answer:r.answer},n))})]});case"photo-gallery":return e.jsxs("section",{className:"px-6 py-16 max-w-6xl mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10",children:s.headline}),e.jsx("div",{className:`grid grid-cols-2 md:grid-cols-${s.columns||3} gap-4`,children:(s.images||[]).map((r,n)=>e.jsxs("div",{className:"rounded-xl overflow-hidden bg-gray-100 aspect-square",children:[e.jsx("img",{src:r.url,alt:r.caption||"",className:"w-full h-full object-cover"}),r.caption&&e.jsx("p",{className:"text-xs text-gray-500 text-center mt-1 pb-1",children:r.caption})]},n))})]});case"video-embed":{const r=ATs(s.videoUrl||"");return e.jsxs("section",{className:"px-6 py-16 max-w-4xl mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-8",children:s.headline}),r?e.jsx("div",{className:"relative w-full aspect-video rounded-2xl overflow-hidden bg-gray-900",children:e.jsx("iframe",{src:r,className:"absolute inset-0 w-full h-full",allowFullScreen:!0,allow:"autoplay; encrypted-media"})}):e.jsx("div",{className:"aspect-video bg-gray-100 rounded-2xl flex items-center justify-center text-gray-400",children:"Paste a YouTube or Vimeo URL"})]})}case"contact-form":return e.jsx("section",{className:"px-6 py-16 bg-gray-50",children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-2",children:s.headline}),s.subtitle&&e.jsx("p",{className:"text-gray-500 text-center mb-8",children:s.subtitle}),e.jsxs("form",{className:"space-y-4",onSubmit:r=>r.preventDefault(),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("input",{className:"w-full px-4 py-3 rounded-lg border border-gray-200 text-sm",placeholder:"First Name"}),e.jsx("input",{className:"w-full px-4 py-3 rounded-lg border border-gray-200 text-sm",placeholder:"Last Name"})]}),e.jsx("input",{className:"w-full px-4 py-3 rounded-lg border border-gray-200 text-sm",placeholder:"Email",type:"email"}),s.showPhone&&e.jsx("input",{className:"w-full px-4 py-3 rounded-lg border border-gray-200 text-sm",placeholder:"Phone (optional)"}),s.showMessage&&e.jsx("textarea",{className:"w-full px-4 py-3 rounded-lg border border-gray-200 text-sm resize-none",rows:4,placeholder:"Message"}),e.jsx("button",{className:"w-full py-3 bg-gray-900 text-white rounded-lg font-semibold hover:bg-gray-800 transition-colors",children:s.buttonText||"Send Message"})]})]})});case"stats-row":return e.jsx("section",{className:"px-6 py-16 bg-gray-900 text-white",children:e.jsx("div",{className:"max-w-5xl mx-auto grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-8 text-center",children:(s.items||[]).map((r,n)=>e.jsxs("div",{children:[e.jsx("p",{className:"text-4xl font-bold mb-1",children:r.value}),e.jsx("p",{className:"text-sm text-gray-400 uppercase tracking-wider",children:r.label})]},n))})});case"divider":return e.jsxs("div",{style:{height:s.height||40},className:"flex items-center justify-center px-6",children:[s.style==="line"&&e.jsx("hr",{className:"w-full max-w-4xl border-gray-200"}),s.style==="dots"&&e.jsx("div",{className:"flex gap-2",children:[1,2,3].map(r=>e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300"},r))})]});case"card-grid":return e.jsxs("section",{className:"px-6 py-16 max-w-6xl mx-auto",children:[s.headline&&e.jsx("h2",{className:"text-3xl font-bold text-gray-900 text-center mb-10",children:s.headline}),e.jsx("div",{className:`grid grid-cols-1 md:grid-cols-${s.columns||3} gap-6`,children:(s.cards||[]).map((r,n)=>e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden hover:shadow-lg transition-shadow",children:[r.imageUrl&&e.jsx("div",{className:"aspect-[16/10] bg-gray-100",children:e.jsx("img",{src:r.imageUrl,alt:r.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:r.title}),e.jsx("p",{className:"text-sm text-gray-500",children:r.description})]})]},n))})]});case"html-code":return s.code?e.jsx("section",{className:"px-6 py-8 max-w-6xl mx-auto",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:s.code}})}):null;default:return null}}function TTs({question:t,answer:s}){const[r,n]=k.useState(!1);return e.jsxs("div",{className:"border border-gray-200 rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(!r),className:"w-full flex items-center justify-between px-5 py-4 text-left hover:bg-gray-50 transition-colors",children:[e.jsx("span",{className:"font-medium text-gray-900",children:t}),e.jsx(Ji,{className:`h-4 w-4 text-gray-400 transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsx("div",{className:"px-5 pb-4 text-sm text-gray-600 leading-relaxed",children:s})]})}function ATs(t){if(!t)return null;const s=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)/);if(s)return`https://www.youtube.com/embed/${s[1]}`;const r=t.match(/vimeo\.com\/(\d+)/);return r?`https://player.vimeo.com/video/${r[1]}`:null}function ETs({siteConfig:t}){const{pageSlug:s}=ao(),{data:r,isLoading:n}=pt({queryKey:["lead-site-custom-page",t.id,s],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_pages").select("*").eq("site_id",t.id).eq("slug",s).eq("is_published",!0).maybeSingle();if(l)throw l;return o},enabled:!!s});if(n)return 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"})});if(!r)return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This page doesn't exist or hasn't been published yet."})]})});const a=r.page_blocks||[];return e.jsxs(e.Fragment,{children:[e.jsxs(Pl,{children:[e.jsxs("title",{children:[r.meta_title||r.title," | ",t.siteTitle]}),r.meta_description&&e.jsx("meta",{name:"description",content:r.meta_description})]}),e.jsx("div",{className:"min-h-[60vh]",children:e.jsx(CTs,{blocks:a})})]})}function PTs(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=X5s();if(r)return 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..."})]})});if(n||!t)return 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."})]})});const a=(s==null?void 0:s.themeTier)==="luxury",o=(s==null?void 0:s.themeTier)==="land-ranch",l=o?mMs:a?uMs:cMs,i=o?e.jsx(BMs,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(jMs,{siteConfig:t,themeConfig:s??void 0}):e.jsx(fMs,{siteConfig:t,themeConfig:s??void 0});return e.jsx(J5s,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsxs(Coe,{children:[e.jsx(xs,{path:"/",element:i}),e.jsx(xs,{path:"/search",element:a?e.jsx(oTs,{siteConfig:t}):e.jsx(aTs,{siteConfig:t})}),e.jsx(xs,{path:"/listing/:mlsNumber",element:a?e.jsx(cTs,{siteConfig:t}):e.jsx(lTs,{siteConfig:t})}),e.jsx(xs,{path:"/about",element:a?e.jsx(uTs,{siteConfig:t}):e.jsx(dTs,{siteConfig:t})}),e.jsx(xs,{path:"/contact",element:a?e.jsx(mTs,{siteConfig:t}):e.jsx(hTs,{siteConfig:t})}),e.jsx(xs,{path:"/account",element:e.jsx(pTs,{siteConfig:t})}),e.jsx(xs,{path:"/blog",element:e.jsx(S9e,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/blog/:slug",element:e.jsx(S9e,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/sell",element:e.jsx(xTs,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(xs,{path:"/community",element:e.jsx(fTs,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/p/:pageSlug",element:e.jsx(ETs,{siteConfig:t})}),e.jsx(xs,{path:"/*",element:e.jsx(ITs,{siteConfig:t})})]})})})}function ITs({siteConfig:t}){const r=hc().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(STs,{siteConfig:t,citySlugOverride:r[1]}):null}const LTs=({team:t,onSelect:s})=>{const{data:r}=pt({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(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Et,{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(Lt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(vr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(Ye,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(ur,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(De,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Cn,{className:"h-6 w-6",children:[e.jsx(Wa,{src:r.leaderProfile.avatar_url||""}),e.jsx(Mn,{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(zm,{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(ou,{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(Ye,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(Ye,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(Ye,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},DTs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Fs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:c,isLoading:u,createTeam:m,updateTeam:f,deleteTeam:g,addMember:y,removeMember:_,updateMemberRole:w}=L3(i),[j,N]=k.useState(!1),[S,M]=k.useState(null),{data:I}=pt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:q,error:$}=await H.from("brokerages").select("id, name").order("name");if($)throw $;return q||[]},enabled:s}),{data:P}=pt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:q,error:$}=await H.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if($)throw $;return q||[]},enabled:!!l}),O=async q=>{const $=q.brokerage_id||l||null,z=await m.mutateAsync({name:q.name,brokerage_id:$,description:q.description});if(q.leaderId&&q.leaderId!=="none"&&await y.mutateAsync({team_id:z.id,user_id:q.leaderId,role:"team_leader"}),q.memberIds)for(const V of q.memberIds)await y.mutateAsync({team_id:z.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(ur,{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(G,{onClick:()=>N(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Rtt,{open:j,onOpenChange:N,onCreateTeam:O,isCreating:m.isPending,brokerageAgents:P||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(q=>e.jsx(Pe,{children:e.jsxs(De,{className:"p-6",children:[e.jsx(ws,{className:"h-5 w-32 mb-3"}),e.jsx(ws,{className:"h-4 w-48 mb-4"}),e.jsx(ws,{className:"h-8 w-full"})]})},q))}),!u&&c.length===0&&!S&&e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ur,{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(G,{onClick:()=>N(!0),children:[e.jsx(qs,{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(LTs,{team:q,onSelect:()=>M(q)},q.id))}),S&&e.jsx(Ott,{team:S,brokerageAgents:P||[],onBack:()=>M(null),onUpdate:q=>f.mutateAsync({id:S.id,...q}).then($=>M($)),onAddMember:(q,$)=>y.mutateAsync({team_id:S.id,user_id:q,role:$}),onRemoveMember:q=>_.mutateAsync({team_id:S.id,member_id:q}),onUpdateRole:(q,$)=>w.mutateAsync({team_id:S.id,member_id:q,role:$}),onDeleteTeam:()=>g.mutate(S.id),isUpdating:f.isPending,isAddingMember:y.isPending})]})})},OTs=()=>{const{data:t,isLoading:s}=Gx(),{useTeamMembers:r}=L3(),{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(ws,{className:"h-8 w-48"}),e.jsx(ws,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ms,{title:"My Team",description:"Your team",children:e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ur,{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(Ye,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(zm,{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(ga,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap",children:[e.jsx(ss,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ss,{value:"contacts",children:[e.jsx(iS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ss,{value:"lead-pond",children:[e.jsx(ey,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ss,{value:"shared-assets",children:[e.jsx(Bm,{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(ws,{className:"h-16 w-full"},l))}):n.map(l=>{var i,c,u,m;return e.jsx(Pe,{children:e.jsxs(De,{className:"flex items-center gap-3 p-4",children:[e.jsxs(Cn,{className:"h-10 w-10",children:[e.jsx(Wa,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(Mn,{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:(m=l.profile)==null?void 0:m.email})]}),l.role==="team_leader"?e.jsxs(Ye,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(zm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Ye,{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(Qke,{})}),o.lead_pond_enabled&&e.jsx(bs,{value:"lead-pond",className:"space-y-4",children:e.jsx(Xke,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(bs,{value:"shared-assets",className:"space-y-4",children:e.jsx(Dtt,{teamId:t.teamId})})]})]})})};function RTs(){const{user:t}=Fs(),s=Qt(),r=pt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await H.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return j},enabled:!!t}),n=pt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await H.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return j},enabled:!!t}),a=pt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:j,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 j},enabled:!!t}),o=pt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await H.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return j},enabled:!!t}),l=pt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,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 j},enabled:!!t}),i=Tt({mutationFn:async()=>{const{data:j,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 I=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:P}=await H.from("agent_availability_slots").insert(I);if(P)throw P;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:j=>me.error(j.message)}),c=Tt({mutationFn:async j=>{const{error:N}=await H.from("agent_booking_settings").update(j).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:j=>me.error(j.message)}),u=Tt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await H.from("agent_booking_types").update(N).eq("id",j.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:j=>me.error(j.message)}),m=Tt({mutationFn:async j=>{const{error:N}=await H.from("agent_booking_types").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:j=>me.error(j.message)}),f=Tt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await H.from("agent_availability_slots").update(N).eq("id",j.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:j=>me.error(j.message)}),g=Tt({mutationFn:async j=>{const{error:N}=await H.from("agent_availability_slots").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>me.error(j.message)}),y=Tt({mutationFn:async j=>{const{error:N}=await H.from("agent_blocked_dates").insert({...j,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:j=>me.error(j.message)}),_=Tt({mutationFn:async j=>{const{error:N}=await H.from("agent_blocked_dates").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:j=>me.error(j.message)}),w=Tt({mutationFn:async({id:j,reason:N})=>{const{error:S}=await H.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",j);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:j=>me.error(j.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:c,upsertBookingType:u,deleteBookingType:m,upsertAvailability:f,deleteAvailability:g,addBlockedDate:y,removeBlockedDate:_,cancelBooking:w}}const C9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function FTs({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=m=>{a({...m}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Lt,{children:"Booking Types"}),e.jsx(vr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(G,{onClick:i,size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(De,{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(m=>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:m.color+"20"},children:C9e[m.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:m.name}),!m.is_active&&e.jsx(Ye,{variant:"secondary",className:"text-xs",children:"Inactive"}),m.qualification_enabled&&e.jsxs(Ye,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(PL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mn,{className:"h-3 w-3"}),m.duration_minutes," min",m.description&&e.jsxs("span",{children:["· ",m.description.slice(0,60),m.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>c(m),children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>r(m.id),className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]})]},m.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(js,{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(ye,{children:"Name"}),e.jsx(Le,{value:n.name||"",onChange:m=>a({...n,name:m.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:n.description||"",onChange:m=>a({...n,description:m.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(ye,{children:"Duration (minutes)"}),e.jsx(Le,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:m=>a({...n,duration_minutes:parseInt(m.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:m=>a({...n,color:m.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(Le,{value:n.color||"#3B82F6",onChange:m=>a({...n,color:m.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(C9e).map(([m,f])=>e.jsx("button",{onClick:()=>a({...n,icon:m}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===m?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},m))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Meeting Link Override (optional)"}),e.jsx(Le,{value:n.meeting_link_override||"",onChange:m=>a({...n,meeting_link_override:m.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(ye,{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:m=>a({...n,qualification_enabled:m})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Active"}),e.jsx(qr,{checked:n.is_active??!0,onCheckedChange:m=>a({...n,is_active:m})})]})]}),e.jsxs(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{onClick:u,children:"Save"})]})]})})]})}const M9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function zTs({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=M9e.map((f,g)=>t.filter(y=>y.day_of_week===g)),m=()=>{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(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(vr,{children:"Set your available hours for each day"})]}),e.jsx(De,{className:"space-y-2",children:M9e.map((f,g)=>{const y=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:[y.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):y.map(_=>{var w,j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=_.start_time)==null?void 0:w.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(Le,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=_.end_time)==null?void 0:j.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(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(_.id),children:e.jsx(kr,{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(Le,{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(Le,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:_=>c(_.target.value)}),e.jsx(G,{size:"sm",className:"h-8",onClick:m,children:"Add"}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(G,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(g),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const BTs={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 $Ts({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(Zi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(Ye,{className:`text-xs ${BTs[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(Fd,{className:"h-3.5 w-3.5"}),ds(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{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(rr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(Ye,{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(G,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(Nc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsx(Lt,{children:"Upcoming Bookings"}),e.jsxs(vr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(De,{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(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{children:"Past & Cancelled"})}),e.jsx(De,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function qTs({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(Pe,{children:[e.jsxs(Et,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(yL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(vr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(De,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(Le,{type:"date",value:o,onChange:m=>l(m.target.value),className:"w-40"}),e.jsx(Le,{placeholder:"Reason (optional)",value:i,onChange:m=>c(m.target.value),className:"flex-1"}),e.jsx(G,{size:"sm",onClick:u,children:"Add"}),e.jsx(G,{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(m=>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:ds(new Date(m.blocked_date+"T00:00:00"),"MMM d, yyyy")}),m.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",m.reason,")"]}),e.jsx("button",{onClick:()=>r(m.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Er,{className:"h-3.5 w-3.5"})})]},m.id))})]})]})}function UTs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:c,deleteBookingType:u,upsertAvailability:m,deleteAvailability:f,addBlockedDate:g,removeBlockedDate:y,cancelBooking:_}=RTs(),[w,j]=k.useState(""),[N,S]=k.useState(15);w||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(Fd,{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(G,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(M),me.success("Booking link copied!")},children:[e.jsx(yi,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(G,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(qr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(ga,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"types",children:"Booking Types"}),e.jsx(ss,{value:"availability",children:"Availability"}),e.jsx(ss,{value:"settings",children:"Settings"}),e.jsxs(ss,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(Ye,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(bs,{value:"types",children:e.jsx(FTs,{types:s,onSave:I=>c.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(bs,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(zTs,{slots:r,onSave:I=>m.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx(qTs,{blockedDates:n,onAdd:I=>g.mutate(I),onRemove:I=>y.mutate(I)})]})}),e.jsx(bs,{value:"settings",children:e.jsxs(Pe,{children:[e.jsxs(Et,{children:[e.jsxs(Lt,{className:"flex items-center gap-2",children:[e.jsx(GL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(vr,{children:"Configure your booking page defaults"})]}),e.jsxs(De,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(G,{variant:"outline",size:"sm",onClick:()=>{M&&(navigator.clipboard.writeText(M),me.success("Copied!"))},children:e.jsx(yi,{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(ye,{htmlFor:"meeting-link",children:[e.jsx(pl,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(Le,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:I=>i.mutate({meeting_link:I.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:I=>i.mutate({buffer_minutes:parseInt(I.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:I=>i.mutate({min_notice_hours:parseInt(I.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:I=>i.mutate({max_advance_days:parseInt(I.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(bs,{value:"bookings",children:e.jsx($Ts,{bookings:a,onCancel:I=>_.mutate({id:I})})})]})]})}):e.jsx(Ms,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 md:p-8 space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center",children:e.jsx(Fd,{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(Pe,{children:e.jsxs(De,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(I=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:I.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.desc})]})]},I.title))}),e.jsx(Qo,{}),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(G,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(nn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const T9e=[{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 VTs(){const{user:t}=Fs(),s=Fa(),{toast:r}=Ra(),n=ar(),a=Qt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,m]=k.useState(null),[f,g]=k.useState({title:"",description:"",page_type:"lead_capture"}),{data:y=[],isLoading:_}=pt({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}),w=Tt({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(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:P,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:I?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:I?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const q=HTs(f.page_type);if(q.length>0){const{error:$}=await H.from("landing_page_fields").insert(q.map((z,V)=>({...z,page_id:P.id,sort_order:V})));if($)throw $}return P},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"})}),j=Tt({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(G,{onClick:()=>l(!0),children:[e.jsx(qs,{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"})}):y.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(wn,{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(G,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:y.map(S=>{var M;return e.jsx(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(De,{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(Ye,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:((M=T9e.find(I=>I.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(Tn,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{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(G,{size:"sm",variant:"outline",onClick:()=>m(N(S.slug)),children:e.jsx(b0,{className:"h-3.5 w-3.5"})}),e.jsx(G,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(S.slug)),r({title:"Link copied!"})},children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(G,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:N(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(du,{children:[e.jsx(uu,{asChild:!0,children:e.jsx(G,{size:"sm",variant:"ghost",children:e.jsx(vx,{className:"h-4 w-4"})})}),e.jsxs(Ud,{align:"end",children:[e.jsxs(La,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx(Pa,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(La,{onClick:()=>c(S.id),className:"text-destructive",children:[e.jsx(kr,{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(js,{children:e.jsx(vs,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Page Title"}),e.jsx(Le,{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(ye,{children:"Description (optional)"}),e.jsx(Tr,{value:f.description,onChange:S=>g(M=>({...M,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Page Template"}),e.jsxs(Rs,{value:f.page_type,onValueChange:S=>g(M=>({...M,page_type:S})),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:T9e.map(S=>e.jsx(ft,{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(Rn,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(G,{onClick:()=>w.mutate(),disabled:!f.title.trim()||w.isPending,children:w.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(Tc,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(nc,{children:[e.jsxs(ac,{children:[e.jsx(oc,{children:"Delete Landing Page?"}),e.jsx(lc,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(ic,{children:[e.jsx(cc,{children:"Cancel"}),e.jsx(zl,{onClick:()=>i&&j.mutate(i),children:"Delete"})]})]})}),e.jsx(fs,{open:!!u,onOpenChange:()=>m(null),children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(qR,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(G,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function HTs(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 GTs=[{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 WTs(){const{pageId:t}=ao(),s=ar(),{user:r}=Fs(),n=Fa(),{toast:a}=Ra(),o=Qt(),[l,i]=k.useState(null),[c,u]=k.useState(!1),{data:m,isLoading:f}=pt({queryKey:["landing-page",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_pages").select("*").eq("id",t).single();if(re)throw re;return ne},enabled:!!t}),{data:g=[],isLoading:y}=pt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(re)throw re;return ne},enabled:!!t}),{data:_=[]}=pt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(re)throw re;return ne},enabled:!!t}),{data:w=[]}=pt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ne,error:re}=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(re)throw re;return ne},enabled:!!r&&((m==null?void 0:m.page_type)==="just_listed"||(m==null?void 0:m.page_type)==="just_sold")}),[j,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(()=>{m&&N({title:m.title,hero_headline:m.hero_headline,hero_subtext:m.hero_subtext||"",hero_image_url:m.hero_image_url,logo_url:m.logo_url,primary_color:m.primary_color,accent_color:m.accent_color,agent_name:m.agent_name||"",agent_phone:m.agent_phone||"",agent_email:m.agent_email||"",agent_photo_url:m.agent_photo_url,success_message:m.success_message||"Thank you! We'll be in touch soon.",is_published:m.is_published,description:m.description||"",lead_magnet_file_url:m.lead_magnet_file_url||null,lead_magnet_file_name:m.lead_magnet_file_name||null,lead_magnet_external_url:m.lead_magnet_external_url||null,listing_id:m.listing_id||null,property_address:m.property_address||"",property_price:m.property_price||"",property_beds:m.property_beds||"",property_baths:m.property_baths||"",property_sqft:m.property_sqft||"",property_description:m.property_description||"",property_photos:Array.isArray(m.property_photos)?m.property_photos:[],property_status:m.property_status||"just_listed"})},[m]),k.useEffect(()=>{g.length>0&&M(g.map(ne=>({id:ne.id,field_type:ne.field_type,label:ne.label,placeholder:ne.placeholder,is_required:ne.is_required,options:typeof ne.options=="string"?ne.options:ne.options?JSON.stringify(ne.options):null,sort_order:ne.sort_order})))},[g]);const I=Tt({mutationFn:async()=>{const{error:ne}=await H.from("landing_pages").update({title:j.title,hero_headline:j.hero_headline,hero_subtext:j.hero_subtext||null,hero_image_url:j.hero_image_url,logo_url:j.logo_url,primary_color:j.primary_color,accent_color:j.accent_color,agent_name:j.agent_name||null,agent_phone:j.agent_phone||null,agent_email:j.agent_email||null,agent_photo_url:j.agent_photo_url,success_message:j.success_message,is_published:j.is_published,description:j.description||null,lead_magnet_file_url:j.lead_magnet_file_url,lead_magnet_file_name:j.lead_magnet_file_name,lead_magnet_external_url:j.lead_magnet_external_url,listing_id:j.listing_id,property_address:j.property_address||null,property_price:j.property_price||null,property_beds:j.property_beds||null,property_baths:j.property_baths||null,property_sqft:j.property_sqft||null,property_description:j.property_description||null,property_photos:j.property_photos,property_status:j.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ne)throw ne;if(await H.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:re}=await H.from("landing_page_fields").insert(S.map((oe,he)=>({page_id:t,field_type:oe.field_type,label:oe.label,placeholder:oe.placeholder||null,is_required:oe.is_required,options:oe.options?JSON.parse(oe.options):null,sort_order:he})));if(re)throw re}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ne=>a({title:"Error",description:ne.message,variant:"destructive"})}),P=async(ne,re)=>{const oe=ne.name.split(".").pop(),he=`landing-pages/${r.id}/${re}-${Date.now()}.${oe}`,{error:xe}=await H.storage.from("recruit-landing").upload(he,ne);if(xe)throw xe;const{data:{publicUrl:ue}}=H.storage.from("recruit-landing").getPublicUrl(he);return ue},O=async(ne,re)=>{var he;const oe=(he=ne.target.files)==null?void 0:he[0];if(oe){i(re);try{const xe=await P(oe,re);N(ue=>({...ue,[re]:xe})),a({title:"Image uploaded!"})}catch(xe){a({title:"Upload failed",description:xe.message,variant:"destructive"})}finally{i(null)}}},q=async ne=>{var oe;const re=(oe=ne.target.files)==null?void 0:oe[0];if(re){i("lead_magnet");try{const he=await P(re,"lead-magnet");N(xe=>({...xe,lead_magnet_file_url:he,lead_magnet_file_name:re.name})),a({title:"File uploaded!"})}catch(he){a({title:"Upload failed",description:he.message,variant:"destructive"})}finally{i(null)}}},$=async ne=>{const re=ne.target.files;if(!(!re||re.length===0)){i("property_photos");try{const oe=[];for(const he of Array.from(re)){const xe=await P(he,"property-photo");oe.push(xe)}N(he=>({...he,property_photos:[...he.property_photos,...oe]})),a({title:`${oe.length} photo(s) uploaded!`})}catch(oe){a({title:"Upload failed",description:oe.message,variant:"destructive"})}finally{i(null)}}},z=async ne=>{const re=w.find(he=>he.id===ne);if(!re)return;const{data:oe}=await H.from("listing_photos").select("photo_url").eq("listing_id",ne).order("sort_order");N(he=>({...he,listing_id:ne,property_address:re.property_address||`${re.city}, ${re.state}`,property_price:re.price?`$${re.price.toLocaleString()}`:"",property_beds:re.bedrooms?String(re.bedrooms):"",property_baths:re.bathrooms?String(re.bathrooms):"",property_sqft:re.square_footage?re.square_footage.toLocaleString():"",property_description:re.description||"",property_photos:(oe==null?void 0:oe.map(xe=>xe.photo_url))||he.property_photos})),a({title:"Listing data imported!"})},V=()=>{M(ne=>[...ne,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ne.length}])},X=(ne,re)=>{M(oe=>oe.map((he,xe)=>xe===ne?{...he,...re}:he))},Y=ne=>{M(re=>re.filter((oe,he)=>he!==ne))},J=m?`https://pages.relevelup.com/${m.slug}`:"",Q=(m==null?void 0:m.page_type)==="lead_magnet",ce=(m==null?void 0:m.page_type)==="just_listed"||(m==null?void 0:m.page_type)==="just_sold";return f||y?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"})})}):m?e.jsxs(Ms,{title:j.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Ga,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:j.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(Ye,{variant:j.is_published?"default":"secondary",className:"text-[10px]",children:j.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",m.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ur,{className:"h-3 w-3"})," ",_.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(G,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(b0,{className:"h-3.5 w-3.5"})}),e.jsxs(G,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(J),a({title:"Link copied!"})},children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(G,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(G,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ga,{defaultValue:"design",children:[e.jsxs(fa,{children:[e.jsx(ss,{value:"design",children:"Design"}),Q&&e.jsx(ss,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(ss,{value:"property",children:"Property Details"}),e.jsxs(ss,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(ss,{value:"submissions",children:["Submissions (",_.length,")"]}),e.jsx(ss,{value:"settings",children:"Settings"})]}),e.jsxs(bs,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Page Details"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Page Title (internal)"}),e.jsx(Le,{value:j.title,onChange:ne=>N(re=>({...re,title:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description (internal)"}),e.jsx(Le,{value:j.description,onChange:ne=>N(re=>({...re,description:ne.target.value}))})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Hero Section"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Headline"}),e.jsx(Le,{value:j.hero_headline,onChange:ne=>N(re=>({...re,hero_headline:ne.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Subtext"}),e.jsx(Tr,{value:j.hero_subtext,onChange:ne=>N(re=>({...re,hero_subtext:ne.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.hero_image_url&&e.jsx("img",{src:j.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(ci,{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:ne=>O(ne,"hero_image_url")})]}),j.hero_image_url&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>N(ne=>({...ne,hero_image_url:null})),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Branding"})}),e.jsxs(De,{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(ye,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.logo_url&&e.jsx("img",{src:j.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>O(ne,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.agent_photo_url&&e.jsx("img",{src:j.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>O(ne,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.primary_color,onChange:ne=>N(re=>({...re,primary_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:j.primary_color,onChange:ne=>N(re=>({...re,primary_color:ne.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.accent_color,onChange:ne=>N(re=>({...re,accent_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:j.accent_color,onChange:ne=>N(re=>({...re,accent_color:ne.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(De,{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(ye,{children:"Name"}),e.jsx(Le,{value:j.agent_name,onChange:ne=>N(re=>({...re,agent_name:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(Le,{value:j.agent_phone,onChange:ne=>N(re=>({...re,agent_phone:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Email"}),e.jsx(Le,{value:j.agent_email,onChange:ne=>N(re=>({...re,agent_email:ne.target.value}))})]})]})})]})]}),Q&&e.jsx(bs,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(De,{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(ye,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.lead_magnet_file_name&&e.jsxs(Ye,{variant:"outline",className:"gap-1",children:[e.jsx(vi,{className:"h-3 w-3"})," ",j.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(ci,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:q})]}),j.lead_magnet_file_url&&e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>N(ne=>({...ne,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(kr,{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(ye,{className:"flex items-center gap-1",children:[e.jsx(pl,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Le,{value:j.lead_magnet_external_url||"",onChange:ne=>N(re=>({...re,lead_magnet_external_url:ne.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"})]})]})]})}),ce&&e.jsxs(bs,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(De,{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(Rs,{value:j.listing_id||"",onValueChange:ne=>z(ne),children:[e.jsx(Ls,{children:e.jsx($s,{placeholder:"Select a listing to import..."})}),e.jsx(Ds,{children:w.map(ne=>{var re;return e.jsxs(ft,{value:ne.id,children:[ne.property_address||`${ne.city}, ${ne.state}`," — $",(re=ne.price)==null?void 0:re.toLocaleString()]},ne.id)})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Property Information"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Property Address"}),e.jsx(Le,{value:j.property_address,onChange:ne=>N(re=>({...re,property_address:ne.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(ye,{children:"Price"}),e.jsx(Le,{value:j.property_price,onChange:ne=>N(re=>({...re,property_price:ne.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Beds"}),e.jsx(Le,{value:j.property_beds,onChange:ne=>N(re=>({...re,property_beds:ne.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Baths"}),e.jsx(Le,{value:j.property_baths,onChange:ne=>N(re=>({...re,property_baths:ne.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Sq Ft"}),e.jsx(Le,{value:j.property_sqft,onChange:ne=>N(re=>({...re,property_sqft:ne.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Tr,{value:j.property_description,onChange:ne=>N(re=>({...re,property_description:ne.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Property Photos"})}),e.jsxs(De,{className:"space-y-4",children:[j.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:j.property_photos.map((ne,re)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ne,alt:`Property ${re+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(G,{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(oe=>({...oe,property_photos:oe.property_photos.filter((he,xe)=>xe!==re)})),children:e.jsx(kr,{className:"h-3 w-3"})})]},re))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(G,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(ci,{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:$})]})]})]})]}),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(G,{size:"sm",onClick:V,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Pe,{children:e.jsx(De,{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((ne,re)=>e.jsx(Pe,{children:e.jsx(De,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Eu,{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(ye,{className:"text-xs",children:"Field Type"}),e.jsxs(Rs,{value:ne.field_type,onValueChange:oe=>X(re,{field_type:oe}),children:[e.jsx(Ls,{children:e.jsx($s,{})}),e.jsx(Ds,{children:GTs.map(oe=>e.jsx(ft,{value:oe.value,children:oe.label},oe.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Label"}),e.jsx(Le,{value:ne.label,onChange:oe=>X(re,{label:oe.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Placeholder"}),e.jsx(Le,{value:ne.placeholder||"",onChange:oe=>X(re,{placeholder:oe.target.value}),placeholder:"Optional hint text"})]})]}),(ne.field_type==="select"||ne.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Le,{value:ne.options?(typeof ne.options=="string"?JSON.parse(ne.options):ne.options).join(", "):"",onChange:oe=>X(re,{options:JSON.stringify(oe.target.value.split(",").map(he=>he.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:ne.is_required,onCheckedChange:oe=>X(re,{is_required:oe})}),e.jsx(ye,{className:"text-xs",children:"Required"})]})]}),e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Y(re),children:e.jsx(kr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},re))})]}),e.jsx(bs,{value:"submissions",className:"mt-4",children:_.length===0?e.jsx(Pe,{children:e.jsx(De,{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(ne=>e.jsx(Pe,{children:e.jsx(De,{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:ne.contact_name||"Anonymous"}),ne.synced_to_crm&&e.jsx(Ye,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ne.contact_email&&e.jsx("span",{className:"mr-3",children:ne.contact_email}),ne.contact_phone&&e.jsx("span",{children:ne.contact_phone})]}),ne.answers&&typeof ne.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ne.answers).map(([re,oe])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[re,":"]})," ",e.jsx("span",{children:String(oe)})]},re))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ne.created_at).toLocaleDateString()})]})})},ne.id))})}),e.jsxs(bs,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Publishing"})}),e.jsxs(De,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(qr,{checked:j.is_published,onCheckedChange:ne=>N(re=>({...re,is_published:ne}))})]}),j.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:J})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Et,{children:e.jsx(Lt,{className:"text-base",children:"Thank You Message"})}),e.jsx(De,{children:e.jsx(Tr,{value:j.success_message,onChange:ne=>N(re=>({...re,success_message:ne.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(js,{children:e.jsx(vs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(qR,{value:J,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:J})]})]})})]}):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(G,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function A9e({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(mL,{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(hL,{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(v0,{className:"h-3 w-3"}),"0%"]})}const KTs={Phone:Nn,MessageSquare:Ki,Mail:rr,Gift:bo,PenTool:X_,Video:An},E9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function ZTs(){const t=ar(),{contactsWithScores:s,stats:r}=zue(),{data:n}=aR(365),{data:a}=VNe(),{data:o}=nR(),l=$Ne(),i=k.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const M=new Date,I=Bc(M),P=px(M),O=Bc(N4(M,1)),q=px(N4(M,1)),$=n.filter(X=>$g(new Date(X.completed_at),{start:I,end:P})).length,z=n.filter(X=>$g(new Date(X.completed_at),{start:O,end:q})).length,V=z>0?Math.round(($-z)/z*100):$>0?100:0;return{touchesThisMonth:$,touchesLastMonth:z,touchTrend:V}},[n]),c=k.useMemo(()=>{if(!n)return 0;const M=new Date,I=Bc(M),P=px(M);return new Set(n.filter(O=>$g(new Date(O.completed_at),{start:I,end:P})).map(O=>O.contact_id)).size},[n]),u=k.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const M=new Date,I=Bc(M),P=px(M),O=a.filter(q=>q.close_date&&$g(Fl(q.close_date),{start:I,end:P}));return{closedThisMonth:O.length,totalGCI:O.reduce((q,$)=>q+(Number($.commission_amount)||0),0)}},[a]),m=k.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const M=new Date,I=Bc(M),P=Bc(N4(M,1)),O=px(N4(M,1)),q=s.filter(V=>new Date(V.created_at)>=I).length,$=s.filter(V=>$g(new Date(V.created_at),{start:P,end:O})).length,z=$>0?Math.round((q-$)/$*100):q>0?100:0;return{newThisMonth:q,newLastMonth:$,trend:z}},[s]),f=k.useMemo(()=>{if(!n||!o)return[];const M=new Date,I=Bc(M),P=px(M),O=n.filter(z=>$g(new Date(z.completed_at),{start:I,end:P})),q={};O.forEach(z=>{const V=z.action_type_id;q[V]=(q[V]||0)+1});const $=O.length||1;return o.filter(z=>q[z.id]).map(z=>({id:z.id,name:z.name,icon:z.icon,count:q[z.id]||0,percent:Math.round((q[z.id]||0)/$*100)})).sort((z,V)=>V.count-z.count)},[n,o]),g=k.useMemo(()=>[...s].filter(M=>M.relationshipScore.status==="at-risk"||M.relationshipScore.status==="cooling").sort((M,I)=>{const P=M.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-P}).slice(0,5),[s]),y=k.useMemo(()=>{if(!n)return[];const M=new Date,I=Bc(M),P=px(M),O=new Set(n.filter(q=>$g(new Date(q.completed_at),{start:I,end:P})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&O.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,$)=>$.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 X=new Date(V.completed_at);return`${X.getFullYear()}-${X.getMonth()}-${X.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let P=0,O=new Date(I);for(;M.has(`${O.getFullYear()}-${O.getMonth()}-${O.getDate()}`);)P++,O.setDate(O.getDate()-1);let q=0,$=0;if(Array.from(M).sort().length>0){const V=n.map(X=>{const Y=new Date(X.completed_at);return Y.setHours(0,0,0,0),Y.getTime()}).filter((X,Y,J)=>J.indexOf(X)===Y).sort((X,Y)=>X-Y);$=1;for(let X=1;X[...s].sort((M,I)=>M.relationshipScore.score-I.relationshipScore.score),[s]),j=w.filter(M=>M.relationshipScore.status==="warm"),N=w.filter(M=>M.relationshipScore.status==="cooling"),S=w.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:[ds(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(rh,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Ja,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Mh,{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(A9e,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ur,{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(Pe,{children:e.jsxs(De,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Bo,{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:m.newThisMonth}),e.jsx(A9e,{value:m.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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(Xh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(De,{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(qi,{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(_o,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(rh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(De,{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(Pe,{children:[e.jsx(Et,{className:"pb-2",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(Mh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(De,{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,I)=>{const P=KTs[M.icon||""]||Mh;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(P,{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(qi,{value:M.percent,className:Pt("h-1.5 bg-muted [&>div]:",E9e[I%E9e.length])})]},M.id)})})})]})]}),g.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-primary",children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(Ye,{variant:"secondary",children:[g.length," contacts"]})]}),e.jsx(vr,{children:"These relationships need attention the most"})]}),e.jsx(De,{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(R8,{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(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${M.phone}`)},children:e.jsx(Nn,{className:"h-4 w-4"})}),M.email&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${M.email}`)},children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]})]},M.id))})})]}),y.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs(Lt,{className:"text-lg flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(vr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(De,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:y.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(Pe,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(De,{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(qi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Pe,{className:"border-l-4 border-l-amber-500",children:e.jsxs(De,{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(qi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Pe,{className:"border-l-4 border-l-red-500",children:e.jsxs(De,{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(qi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Pe,{children:e.jsx(De,{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(SL,{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(ga,{defaultValue:"at-risk",children:[e.jsxs(fa,{children:[e.jsxs(ss,{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(ss,{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(ss,{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:j}].map(({key:M,contacts:I})=>e.jsx(bs,{value:M,children:e.jsx(Pe,{children:e.jsx(De,{className:"p-0",children:I.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(jt,{children:"Score"}),e.jsx(jt,{className:"w-10"})]})}),e.jsx(qn,{children:I.slice(0,20).map(P=>e.jsxs(ks,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${P.id}`),children:[e.jsxs(ut,{className:"font-medium",children:[P.first_name," ",P.last_name]}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:P.relationshipScore.daysSinceTouch===null?"Never":P.relationshipScore.daysSinceTouch===0?"Today":`${P.relationshipScore.daysSinceTouch}d ago`}),e.jsx(ut,{className:"hidden md:table-cell",children:P.relationshipScore.touchCountLast12Months}),e.jsx(ut,{children:e.jsx(R8,{score:P.relationshipScore,showScore:!0})}),e.jsx(ut,{children:e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})})]},P.id))})]})})})},M))]})]})})}function mdt(){const{user:t}=Fs(),s=Qt(),{data:r,isLoading:n}=pt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:m}=await H.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(m)throw m;return u},enabled:!!(t!=null&&t.id)}),a=Tt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:m,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 m},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Connect page created!")},onError:u=>{var m;(m=u.message)!=null&&m.includes("duplicate")?me.error("That slug is already taken. Try another."):me.error("Failed to create page")}}),o=Tt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:m}=await H.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(m)throw m},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Page updated!")},onError:()=>me.error("Failed to update page")}),{data:l=[],isLoading:i}=pt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:m}=await H.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(m)throw m;return u},enabled:!!(t!=null&&t.id)}),c=Tt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:m,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=${m.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:c}}function YTs(){const{user:t}=Fs();return pt({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 QTs(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 JI=[{key:"email",label:"Missing Email",icon:rr,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:Nn,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:aa,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:Eh,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:xn,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:Lh,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function oM(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 XTs({contact:t,onClose:s}){const r=FNe(),[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=JI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(xE,{open:!0,onOpenChange:()=>s(),children:e.jsxs(P3,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(gE,{children:[e.jsxs(yE,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(xYe,{children:["Fill in missing fields to improve this contact's completeness (",oM(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(Ye,{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(ye,{className:"flex items-center gap-1.5",children:[e.jsx(rr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(Le,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(c=>({...c,email:i.target.value})),className:Pt(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(Le,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(c=>({...c,phone:i.target.value})),className:Pt(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(aa,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(Le,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(c=>({...c,address:i.target.value})),className:Pt(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Eh,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(Le,{type:"date",value:n.birthday,onChange:i=>a(c=>({...c,birthday:i.target.value})),className:Pt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(xn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Le,{type:"date",value:n.home_anniversary,onChange:i=>a(c=>({...c,home_anniversary:i.target.value})),className:Pt(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(G,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(Vc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(G,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Qye="Quick favor — can you update your info? 🙏",P9e=`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 JTs(){const t=ar(),{data:s,isLoading:r}=nm(),{data:n}=Rf(),{intakePage:a}=mdt(),{isGmailConnected:o,gmailEmail:l}=Ff(),{data:i}=YTs(),[c,u]=k.useState("blocked"),[m,f]=k.useState("all"),[g,y]=k.useState(null),[_,w]=k.useState(!1),[j,N]=k.useState(!1),[S,M]=k.useState(null),[I,P]=k.useState([]),[O,q]=k.useState(""),[$,z]=k.useState(""),V=k.useMemo(()=>s?m==="all"?s:s.filter(Me=>{var ke;return(ke=Me.tags)==null?void 0:ke.some(Oe=>Oe.relationship_type_id===m)}):[],[s,m]),X=k.useMemo(()=>V.filter(Me=>!Me.email&&!Me.phone),[V]),Y=k.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Me={};Me.blocked=X,JI.forEach(ve=>{Me[ve.key]=V.filter(ve.check)});const ke=V.map(oM),Oe=V.length>0?Math.round(ke.reduce((ve,dt)=>ve+dt,0)/V.length):0,qe=ke.filter(ve=>ve===100).length;return{contactsByGap:Me,overallCompleteness:Oe,fullyComplete:qe}},[V,X]),J=k.useMemo(()=>{if(!s||s.length===0)return null;const Me=Bc(N4(new Date,1)),ke=s.filter(dt=>new Date(dt.created_at)dt+pe,0)/ke.length),qe=Y.overallCompleteness,ve=qe-Oe;return{oldCompleteness:Oe,currentCompleteness:qe,diff:ve,oldCount:ke.length}},[s,Y.overallCompleteness]),Q=V.length,ce=k.useCallback(()=>{var Xe;const Me=Y.contactsByGap[c];if(!(Me!=null&&Me.length))return;const ke=c==="blocked"?"Outreach Blocked":((Xe=JI.find(et=>et.key===c))==null?void 0:Xe.label)||c,Oe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],qe=Me.map(et=>[et.first_name,et.last_name||"",et.email||"",et.phone||"",et.address||"",et.birthday||"",et.home_anniversary||"",oM(et).toString()]),ve=[Oe.join(","),...qe.map(et=>et.map(Ce=>`"${Ce.replace(/"/g,'""')}"`).join(","))].join(` `),dt=new Blob([ve],{type:"text/csv"}),pe=URL.createObjectURL(dt),Ue=document.createElement("a");Ue.href=pe,Ue.download=`sphere-gaps-${ke.toLowerCase().replace(/\s+/g,"-")}-${ds(new Date,"yyyy-MM-dd")}.csv`,Ue.click(),URL.revokeObjectURL(pe),kn({title:`Exported ${Me.length} contacts to CSV`})},[Y.contactsByGap,c]),ne=k.useCallback(async Me=>{if(!a)return null;try{const{data:ke,error:Oe}=await H.from("contact_intake_tokens").insert({contact_id:Me,intake_page_id:a.id}).select("token").single();if(Oe)throw Oe;return ke.token}catch{return null}},[a]),re=k.useCallback(Me=>a?`https://contacts.relevelup.com/${a.slug}?t=${Me}`:"",[a]),oe=k.useCallback(async Me=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ke=await ne(Me);ke?(await navigator.clipboard.writeText(re(ke)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,ne,re,t]),he=k.useCallback(async Me=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Me.email){me.error("This contact has no email address");return}const ke=await ne(Me.id);if(!ke){me.error("Failed to generate link");return}const Oe=re(ke),qe=P9e.replace("{{update_link}}",Oe).replace(/\{\{first_name\}\}/g,Me.first_name).replace(/\{\{last_name\}\}/g,Me.last_name||""),ve=Qye.replace(/\{\{first_name\}\}/g,Me.first_name).replace(/\{\{last_name\}\}/g,Me.last_name||"");if(o)M({id:Me.id,first_name:Me.first_name,last_name:Me.last_name,email:Me.email}),P([]),q(ve),z(qe),N(!0);else{const dt=encodeURIComponent(Qye.replace("{{first_name}}",Me.first_name)),pe=encodeURIComponent(qe.replace(/\{\{first_name\}\}/g,Me.first_name));window.location.href=`mailto:${Me.email}?subject=${dt}&body=${pe}`}},[a,ne,re,o,t]),xe=k.useCallback(async Me=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const ke=Me.filter(ve=>ve.email);if(!ke.length){me.error("No contacts with email addresses in this group");return}const Oe=new Set((i||[]).map(ve=>ve.contact_id)),qe=ke.filter(ve=>!Oe.has(ve.id));if(qe.length===0){me.info(`All ${ke.length} contacts with email have already been sent this update request.`);return}if(qe.lengthJe.id),intake_page_id:a.id}});if(dt)throw dt;const pe=typeof ve=="string"?JSON.parse(ve):ve,Ue=Array.isArray(pe)?pe:Array.isArray(pe==null?void 0:pe.tokens)?pe.tokens:[],Xe=new Map(Ue.filter(Je=>(Je==null?void 0:Je.contact_id)&&(Je==null?void 0:Je.token)).map(Je=>[Je.contact_id,Je.token]));if(Xe.size===0&&(await Promise.all(ke.map(async Ge=>({contactId:Ge.id,token:await ne(Ge.id)})))).forEach(({contactId:Ge,token:lt})=>{lt&&Xe.set(Ge,lt)}),Xe.size===0){me.error("Failed to generate update links. Please try again.");return}const et=qe.filter(Je=>Xe.has(Je.id)).map(Je=>({id:Je.id,first_name:Je.first_name,last_name:Je.last_name,email:Je.email,updateLink:re(Xe.get(Je.id))})),Ce=P9e;M(null),P(et),q(Qye),z(Ce),N(!0),me.success(`Ready to email ${et.length} contacts`)}catch{me.error("Failed to generate links")}finally{w(!1)}},[a,o,re,ne,t]),ge=[{key:"blocked",label:"Outreach Blocked",icon:Vv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...JI].find(Me=>Me.key===c),_e=Y.contactsByGap[c]||[],Be=_e.filter(Me=>Me.email).length,Se=new Set((i||[]).map(Me=>Me.contact_id)),Ee=_e.filter(Me=>Me.email&&Se.has(Me.id)).length,Ae=Be-Ee;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(ty,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Rs,{value:m,onValueChange:f,children:[e.jsx(Ls,{className:"w-[180px]",children:e.jsx($s,{placeholder:"Filter by tag"})}),e.jsxs(Ds,{children:[e.jsx(ft,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(Me=>e.jsx(ft,{value:Me.id,children:Me.name},Me.id))]})]})]})]}),e.jsx(Pe,{children:e.jsxs(De,{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",m!=="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:[Y.overallCompleteness,"%"]}),J&&J.diff!==0&&m==="all"&&e.jsxs("div",{className:Pt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",J.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:[J.diff>0?"↑":"↓"," ",Math.abs(J.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:[Y.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Q]})]})]})]}),e.jsx(qi,{value:Y.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Y.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":Y.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),X.length>0&&e.jsx(Pe,{className:Pt("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(De,{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(Vv,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:X.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:JI.map(Me=>{var dt;const ke=((dt=Y.contactsByGap[Me.key])==null?void 0:dt.length)||0,Oe=Q>0?Math.round(ke/Q*100):0,qe=Me.icon,ve=c===Me.key;return e.jsx(Pe,{className:Pt("cursor-pointer transition-all hover:shadow-md",ve&&"ring-2 ring-primary"),onClick:()=>u(Me.key),children:e.jsxs(De,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(qe,{className:Pt("h-5 w-5",Me.color)}),e.jsx("span",{className:"text-sm font-medium",children:Me.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:ke}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Oe,"% of contacts"]})]}),e.jsx(qi,{value:100-Oe,className:"mt-2 h-1.5"})]})},Me.key)})}),e.jsxs(Pe,{children:[e.jsxs(Et,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Lt,{className:"text-lg",children:[(ge==null?void 0:ge.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Ye,{variant:"secondary",children:[_e.length," contacts"]}),Ee>0&&e.jsxs(Ye,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(sa,{className:"h-3 w-3"}),Ee," already emailed"]}),_e.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(G,{variant:"outline",size:"sm",onClick:ce,className:"gap-1.5",children:[e.jsx(vi,{className:"h-3.5 w-3.5"}),"Export"]}),Ae>0&&a&&e.jsxs(G,{size:"sm",onClick:()=>xe(_e),disabled:_,className:"gap-1.5",children:[_?e.jsx(ys,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Fn,{className:"h-3.5 w-3.5"}),"Email ",Ae," Update Links"]})]})]})]}),e.jsx(vr,{children:ge==null?void 0:ge.description})]}),e.jsx(De,{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(Bn,{children:[e.jsx($n,{children:e.jsxs(ks,{children:[e.jsx(jt,{children:"Contact"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(jt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(jt,{children:"Completeness"}),e.jsx(jt,{className:"w-28",children:"Actions"})]})}),e.jsx(qn,{children:_e.map(Me=>{const ke=QTs(i,Me.id);return e.jsxs(ks,{children:[e.jsx(ut,{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/${Me.id}`),children:[Me.first_name," ",Me.last_name]}),!Me.email&&!Me.phone&&c!=="blocked"&&e.jsx(Ye,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),ke&&e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsxs(Ye,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(rr,{className:"h-2.5 w-2.5"}),ql(new Date(ke),{addSuffix:!0})]})}),e.jsxs(sc,{children:["Last bulk emailed ",ds(new Date(ke),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:Me.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:Me.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qi,{value:oM(Me),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[oM(Me),"%"]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>y(Me),children:e.jsx(Gv,{className:"h-3.5 w-3.5"})})}),e.jsx(sc,{children:"Quick edit"})]}),(Me.email||Me.phone)&&a&&e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>oe(Me.id),children:e.jsx(yi,{className:"h-3.5 w-3.5"})})}),e.jsx(sc,{children:"Copy update link"})]}),Me.email&&a&&e.jsxs(kc,{children:[e.jsx(Sc,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>he(Me),children:e.jsx(rr,{className:"h-3.5 w-3.5"})})}),e.jsx(sc,{children:"Email update link"})]})]})})]},Me.id)})})]})})]})]}),g&&e.jsx(XTs,{contact:g,onClose:()=>y(null)}),e.jsx(X1,{open:j,onOpenChange:N,contact:S||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:O,defaultBody:$,gmailEmail:l})]})}function eAs(){const{user:t}=Fs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=mdt(),[i,c]=k.useState(""),[u,m]=k.useState(""),[f,g]=k.useState(!1);k.useEffect(()=>{s&&m(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 y=s?`https://contacts.relevelup.com/${s.slug}`:"",_=()=>{navigator.clipboard.writeText(y),me.success("Link copied!")};if(r)return e.jsx(Pe,{children:e.jsx(De,{className:"p-6 flex items-center justify-center",children:e.jsx(ys,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Pe,{children:[e.jsx(Et,{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(pl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{children:"Connect Page"}),e.jsx(vr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{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(Le,{value:i,onChange:M=>c(M.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(G,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(ys,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const w=o.filter(M=>!M.is_processed),j=o.filter(M=>M.is_processed),N=w.length,S=(M,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[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(Ye,{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(mn,{className:"h-3 w-3"}),ds(new Date(M.created_at),"MMM d")]}),I&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},M.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Et,{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(pl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Lt,{children:"Connect Page"}),e.jsx(vr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{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(De,{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:y}),e.jsxs(G,{size:"sm",variant:"outline",onClick:_,children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(G,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:M=>m(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(G,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),g(!1)},children:"Save"}),e.jsx(G,{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(Pe,{children:[e.jsx(Et,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ur,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Lt,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(vr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(G,{size:"sm",onClick:async()=>{try{const{data:M,error:I}=await H.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;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(De,{children:l?e.jsx(ys,{className:"h-5 w-5 animate-spin text-muted-foreground"}):w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:w.map(M=>S(M,!1))})})]}),j.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{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(Lt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(vr,{children:[j.length," contacts already in your database"]})]})]})}),e.jsx(De,{children:e.jsxs("div",{className:"space-y-3",children:[j.slice(0,10).map(M=>S(M,!0)),j.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",j.length-10," more synced contacts"]})]})})]})]})}function tAs(){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(eAs,{})]})})}const sAs={property_view:{label:"Viewed Listing",icon:Tn,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:El,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:Ja,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},rAs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function nAs({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 Io.accessToken=n,r.current=new Io.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new Io.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 Io.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new Io.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 Io.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(y0,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function pdt(){var P,O,q,$;const{user:t}=Fs(),s=ar(),{isGmailConnected:r,gmailEmail:n}=Ff(),[a,o]=k.useState("all"),[l,i]=k.useState("30"),[c,u]=k.useState(""),[m,f]=k.useState(!1),[g,y]=k.useState(null),{data:_,isLoading:w}=pt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:z,error:V}=await H.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(V)throw V;const X=z;return{...X,visitor_locations:((X==null?void 0:X.visitor_locations)||[]).map(Y=>({...Y,lat:Number(Y.lat),lng:Number(Y.lng),visitor_count:Number(Y.visitor_count??Y.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),j=k.useMemo(()=>{if(!(_!=null&&_.activities))return[];let z=_.activities;if(a!=="all"&&(z=z.filter(V=>V.activity_type===a)),c){const V=c.toLowerCase();z=z.filter(X=>{var Y,J,Q,ce,ne;return((Y=X.visitor_name)==null?void 0:Y.toLowerCase().includes(V))||((J=X.visitor_email)==null?void 0:J.toLowerCase().includes(V))||((Q=X.mls_number)==null?void 0:Q.includes(V))||((ce=X.property_address)==null?void 0:ce.toLowerCase().includes(V))||((ne=X.lead_type)==null?void 0:ne.toLowerCase().includes(V))})}return z},[_==null?void 0:_.activities,a,c]),N=_==null?void 0:_.subdomain,S=z=>N?`https://${N}.thelocalmove.com/listing/${z}`:null,M=_==null?void 0:_.stats,I=z=>{if(z.visitor_email)if(r){const V=(z.visitor_name||"").split(" ");y({id:z.contact_id||"",first_name:V[0]||"",last_name:V.slice(1).join(" ")||null,email:z.visitor_email}),f(!0)}else window.location.href=`mailto:${z.visitor_email}`};return!(_!=null&&_.has_site)&&!w?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(Nd,{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(G,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Ga,{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(Nd,{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(z=>e.jsxs(G,{variant:l===z?"default":"outline",size:"sm",onClick:()=>i(z),children:[z,"d"]},z))})]}),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:wn,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:Tn,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:El,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:Ja,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map(z=>e.jsx(Pe,{children:e.jsxs(De,{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:z.label}),e.jsx("p",{className:`text-2xl font-bold ${z.color}`,children:z.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${z.bg}`,children:e.jsx(z.icon,{className:`h-5 w-5 ${z.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${z.color}`,children:z.sub})," in last 7d"]})]})},z.label))}),e.jsxs(ga,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ss,{value:"overview",className:"gap-1.5",children:[e.jsx(co,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ss,{value:"leads",className:"gap-1.5",children:[e.jsx(Jh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ss,{value:"map",className:"gap-1.5",children:[e.jsx(y0,{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(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(De,{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(xn,{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((z,V)=>{const X=S(z.mls_number);return e.jsxs("a",{href:X||"#",target:"_blank",rel:"noopener noreferrer",onClick:Y=>{X||Y.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}),z.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:z.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(xn,{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:z.property_address||`MLS# ${z.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ql(new Date(z.last_viewed),{addSuffix:!0})})]}),e.jsxs(Ye,{variant:"secondary",className:"shrink-0 text-xs",children:[z.view_count," view",z.view_count!==1?"s":""]}),X&&e.jsx(rn,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},z.mls_number)})})})]}),e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(De,{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(wn,{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((z,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:rAs[z.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:z.page_title||z.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:z.page_path})]}),e.jsx(Ye,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:z.page_type}),e.jsx(Ye,{variant:"outline",className:"shrink-0 text-xs",children:z.view_count})]},`${z.page_type}-${z.page_path}`))})})]})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(aa,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(De,{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(z=>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(aa,{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:[z.city,", ",z.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:z.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:z.visitor_count})]},`${z.city}-${z.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(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, address...",value:c,onChange:z=>u(z.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((P=_==null?void 0:_.activities)==null?void 0:P.length)||0},{key:"new_lead",label:"Leads",count:((O=_==null?void 0:_.activities)==null?void 0:O.filter(z=>z.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:((q=_==null?void 0:_.activities)==null?void 0:q.filter(z=>z.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:(($=_==null?void 0:_.activities)==null?void 0:$.filter(z=>z.activity_type==="saved_listing").length)||0}].map(z=>e.jsxs(G,{variant:a===z.key?"default":"outline",size:"sm",onClick:()=>o(z.key),className:"gap-1.5",children:[z.label,e.jsx(Ye,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:z.count})]},z.key))})]}),w?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(z=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},z))}):j.length===0?e.jsx(Pe,{children:e.jsxs(De,{className:"p-8 text-center",children:[e.jsx(Mh,{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:j.map((z,V)=>{const X=sAs[z.activity_type],Y=X.icon,J=ql(new Date(z.occurred_at),{addSuffix:!0}),Q=z.visitor_name&&z.visitor_name!=="Site Visitor";return e.jsx(Pe,{className:`transition-all hover:shadow-md ${z.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":z.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(De,{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:[z.photo_url?e.jsx("a",{href:z.mls_number&&S(z.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:z.photo_url,alt:z.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${z.activity_type==="new_lead"?"bg-emerald-500/10":z.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(Y,{className:`h-4 w-4 ${z.activity_type==="new_lead"?"text-emerald-500":z.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:[Q?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{z.contact_id&&s(`/mission-control/contacts/${z.contact_id}`)},children:z.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:z.visitor_name||"Site Visitor"}),e.jsx(Ye,{variant:"outline",className:`text-[10px] shrink-0 ${X.badgeClass}`,children:X.label}),z.lead_type&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] capitalize",children:z.lead_type.replace(/_/g," ")})]}),z.property_address&&z.mls_number&&e.jsxs("a",{href:S(z.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(aa,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:z.property_address}),e.jsx(rn,{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(mn,{className:"h-3 w-3"}),J]}),z.mls_number&&!z.property_address&&e.jsxs("a",{href:S(z.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",z.mls_number]})]}),z.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',z.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[z.visitor_email&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>I(z),children:e.jsx(rr,{className:"h-4 w-4"})}),z.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${z.visitor_phone}`,children:e.jsx(Nn,{className:"h-4 w-4"})}),e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${z.visitor_phone}`,children:e.jsx(Ki,{className:"h-4 w-4"})})]}),z.contact_id&&e.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${z.contact_id}`),children:e.jsx(da,{className:"h-4 w-4"})})]})]})})},`${z.activity_type}-${z.occurred_at}-${V}`)})})]}),e.jsxs(bs,{value:"map",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsxs(Lt,{className:"text-base flex items-center gap-2",children:[e.jsx(y0,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ye,{variant:"secondary",className:"text-xs ml-2",children:[_.visitor_locations.reduce((z,V)=>z+V.visitor_count,0)," visitors from ",_.visitor_locations.length," cities"]})]})}),e.jsx(De,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(nAs,{locations:(_==null?void 0:_.visitor_locations)||[]})})})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Pe,{children:[e.jsx(Et,{className:"pb-3",children:e.jsx(Lt,{className:"text-base",children:"Location Breakdown"})}),e.jsx(De,{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(z=>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(aa,{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:[z.city,", ",z.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:z.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:z.visitor_count})]},`${z.city}-${z.region}`))})})]})]})]})]}),r&&g&&e.jsx(X1,{open:m,onOpenChange:f,contact:g,gmailEmail:n})]})}const aAs=Object.freeze(Object.defineProperty({__proto__:null,default:pdt},Symbol.toStringTag,{value:"Module"})),iAs=k.lazy(()=>Lo(()=>import("./MobileAgentApp-CNEYFbi5.js"),[])),oAs=k.lazy(()=>Lo(()=>import("./PostcardManager-BjK-bzFQ.js"),__vite__mapDeps([0,1]))),lAs=k.lazy(()=>Lo(()=>import("./HomeReelManager-C8XBN7D_.js"),[])),cAs=k.lazy(()=>Lo(()=>import("./AdminCredits-BRgqebJQ.js"),[])),dAs=k.lazy(()=>Lo(()=>import("./DirectMail-CRFnXrhs.js").then(t=>t.D),__vite__mapDeps([2,1]))),uAs=k.lazy(()=>Lo(()=>import("./InnerCirclePopbyMap-3mt_8jwS.js"),[])),hAs=k.lazy(()=>Lo(()=>import("./LiveVisitorFeed-Jg2mz1X5.js"),[])),mAs=k.lazy(()=>Lo(()=>import("./LeadSites-CMgG-BGF.js"),[])),I9e=k.lazy(()=>Lo(()=>import("./LeadSiteEditor-B310g2jz.js"),__vite__mapDeps([3,4,5]))),pAs=k.lazy(()=>Lo(()=>import("./AdminLeadSiteThemes-moo4KMiC.js"),__vite__mapDeps([6,4]))),fAs=k.lazy(()=>Lo(()=>import("./AdminMlsFeeds-ZHSAvY_C.js"),[])),xAs=k.lazy(()=>Lo(()=>import("./AdminLeadSiteAnalytics-KqzlT77p.js"),[])),gAs=k.lazy(()=>Lo(()=>import("./AdminWebsiteInterests-Dg5-qK9U.js"),[])),yAs=k.lazy(()=>Lo(()=>import("./AdminMlsFeeTracker-xxIl1QjJ.js"),[])),vAs=k.lazy(()=>Lo(()=>import("./MLSListings-D4fDc87K.js"),[])),bAs=k.lazy(()=>Lo(()=>import("./MLSListingDetail-BbEXk6OZ.js"),[])),_As=k.lazy(()=>Lo(()=>import("./MarketReportPage-C9zqhYGa.js"),[]));k.lazy(()=>Lo(()=>Promise.resolve().then(()=>aAs),void 0));const wAs=k.lazy(()=>Lo(()=>import("./EmailCampaigns-BOIsvHen.js"),[])),jAs=k.lazy(()=>Lo(()=>import("./EmailCampaignComposer-GUZHbY6v.js"),__vite__mapDeps([7,8]))),NAs=k.lazy(()=>Lo(()=>import("./EmailCampaignDetail-Bx1q6t7W.js"),[])),kAs=k.lazy(()=>Lo(()=>import("./SharedCampaignTemplates-D5KAXfKA.js"),__vite__mapDeps([9,10,8]))),SAs=k.lazy(()=>Lo(()=>import("./AgentTemplates-BtHfDVyV.js"),__vite__mapDeps([11,10,8]))),L9e=k.lazy(()=>Lo(()=>import("./TheLocalMoveHome-DM4Qj5CX.js"),__vite__mapDeps([12,13]))),D9e=k.lazy(()=>Lo(()=>import("./TheLocalMoveGetStarted-BqFZhb2Q.js"),__vite__mapDeps([14,13]))),O9e=k.lazy(()=>Lo(()=>import("./TheLocalMoveCheckout-C2bLnxMF.js"),[])),R9e=k.lazy(()=>Lo(()=>import("./TheLocalMoveCheckoutSuccess-CufSrB3I.js"),[])),CAs=k.lazy(()=>Lo(()=>import("./AdminWebsiteOrders-itdPl0DW.js"),[])),MAs=new $vt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),TAs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},AAs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},EAs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},PAs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},IAs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},LAs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},DAs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},OAs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},RAs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},fdt=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},FAs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!fdt(),zAs=()=>e.jsx(Gvt,{client:MAs,children:e.jsx(eVe,{children:e.jsxs(W1,{children:[e.jsx(oyt,{}),e.jsx(zyt,{}),e.jsx(rbt,{children:e.jsx(i2t,{children:e.jsx(o2t,{children:e.jsxs(c2t,{children:[e.jsx(l2t,{}),e.jsx($Nt,{}),e.jsx(rkt,{}),LAs()?e.jsx(G5s,{}):AAs()?e.jsx(w4t,{}):TAs()?e.jsx(Vkt,{}):EAs()?e.jsx(k4t,{}):PAs()?e.jsx(h6t,{}):IAs()?e.jsx(T6t,{}):DAs()?e.jsx(W5s,{}):OAs()?e.jsx(K5s,{}):RAs()?e.jsx(Z5s,{}):fdt()?e.jsxs(Coe,{children:[e.jsx(xs,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(D9e,{})})}),e.jsx(xs,{path:"/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(O9e,{})})}),e.jsx(xs,{path:"/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(R9e,{})})}),e.jsx(xs,{path:"/privacy-policy",element:e.jsx(mIe,{})}),e.jsx(xs,{path:"/terms-of-service",element:e.jsx(pIe,{})}),e.jsx(xs,{path:"*",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(L9e,{})})})]}):FAs()?e.jsx(PTs,{}):e.jsxs(Coe,{children:[e.jsx(xs,{path:"/",element:e.jsx(F6t,{})}),e.jsx(xs,{path:"/the-local-move",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(L9e,{})})}),e.jsx(xs,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(D9e,{})})}),e.jsx(xs,{path:"/local-move/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(O9e,{})})}),e.jsx(xs,{path:"/local-move/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(R9e,{})})}),e.jsx(xs,{path:"/privacy-policy",element:e.jsx(mIe,{})}),e.jsx(xs,{path:"/terms-of-service",element:e.jsx(pIe,{})}),e.jsx(xs,{path:"/data-deletion",element:e.jsx(z6t,{})}),e.jsx(xs,{path:"/public/listings",element:e.jsx(EWe,{})}),e.jsx(xs,{path:"/public/listing/:slugOrId",element:e.jsx(TLt,{})}),e.jsx(xs,{path:"/card/:slug",element:e.jsx(ALt,{})}),e.jsx(xs,{path:"/join-brokerage/:slug",element:e.jsx($Cs,{})}),e.jsx(xs,{path:"/recruit-unsubscribe",element:e.jsx(HCs,{})}),e.jsx(xs,{path:"/recruit-video/:shareToken",element:e.jsx(UCs,{})}),e.jsx(xs,{path:"/connect/:slug",element:e.jsx(MQe,{})}),e.jsx(xs,{path:"/auth",element:e.jsx($6t,{})}),e.jsx(xs,{path:"/subscription-success",element:e.jsx(q6t,{})}),e.jsx(xs,{path:"/subscription",element:e.jsx(or,{children:e.jsx(DIt,{})})}),e.jsxs(xs,{path:"/share/video",element:e.jsx(wLt,{}),children:[e.jsx(xs,{path:":shareToken",element:e.jsx(FIe,{})}),e.jsx(xs,{path:":shareToken/r/:recipientToken",element:e.jsx(FIe,{})})]}),e.jsx(xs,{path:"/p/:shareToken",element:e.jsx(c5s,{})}),e.jsx(xs,{path:"/portal/:slug",element:e.jsx(x5s,{})}),e.jsx(xs,{path:"/og/video/:token",element:e.jsx(jLt,{})}),e.jsx(xs,{path:"/setup-brokerage",element:e.jsx(or,{children:e.jsx(OIt,{})})}),e.jsx(xs,{path:"/claim-account",element:e.jsx(DIe,{})}),e.jsx(xs,{path:"/claim",element:e.jsx(DIe,{})}),e.jsx(xs,{path:"/join",element:e.jsx(RIt,{})}),e.jsx(xs,{path:"/trial",element:e.jsx(KIt,{})}),e.jsx(xs,{path:"/trial/success",element:e.jsx(ZIt,{})}),e.jsx(xs,{path:"/dashboard",element:e.jsx(or,{children:e.jsx(Q8t,{})})}),e.jsx(xs,{path:"/profile",element:e.jsx(or,{children:e.jsx(D$t,{})})}),e.jsx(xs,{path:"/apps",element:e.jsx(or,{children:e.jsx(G$t,{})})}),e.jsx(xs,{path:"/admin",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(O8e,{})})}),e.jsx(xs,{path:"/admin/dashboard",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(O8e,{})})}),e.jsx(xs,{path:"/admin/apps",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(IVt,{})})}),e.jsx(xs,{path:"/admin/members",element:e.jsx(or,{requireAdmin:!0,children:e.jsx($Vt,{})})}),e.jsx(xs,{path:"/admin/invite-codes",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(qVt,{})})}),e.jsx(xs,{path:"/admin/events",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(KVt,{})})}),e.jsx(xs,{path:"/events",element:e.jsx(or,{children:e.jsx(q$t,{})})}),e.jsx(xs,{path:"/events/:eventId",element:e.jsx(or,{children:e.jsx(V$t,{})})}),e.jsx(xs,{path:"/templates",element:e.jsx(or,{children:e.jsx(W$t,{})})}),e.jsx(xs,{path:"/templates/:templateId",element:e.jsx(or,{children:e.jsx(Q$t,{})})}),e.jsx(xs,{path:"/admin/templates",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(YVt,{})})}),e.jsx(xs,{path:"/academy",element:e.jsx(or,{children:e.jsx(X$t,{})})}),e.jsx(xs,{path:"/academy/:videoId",element:e.jsx(or,{children:e.jsx(eqt,{})})}),e.jsx(xs,{path:"/admin/academy",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(XVt,{})})}),e.jsx(xs,{path:"/toolbox",element:e.jsx(or,{children:e.jsx(tqt,{})})}),e.jsx(xs,{path:"/toolbox/:kitId",element:e.jsx(or,{children:e.jsx(sqt,{})})}),e.jsx(xs,{path:"/admin/toolbox",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(JVt,{})})}),e.jsx(xs,{path:"/social-swag",element:e.jsx(or,{children:e.jsx(rqt,{})})}),e.jsx(xs,{path:"/social-swag-2",element:e.jsx(or,{children:e.jsx(tVt,{})})}),e.jsx(xs,{path:"/social-swag/:swagId",element:e.jsx(or,{children:e.jsx(sVt,{})})}),e.jsx(xs,{path:"/social-connections",element:e.jsx(or,{children:e.jsx(GCs,{})})}),e.jsx(xs,{path:"/social-connections/callback",element:e.jsx(or,{children:e.jsx(WCs,{})})}),e.jsx(xs,{path:"/social-connections/linkedin-callback",element:e.jsx(or,{children:e.jsx(ZCs,{})})}),e.jsx(xs,{path:"/social-connections/google-callback",element:e.jsx(or,{children:e.jsx(KCs,{})})}),e.jsx(xs,{path:"/admin/social-swag",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(eHt,{})})}),e.jsx(xs,{path:"/admin/social-swag-2",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(FGt,{})})}),e.jsx(xs,{path:"/community",element:e.jsx(or,{children:e.jsx(_Vt,{})})}),e.jsx(xs,{path:"/support",element:e.jsx(or,{children:e.jsx(wVt,{})})}),e.jsx(xs,{path:"/admin/community",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(zGt,{})})}),e.jsx(xs,{path:"/admin/support-tickets",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(C1s,{})})}),e.jsx(xs,{path:"/admin/email-templates",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(T1s,{})})}),e.jsx(xs,{path:"/admin/agent-email-templates",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(A1s,{})})}),e.jsx(xs,{path:"/admin/analytics",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(N1s,{})})}),e.jsx(xs,{path:"/admin/brokerage-resources",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(k1s,{})})}),e.jsx(xs,{path:"/admin/dashboard-management",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(S1s,{})})}),e.jsx(xs,{path:"/brokerage/dashboard",element:e.jsx(or,{requireBrokerageManager:!0,children:e.jsx(q1s,{})})}),e.jsx(xs,{path:"/brokerage/teams",element:e.jsx(or,{requireBrokerageManager:!0,children:e.jsx(DTs,{})})}),e.jsx(xs,{path:"/brokerage/recruiting",element:e.jsx(or,{requireBrokerageManager:!0,children:e.jsx(c3s,{})})}),e.jsx(xs,{path:"/my-team",element:e.jsx(or,{children:e.jsx(OTs,{})})}),e.jsx(xs,{path:"/my-brokerage",element:e.jsx(or,{children:e.jsx(K1s,{})})}),e.jsx(xs,{path:"/brokerage-content",element:e.jsx(or,{children:e.jsx(ebs,{})})}),e.jsx(xs,{path:"/brokerage-content/:contentId",element:e.jsx(or,{children:e.jsx(abs,{})})}),e.jsx(xs,{path:"/brokerage-resources",element:e.jsx(or,{requireBrokerageManager:!0,children:e.jsx(MVt,{})})}),e.jsx(xs,{path:"/brokerage-resources/:resourceId",element:e.jsx(or,{requireBrokerageManager:!0,children:e.jsx(TVt,{})})}),e.jsx(xs,{path:"/newsletters",element:e.jsx(or,{children:e.jsx(ibs,{})})}),e.jsx(xs,{path:"/newsletters/:id",element:e.jsx(or,{children:e.jsx(lbs,{})})}),e.jsx(xs,{path:"/wishlist",element:e.jsx(or,{children:e.jsx(ubs,{})})}),e.jsx(xs,{path:"/wishlist/:itemId",element:e.jsx(or,{children:e.jsx(hbs,{})})}),e.jsx(xs,{path:"/admin/wishlist",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(mbs,{})})}),e.jsx(xs,{path:"/admin/levelup-brief",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(pbs,{})})}),e.jsx(xs,{path:"/admin/newsletters",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(dbs,{})})}),e.jsx(xs,{path:"/admin/additional-services",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(fbs,{})})}),e.jsx(xs,{path:"/admin/discounts",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(xbs,{})})}),e.jsx(xs,{path:"/admin/subscriptions",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(gbs,{})})}),e.jsx(xs,{path:"/admin/referrals",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(ybs,{})})}),e.jsx(xs,{path:"/admin/prospector",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(USs,{})})}),e.jsx(xs,{path:"/admin/recruiting",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(l3s,{})})}),e.jsx(xs,{path:"/admin/beta/social-post-generator",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(dCs,{})})}),e.jsx(xs,{path:"/admin/credits",element:e.jsx(or,{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(cAs,{})})})}),e.jsx(xs,{path:"/admin/beta/postcard-manager",element:e.jsx(or,{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(oAs,{})})})}),e.jsx(xs,{path:"/admin/beta/homereel",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(lAs,{})})})}),e.jsx(xs,{path:"/admin/lms",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(NCs,{})})}),e.jsx(xs,{path:"/admin/lms/stats",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(TCs,{})})}),e.jsx(xs,{path:"/admin/lms/:courseId",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(kCs,{})})}),e.jsx(xs,{path:"/levelup-u",element:e.jsx(or,{children:e.jsx(ACs,{})})}),e.jsx(xs,{path:"/levelup-u/:courseId",element:e.jsx(or,{children:e.jsx(PCs,{})})}),e.jsx(xs,{path:"/admin/brokerage-content-activity",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(d3s,{})})}),e.jsx(xs,{path:"/admin/onboarding-checklist",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(bbs,{})})}),e.jsx(xs,{path:"/admin/marketplace",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(bSs,{})})}),e.jsx(xs,{path:"/admin/agent-points",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(V4s,{})})}),e.jsx(xs,{path:"/admin/reward-store",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(DSs,{})})}),e.jsx(xs,{path:"/admin/integrations",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(RSs,{})})}),e.jsx(xs,{path:"/admin/integrations/callback",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(qSs,{})})}),e.jsx(xs,{path:"/admin/email-campaigns",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(wAs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/templates",element:e.jsx(or,{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(kAs,{})})})}),e.jsx(xs,{path:"/email-campaigns/templates",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(SAs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/new",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(jAs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/:id",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(NAs,{})})})}),e.jsx(xs,{path:"/reward-store",element:e.jsx(or,{children:e.jsx(r5s,{})})}),e.jsx(xs,{path:"/additional-services",element:e.jsx(or,{children:e.jsx(Ebs,{})})}),e.jsx(xs,{path:"/additional-services/:serviceId",element:e.jsx(or,{children:e.jsx(Pbs,{})})}),e.jsx(xs,{path:"/ai-toolkit",element:e.jsx(or,{children:e.jsx(Ibs,{})})}),e.jsx(xs,{path:"/mission-control",element:e.jsx(or,{children:e.jsx(Xbs,{})})}),e.jsx(xs,{path:"/mission-control/contacts",element:e.jsx(or,{children:e.jsx(X_s,{})})}),e.jsx(xs,{path:"/mission-control/contacts/:contactId",element:e.jsx(or,{children:e.jsx(Tws,{})})}),e.jsx(xs,{path:"/mission-control/plans",element:e.jsx(or,{children:e.jsx(Aws,{})})}),e.jsx(xs,{path:"/mission-control/popbys",element:e.jsx(or,{children:e.jsx(Rws,{})})}),e.jsx(xs,{path:"/mission-control/popbys/map",element:e.jsx(or,{children:e.jsx(uAs,{})})}),e.jsx(xs,{path:"/admin/notification-settings",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(zSs,{})})}),e.jsx(xs,{path:"/admin/agent-os",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(wbs,{})})}),e.jsx(xs,{path:"/mission-control/listings",element:e.jsx(or,{children:e.jsx(o2s,{})})}),e.jsx(xs,{path:"/mission-control/listings/new",element:e.jsx(or,{children:e.jsx(A7e,{})})}),e.jsx(xs,{path:"/mission-control/listings/:listingId",element:e.jsx(or,{children:e.jsx(k2s,{})})}),e.jsx(xs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(or,{children:e.jsx(A7e,{})})}),e.jsx(xs,{path:"/admin/listing-exchange",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(F4s,{})})}),e.jsx(xs,{path:"/mission-control/pipeline",element:e.jsx(or,{children:e.jsx(Hks,{})})}),e.jsx(xs,{path:"/mission-control/tasks",element:e.jsx(or,{children:e.jsx(t4s,{})})}),e.jsx(xs,{path:"/mission-control/my-card",element:e.jsx(or,{children:e.jsx(_4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations",element:e.jsx(or,{children:e.jsx(E4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(or,{children:e.jsx(P4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(I4s,{})}),e.jsx(xs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(or,{children:e.jsx(L4s,{})})}),e.jsx(xs,{path:"/mission-control/scorecard",element:e.jsx(or,{children:e.jsx(Qws,{})})}),e.jsx(xs,{path:"/admin/scorecard",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(O4s,{})})}),e.jsx(xs,{path:"/admin/scorecard/:userId",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(Uze,{})})}),e.jsx(xs,{path:"/mission-control/scorecard/:userId",element:e.jsx(or,{children:e.jsx(Uze,{})})}),e.jsx(xs,{path:"/mission-control/relationship-scorecard",element:e.jsx(or,{children:e.jsx(ZTs,{})})}),e.jsx(xs,{path:"/mission-control/sphere-gaps",element:e.jsx(or,{children:e.jsx(JTs,{})})}),e.jsx(xs,{path:"/mission-control/website-activity",element:e.jsx(or,{children:e.jsx(pdt,{})})}),e.jsx(xs,{path:"/mission-control/connect-page",element:e.jsx(or,{children:e.jsx(tAs,{})})}),e.jsx(xs,{path:"/admin/membership-reviews",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(z4s,{})})}),e.jsx(xs,{path:"/admin/weekly-digest",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(q4s,{})})}),e.jsx(xs,{path:"/mission-control/video/record",element:e.jsx(or,{children:e.jsx(MNs,{})})}),e.jsx(xs,{path:"/mission-control/video-library",element:e.jsx(or,{children:e.jsx(UNs,{})})}),e.jsx(xs,{path:"/marketplace",element:e.jsx(or,{children:e.jsx(YCs,{})})}),e.jsx(xs,{path:"/marketplace/:productId",element:e.jsx(or,{children:e.jsx(QCs,{})})}),e.jsx(xs,{path:"/marketplace/cart",element:e.jsx(or,{children:e.jsx(XCs,{})})}),e.jsx(xs,{path:"/marketplace/orders",element:e.jsx(or,{children:e.jsx(JCs,{})})}),e.jsx(xs,{path:"/marketplace/orders/:orderId",element:e.jsx(or,{children:e.jsx(t5s,{})})}),e.jsx(xs,{path:"/marketplace/success",element:e.jsx(or,{children:e.jsx(s5s,{})})}),e.jsx(xs,{path:"/admin/agent-cards",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(H4s,{})})}),e.jsx(xs,{path:"/admin/presentation-analytics",element:e.jsx(or,{requireAdmin:!0,children:e.jsx(BSs,{})})}),e.jsx(xs,{path:"/admin/guest-book-analytics",element:e.jsx(or,{requireAdmin:!0,children:e.jsx($Ss,{})})}),e.jsx(xs,{path:"/mission-control/smart-drips",element:e.jsx(or,{children:e.jsx(V5s,{})})}),e.jsx(xs,{path:"/mission-control/direct-mail",element:e.jsx(or,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(dAs,{})})})}),e.jsx(xs,{path:"/mission-control/presentations",element:e.jsx(or,{children:e.jsx(n5s,{})})}),e.jsx(xs,{path:"/mission-control/presentations/new",element:e.jsx(or,{children:e.jsx(p9e,{})})}),e.jsx(xs,{path:"/mission-control/presentations/:id",element:e.jsx(or,{children:e.jsx(p9e,{})})}),e.jsx(xs,{path:"/mission-control/guest-book",element:e.jsx(or,{children:e.jsx(p5s,{})})}),e.jsx(xs,{path:"/mission-control/guest-book/live/:id",element:e.jsx(or,{children:e.jsx(hAs,{})})}),e.jsx(xs,{path:"/guestbook/:slug",element:e.jsx(uKe,{})}),e.jsx(xs,{path:"/mission-control/card-studio",element:e.jsx(or,{children:e.jsx(w5s,{})})}),e.jsx(xs,{path:"/mission-control/scheduler",element:e.jsx(or,{children:e.jsx(UTs,{})})}),e.jsx(xs,{path:"/c/:shareToken",element:e.jsx(Jct,{})}),e.jsx(xs,{path:"/book/:slug",element:e.jsx(tdt,{})}),e.jsx(xs,{path:"/page/:slug",element:e.jsx(sdt,{})}),e.jsx(xs,{path:"/mission-control/landing-pages",element:e.jsx(or,{children:e.jsx(VTs,{})})}),e.jsx(xs,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(or,{children:e.jsx(WTs,{})})}),e.jsx(xs,{path:"/my-website/:siteId/edit",element:e.jsx(or,{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(xs,{path:"/my-website/mls-listings",element:e.jsx(or,{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(vAs,{})})})}),e.jsx(xs,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(or,{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(bAs,{})})})}),e.jsx(xs,{path:"/my-website/market-report",element:e.jsx(or,{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(_As,{})})})}),e.jsx(xs,{path:"/admin/lead-sites",element:e.jsx(or,{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(mAs,{})})})}),e.jsx(xs,{path:"/admin/lead-sites/themes",element:e.jsx(or,{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(pAs,{})})})}),e.jsx(xs,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(or,{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(xs,{path:"/admin/mls-feeds",element:e.jsx(or,{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(fAs,{})})})}),e.jsx(xs,{path:"/admin/lead-site-analytics",element:e.jsx(or,{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(xAs,{})})})}),e.jsx(xs,{path:"/admin/website-interests",element:e.jsx(or,{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(gAs,{})})})}),e.jsx(xs,{path:"/admin/website-orders",element:e.jsx(or,{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(CAs,{})})})}),e.jsx(xs,{path:"/admin/mls-fee-tracker",element:e.jsx(or,{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(yAs,{})})})}),e.jsx(xs,{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(iAs,{})})}),e.jsx(xs,{path:"*",element:e.jsx(edt,{})})]}),")"]})})})})]})})}),tf=window.location.hostname,BAs=tf.includes("lovable.app")||tf.includes("lovableproject.com"),$As=(()=>{try{return window.self!==window.top}catch{return!0}})(),qAs=tf.startsWith("cards.")||tf.startsWith("cardstudio.")||tf.startsWith("listings.")||tf.startsWith("presentations.")||tf.startsWith("guestbook.")||tf.startsWith("clients.")||tf.startsWith("booking.")||tf.startsWith("contacts.")||tf.startsWith("pages.")||tf.endsWith(".thelocalmove.com")&&!tf.startsWith("dashboard.");var K9e;BAs||$As||qAs?((K9e=navigator.serviceWorker)==null||K9e.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&Lo(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-C7lUxRNi.js");return{registerSW:t}},[]).then(({registerSW:t})=>{t({onNeedRefresh(){},onOfflineReady(){}})});lqe(document.getElementById("root")).render(e.jsx(zAs,{}));export{ao as $,qs as A,Ga as B,co as C,sh as D,Tn as E,Pa as F,aa as G,xn as H,SY as I,fn as J,JAe as K,Ja as L,Ki as M,yxe as N,K1t as O,Nn as P,ame as Q,R_s as R,el as S,Lh as T,ur as U,bit as V,B_s as W,Er as X,NSe as Y,ua as Z,Lo as _,ar as a,Vc as a$,Ff as a0,Tt as a1,Nd as a2,Fn as a3,X1 as a4,Bo as a5,v1 as a6,ys as a7,Th as a8,au as a9,$n as aA,ks as aB,jt as aC,qn as aD,ut as aE,Ye as aF,qr as aG,fs as aH,ps as aI,js as aJ,vs as aK,ye as aL,Le as aM,Rs as aN,Ls as aO,$s as aP,Ds as aQ,ft as aR,Rn as aS,JAs as aT,ds as aU,bo as aV,Tr as aW,bl as aX,uae as aY,X4 as aZ,Ta as a_,xS as aa,nd as ab,qM as ac,ZM as ad,rh as ae,l0 as af,ey as ag,tl as ah,rn as ai,Fm as aj,fS as ak,Coe as al,xs as am,Pe as an,Et as ao,Lt as ap,ml as aq,vr as ar,De as as,ga as at,fa as au,ss as av,Al as aw,bs as ax,G as ay,Bn as az,Fs as b,W1 as b$,yi as b0,kr as b1,Ms as b2,mS as b3,Oi as b4,ci as b5,nn as b6,Z_ as b7,fJ as b8,Ih as b9,yR as bA,u4e as bB,u3 as bC,Eu as bD,kc as bE,Sc as bF,l1 as bG,sc as bH,ose as bI,Vo as bJ,Ho as bK,$o as bL,Li as bM,bL as bN,sa as bO,ul as bP,cJ as bQ,rJ as bR,fL as bS,dh as bT,bV as bU,wn as bV,KM as bW,t8 as bX,Px as bY,Gr as bZ,Yj as b_,sl as ba,zae as bb,Qg as bc,Kv as bd,qi as be,vi as bf,YM as bg,zo as bh,_u as bi,An as bj,N0 as bk,vS as bl,v0 as bm,TIt as bn,Cn as bo,Wa as bp,Mn as bq,r4e as br,sce as bs,Qse as bt,l4e as bu,n4e as bv,d4e as bw,cEs as bx,EV as by,i4e as bz,Pt as c,El as c$,aT as c0,vd as c1,BL as c2,Mo as c3,kn as c4,Spt as c5,Do as c6,mt as c7,o_s as c8,i_s as c9,zm as cA,dZ as cB,ou as cC,Tu as cD,Yh as cE,c4e as cF,Hv as cG,dEs as cH,fEs as cI,DGt as cJ,S0 as cK,gf as cL,ea as cM,u1 as cN,Ph as cO,mEs as cP,pEs as cQ,Cp as cR,Jv as cS,du as cT,uu as cU,Ud as cV,E2e as cW,La as cX,GL as cY,gS as cZ,Ome as c_,c_s as ca,Io as cb,XM as cc,OL as cd,wi as ce,eEs as cf,zWe as cg,tEs as ch,sEs as ci,rEs as cj,y1 as ck,pNe as cl,pl as cm,gs as cn,ew as co,xE as cp,P3 as cq,gE as cr,yE as cs,Lre as ct,$l as cu,Ex as cv,zL as cw,Vee as cx,sT as cy,DL as cz,Ul as d,iN as d$,Mp as d0,_L as d1,Ax as d2,wd as d3,vSe as d4,b0 as d5,Qo as d6,Au as d7,cae as d8,qR as d9,Dke as dA,Ike as dB,Lke as dC,tS as dD,dS as dE,GM as dF,WM as dG,nh as dH,g0 as dI,Q4 as dJ,J4 as dK,Uo as dL,MS as dM,wS as dN,vke as dO,Ra as dP,Pl as dQ,iS as dR,Xh as dS,Nj as dT,W_ as dU,hS as dV,xL as dW,xW as dX,Qee as dY,Jh as dZ,zd as d_,ba as da,Bm as db,Fa as dc,nS as dd,bS as de,Nf as df,wT as dg,Yat as dh,Y0 as di,jR as dj,mp as dk,Zat as dl,y3 as dm,v3 as dn,B1 as dp,kh as dq,pL as dr,Ix as ds,Gv as dt,ine as du,sS as dv,_ke as dw,jke as dx,eBt as dy,Xat as dz,pt as e,jS as e0,sn as f,vE as g,Wbs as h,da as i,e as j,rr as k,Qt as l,bIt as m,ql as n,Zi as o,mn as p,Oue as q,k as r,H as s,Rf as t,hc as u,_E as v,vp as w,Sp as x,Ji as y,me as z};